Make flake update automatically

This commit is contained in:
Peder Bergebakken Sundt 2023-02-26 21:15:08 +01:00
parent 198167e42a
commit 107c8b901e
1 changed files with 18 additions and 19 deletions

View File

@ -12,30 +12,29 @@
nixpkgs.config.allowUnfreePredicate = (pkg: true); nixpkgs.config.allowUnfreePredicate = (pkg: true);
# 'nixos-rebuild switch --upgrade', by default daily with no reboot # 'nixos-rebuild switch --upgrade', by default daily with no reboot
system.autoUpgrade.enable = true;
#system.autoUpgrade.allowReboot = true; # reboot after a kernel (module) or initrd upgrade, consider also setting `rebootWindow` #system.autoUpgrade.allowReboot = true; # reboot after a kernel (module) or initrd upgrade, consider also setting `rebootWindow`
# TODO: this check is not pure /** /
system.autoUpgrade = if builtins.pathExists "/etc/nixos/flake.nix" then { #TODO: should i check for .git instead? # TODO: this doesn't work during 'nix eval' on a non-nixos machine
enable = true; system.autoUpgrade.flake = "/etc/nixos";
flake = "/etc/nixos"; system.autoUpgrade.flags = [
flags = [
"--recreate-lock-file" # fetch new inputs "--recreate-lock-file" # fetch new inputs
#"--commit-lock-file" # commit new lock to local git repo #"--commit-lock-file" # commit new lock to local git repo
# TODO: can i somehow first do a git pull --rebase --autostash with proper abort handling ? # TODO: can i somehow first do a git pull --rebase --autostash with proper abort handling ?
"-L" # print build logs "-L" # print build logs
]; ];
} else { #assertions = [
enable = true; # { assertion = builtins.pathExists "/etc/nixos/flake.nix"; message = "You have yet to test systems without a flake in /etc/nixos"; }
flake = inputs.self.outPath; # a nix store path #];
flags = [ /**/
system.autoUpgrade.flake = inputs.self.outPath; # a nix store path
#system.autoUpgrade.flake = "github:pbsds/nix-config"; # TODO: use this instead?
system.autoUpgrade.flags = [
"--recreate-lock-file" # fetch new inputs "--recreate-lock-file" # fetch new inputs
"--no-write-lock-file" # no write new flakelock, as the in-store flake is read-only "--no-write-lock-file" # no write new flakelock, as the in-store flake is read-only
"-L" # print build logs "-L" # print build logs
]; ];
}; /**/
# TODO: this doesn't work during 'nix eval' on a non-nixos machine
#assertions = [
# { assertion = builtins.pathExists "/etc/nixos/flake.nix"; message = "You have yet to test systems without a flake in /etc/nixos"; }
#];
nix.settings.trusted-users = [ "root" ]; # default, but will stick around after a mergins with ./users nix.settings.trusted-users = [ "root" ]; # default, but will stick around after a mergins with ./users
nix.settings.auto-optimise-store = true; # deduplicate with hardlinks, expensive. Alternative: nix-store --optimise nix.settings.auto-optimise-store = true; # deduplicate with hardlinks, expensive. Alternative: nix-store --optimise