refactor nixos rebuild arguments

This commit is contained in:
Sean Buckley 2021-04-08 21:55:37 -04:00
parent 704e9b53f1
commit 49d9ebb5e3

View file

@ -1,6 +1,7 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
cfg = config.sconfig.flakes; cfg = config.sconfig.flakes;
upgradeArg = if cfg.rebuildPath == "/etc/nixos" then "--recreate-lock-file" else "--refresh";
in in
{ {
options.sconfig.flakes = { options.sconfig.flakes = {
@ -20,7 +21,7 @@ in
''; '';
system.autoUpgrade.flake = cfg.rebuildPath; system.autoUpgrade.flake = cfg.rebuildPath;
system.autoUpgrade.flags = [ (lib.optionalString (cfg.rebuildPath == "/etc/nixos") "--recreate-lock-file") ]; system.autoUpgrade.flags = [ upgradeArg ];
environment.systemPackages = map environment.systemPackages = map
(x: (pkgs.writeShellScriptBin (x: (pkgs.writeShellScriptBin
@ -31,9 +32,9 @@ in
[ "switch" "switch" ] [ "switch" "switch" ]
[ "build" "build" ] [ "build" "build" ]
[ "boot" "boot" ] [ "boot" "boot" ]
[ "switch-upgrade" "switch" (if cfg.rebuildPath == "/etc/nixos" then "--recreate-lock-file" else "--refresh") ] [ "switch-upgrade" "switch" upgradeArg ]
[ "build-upgrade" "build" (if cfg.rebuildPath == "/etc/nixos" then "--recreate-lock-file" else "--refresh") ] [ "build-upgrade" "build" upgradeArg ]
[ "boot-upgrade" "boot" (if cfg.rebuildPath == "/etc/nixos" then "--recreate-lock-file" else "--refresh") ] [ "boot-upgrade" "boot" upgradeArg ]
]; ];
}; };