mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
home-manager-auto-upgrade: add flake support (#8053)
Adds the ability for the auto-upgrade service to update a Nix flake instead of Nix channels. This is controlled by a new `useFlake` boolean option. When enabled, the service will run `nix flake update` in the directory specified by the `flakeDir` option. `flakeDir` defaults to the standard Home Manager configuration directory (`~/.config/home-manager`), making this feature work out-of-the-box for most users. The path is passed to the upgrade script via an environment variable in the systemd service unit.
This commit is contained in:
parent
2a9969b39c
commit
255b6a0ef2
4 changed files with 70 additions and 7 deletions
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||
home-manager-auto-upgrade-basic-configuration = ./basic-configuration.nix;
|
||||
home-manager-auto-upgrade-flake-configuration = ./flake-configuration.nix;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
services.home-manager.autoUpgrade = {
|
||||
enable = true;
|
||||
frequency = "daily";
|
||||
useFlake = true;
|
||||
flakeDir = "/tmp/my-flake";
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
serviceFile="home-files/.config/systemd/user/home-manager-auto-upgrade.service"
|
||||
assertFileExists "$serviceFile"
|
||||
assertFileRegex "$serviceFile" "FLAKE_DIR=/tmp/my-flake"
|
||||
|
||||
scriptPath=$(grep -oP 'ExecStart=\K.+' "$TESTED/$serviceFile")
|
||||
assertFileRegex "$scriptPath" "nix flake update"
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue