Skip to content

Commit 7fc83df

Browse files
committed
bin/nixos-shell: use nix run
Use `nix run` instead of puttling the `result` in a temporary directory and run the executable with a glob pattern.
1 parent bfc8c1a commit 7fc83df

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

bin/nixos-shell

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,21 @@ done
5353

5454
unset NIXOS_CONFIG
5555

56-
tempdir=$(mktemp -d)
57-
cleanup() {
58-
rm -rf "$tempdir"
59-
}
60-
trap cleanup EXIT SIGINT SIGQUIT ERR
61-
6256
if [[ -z "$flake_uri" ]]; then
6357
extraBuildFlags+=(
6458
-I "nixos-config=$nixos_config"
6559
)
6660
else
6761
extraBuildFlags+=(
68-
--extra-experimental-features "flakes"
62+
--extra-experimental-features "nix-command flakes"
6963
--argstr flakeStr "$flake"
7064
--argstr flakeUri "$flake_uri"
7165
--argstr flakeAttr "${flake_attr:-"vm"}"
7266
)
7367
fi
7468

75-
nix-build "${script_dir}/../share/nixos-shell.nix" -A "config.system.build.vm" -k \
76-
-o "${tempdir}/result" \
77-
"${extraBuildFlags[@]}"
69+
nix run config.system.build.vm \
70+
--file "${script_dir}/../share/nixos-shell.nix" \
71+
--keep-going \
72+
"${extraBuildFlags[@]}" \
7873
"$@"
79-
"${tempdir}/result/bin/"run-*-vm

0 commit comments

Comments
 (0)