couple improvements in shell.nix
This commit is contained in:
parent
fa0748a598
commit
a4d2b03b3c
18
shell.nix
18
shell.nix
|
@ -1,16 +1,17 @@
|
||||||
# Shell for bootstrapping flake-enabled nix and home-manager, from any nix version
|
# Shell for bootstrapping flake-enabled nix and home-manager, from any nix version
|
||||||
{ pkgs ? let
|
{ pkgs ? let
|
||||||
system = builtins.currentSystem or "Unknown system";
|
inherit (builtins) currentSystem pathExists fromJSON readFile;
|
||||||
|
|
||||||
nixpkgs =
|
nixpkgs =
|
||||||
if builtins.pathExists ./flake.lock
|
if pathExists ./flake.lock
|
||||||
then
|
then
|
||||||
# If we have a lock, fetch locked nixpkgs
|
# If we have a lock, fetch locked nixpkgs
|
||||||
let lock = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked;
|
let
|
||||||
|
inherit ((fromJSON (readFile ./flake.lock)).nodes.nixpkgs) locked;
|
||||||
in
|
in
|
||||||
fetchTarball {
|
fetchTarball {
|
||||||
url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz";
|
url = "https://github.com/nixos/nixpkgs/archive/${locked.rev}.tar.gz";
|
||||||
sha256 = lock.narHash;
|
sha256 = locked.narHash;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
# If not (probably because not flake-enabled), fetch nixos-unstable impurely
|
# If not (probably because not flake-enabled), fetch nixos-unstable impurely
|
||||||
|
@ -18,13 +19,16 @@
|
||||||
url = "https://github.com/nixos/nixpkgs/archive/nixos-unstable.tar.gz";
|
url = "https://github.com/nixos/nixpkgs/archive/nixos-unstable.tar.gz";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
system = currentSystem;
|
||||||
|
overlays = [ ];
|
||||||
|
|
||||||
in
|
in
|
||||||
import nixpkgs { inherit system; }
|
import nixpkgs { inherit system overlays; }
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
# Enable experimental features without having to specify the argument
|
# Enable experimental features without having to specify the argument
|
||||||
nix = (pkgs.writeShellScriptBin) "nix" ''
|
nix = pkgs.writeShellScriptBin "nix" ''
|
||||||
exec ${pkgs.nixFlakes}/bin/nix --experimental-features "nix-command flakes" "$@"
|
exec ${pkgs.nixFlakes}/bin/nix --experimental-features "nix-command flakes" "$@"
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
|
|
Loading…
Reference in a new issue