summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-23 22:57:11 +0000
committertv <tv@krebsco.de>2026-11-23 23:30:13 +0000
commit8f425987f93cddb2aad21524bc52f7d6df29a07c (patch)
tree54ea48e7afeef5b341e4c97910c581e96d116574
parent35de496b57dfb8a9293c7f0002f1621119745bd4 (diff)
krops.nix: add switch argument
-rw-r--r--krops.nix41
1 files changed, 30 insertions, 11 deletions
diff --git a/krops.nix b/krops.nix
index 6f7858db..5a8925cd 100644
--- a/krops.nix
+++ b/krops.nix
@@ -9,11 +9,22 @@
# diff build the system on the target and show what switching to it
# would change
#
+# ARGUMENTS
+# name the host to deploy
+# target where to deploy it, instead of spec.nix's target
+# switch what switch-to-configuration does: switch (the default), boot,
+# or test (no new generation)
+#
{ lib ? import ~/sync/src/krops/lib
, pkgs ? import ~/sync/src/krops/pkgs {}
, name
, target ? null
-}@args: rec {
+, switch ? "switch"
+}@args:
+
+assert builtins.elem switch [ "switch" "boot" "test" ];
+
+rec {
spec = {
nixpkgs = "nixos-26.05";
@@ -82,16 +93,24 @@
}}
)
${builtins.getAttr deploy-action {
- deploy = /* sh */ ''
- old_gen=$(readlink -f /nix/var/nix/profiles/system)
- new_gen=$(readlink -f "$system")
- if [ "x$old_gen" != "x$new_gen" ]; then
- nix-env -p /nix/var/nix/profiles/system --set "$system"
- "$system"/bin/switch-to-configuration switch
- else
- echo 'Configuration is already up to date' >&2
- fi
- '';
+ deploy = let
+ setAndSwitch = /* sh */ ''
+ old_gen=$(readlink -f /nix/var/nix/profiles/system)
+ new_gen=$(readlink -f "$system")
+ if [ "x$old_gen" != "x$new_gen" ]; then
+ nix-env -p /nix/var/nix/profiles/system --set "$system"
+ "$system"/bin/switch-to-configuration ${switch}
+ else
+ echo 'Configuration is already up to date' >&2
+ fi
+ '';
+ in builtins.getAttr switch {
+ switch = setAndSwitch;
+ boot = setAndSwitch;
+ test = /* sh */ ''
+ "$system"/bin/switch-to-configuration test
+ '';
+ };
diff = /* sh */ ''
nix --extra-experimental-features nix-command \
store diff-closures /run/current-system "$system"