2022-04-24 16:35:26 -07:00
|
|
|
# Shell for bootstrapping flake-enabled nix and home-manager, from any nix version
|
|
|
|
{ pkgs ? let
|
2022-04-29 13:25:38 -07:00
|
|
|
inherit (builtins) currentSystem pathExists fromJSON readFile;
|
2022-04-24 16:35:26 -07:00
|
|
|
|
|
|
|
nixpkgs =
|
2022-04-29 13:25:38 -07:00
|
|
|
if pathExists ./flake.lock
|
2022-04-24 16:35:26 -07:00
|
|
|
then
|
|
|
|
# If we have a lock, fetch locked nixpkgs
|
2022-04-29 13:25:38 -07:00
|
|
|
let
|
|
|
|
inherit ((fromJSON (readFile ./flake.lock)).nodes.nixpkgs) locked;
|
2022-04-24 16:35:26 -07:00
|
|
|
in
|
|
|
|
fetchTarball {
|
2022-04-29 13:25:38 -07:00
|
|
|
url = "https://github.com/nixos/nixpkgs/archive/${locked.rev}.tar.gz";
|
|
|
|
sha256 = locked.narHash;
|
2022-04-24 16:35:26 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
# If not (probably because not flake-enabled), fetch nixos-unstable impurely
|
|
|
|
fetchTarball {
|
|
|
|
url = "https://github.com/nixos/nixpkgs/archive/nixos-unstable.tar.gz";
|
|
|
|
};
|
|
|
|
|
2022-04-29 13:25:38 -07:00
|
|
|
system = currentSystem;
|
|
|
|
overlays = [ ];
|
|
|
|
|
2022-04-24 16:35:26 -07:00
|
|
|
in
|
2022-04-29 13:25:38 -07:00
|
|
|
import nixpkgs { inherit system overlays; }
|
2022-04-24 16:35:26 -07:00
|
|
|
, ...
|
|
|
|
}:
|
2022-04-24 17:14:27 -07:00
|
|
|
let
|
|
|
|
# Enable experimental features without having to specify the argument
|
2022-04-29 13:25:38 -07:00
|
|
|
nix = pkgs.writeShellScriptBin "nix" ''
|
2022-04-24 17:14:27 -07:00
|
|
|
exec ${pkgs.nixFlakes}/bin/nix --experimental-features "nix-command flakes" "$@"
|
|
|
|
'';
|
|
|
|
in
|
2022-04-24 16:35:26 -07:00
|
|
|
pkgs.mkShell {
|
|
|
|
nativeBuildInputs = with pkgs; [ nix home-manager git ];
|
|
|
|
}
|