ctucx.git: nixfiles

ctucx' nixfiles

commit 291437659854f0077a45722a33c5b08d0945253e
parent 4c107badbf27337b9fa32ae2e706f2151b7f727c
Author: Leah (ctucx) <leah@ctu.cx>
Date: Fri, 10 Jun 2022 16:28:35 +0200

hotfix for nixos-{deploy,rebuild} scripts on nix 2.8
2 files changed, 14 insertions(+), 2 deletions(-)
M
nixos-deploy
|
8
+++++++-
M
nixos-rebuild
|
8
+++++++-
diff --git a/nixos-deploy b/nixos-deploy
@@ -1,5 +1,9 @@
  #!/usr/bin/env bash
 set -eo pipefail
+
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+
 cd "$(dirname "$0")"
 
 machine="${1:-lollo}"

@@ -16,10 +20,12 @@ fi
 echo "deploying $machine to $target"
 sleep 1
 
+cp --no-preserve=mode -r $(nix-build nix/sources-dir.nix --no-out-link) $tmp/sources
+
 set -x
 system_drv=$(
   nix-instantiate "<nixpkgs/nixos>" -A config.system.build.toplevel \
-    -I "$(nix-build nix/sources-dir.nix --no-out-link)" \
+    -I "$tmp/sources" \
     -I "nixos-config=machines/$machine/configuration.nix"
 )
 nix-copy-closure --to $target $system_drv
diff --git a/nixos-rebuild b/nixos-rebuild
@@ -1,2 +1,8 @@
 #!/usr/bin/env sh
-nixos-rebuild -I $(nix-build $(temp=$( realpath "$0"  ) && dirname "$temp")/nix/sources-dir.nix --no-out-link) "$@"
+
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+
+cp --no-preserve=mode -r $(nix-build $(temp=$( realpath "$0"  ) && dirname "$temp")/nix/sources-dir.nix --no-out-link) $tmp/sources
+
+nixos-rebuild -I "$tmp/sources" "$@"