Skip to content

Commit 44ce07e

Browse files
authored
Merge pull request #76 from ShamrockLee/bin-nix-run
bin/nixos-shell: use `nix run` to run; flake.nix: use `packages.<system>.default`
2 parents 8a835e2 + 7fc83df commit 44ce07e

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
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

flake.nix

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@
4242

4343
//
4444

45-
lib.foldl' lib.recursiveUpdate {} (lib.forEach supportedSystems (system: rec {
45+
lib.foldl' lib.recursiveUpdate {} (lib.forEach supportedSystems (system: {
4646

47-
packages."${system}".nixos-shell = import ./default.nix {
48-
pkgs = inp.nixpkgs.legacyPackages."${system}";
49-
};
47+
packages."${system}" = {
48+
nixos-shell = import ./default.nix {
49+
pkgs = inp.nixpkgs.legacyPackages."${system}";
50+
};
5051

51-
defaultPackage."${system}" = packages."${system}".nixos-shell;
52+
default = inp.self.packages."${system}".nixos-shell;
53+
};
5254

5355
}));
5456
}

0 commit comments

Comments
 (0)