aboutsummaryrefslogtreecommitdiff
path: root/nixos
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2022-10-11 13:15:50 +0200
committerKarel Kočí <cynerd@email.cz>2022-10-11 13:15:50 +0200
commit7e45f16948a802a3810d915b315f810f83fe8900 (patch)
tree95132766f0e9e82c8d48472342d946cd7c53a51c /nixos
parentc57793639f332984bbe90b3c991fef931b915c29 (diff)
downloadnixos-personal-7e45f16948a802a3810d915b315f810f83fe8900.tar.gz
nixos-personal-7e45f16948a802a3810d915b315f810f83fe8900.tar.bz2
nixos-personal-7e45f16948a802a3810d915b315f810f83fe8900.zip
hosts.sh: support not only devices and use screen to detach switch
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/generic.nix5
-rw-r--r--nixos/modules/nixos-system.sh27
2 files changed, 32 insertions, 0 deletions
diff --git a/nixos/modules/generic.nix b/nixos/modules/generic.nix
index ff635cf..fb2879c 100644
--- a/nixos/modules/generic.nix
+++ b/nixos/modules/generic.nix
@@ -131,6 +131,11 @@ in {
'';
})
];
+
+ system.extraSystemBuilderCmds = ''
+ substituteAll ${./nixos-system.sh} $out/bin/nixos-system
+ chmod +x $out/bin/nixos-system
+ '';
};
}
diff --git a/nixos/modules/nixos-system.sh b/nixos/modules/nixos-system.sh
new file mode 100644
index 0000000..7a220bb
--- /dev/null
+++ b/nixos/modules/nixos-system.sh
@@ -0,0 +1,27 @@
+#!@shell@
+# Simple script handy to be used for activation
+
+while getopts "s" opt; do
+ case "$opt" in
+ s)
+ if [ ! -v NIXOS_SYSTEM_GNU_SCREEN ]; then
+ export NIXOS_SYSTEM_GNU_SCREEN=1
+ exec @out@/sw/bin/screen "$0" "$@"
+ fi
+ ;;
+ *)
+ echo "Invalid argument: $1" >&2
+ exit 1
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+
+@out@/sw/bin/nix-env --profile /nix/var/nix/profiles/system --set '@out@'
+
+@out@/bin/switch-to-configuration "$@" || {
+ echo "Switch failed!" >&2
+ read -r _
+ exit 1
+}