forked from pub-solar/os
e7c0700959
Create fetch function which takes a valid flake input, and calls fetchTarball with the revision and hash information from the flake.lock. Useful for pulling the exact revision of flake inputs from not flake expressions, such as those in shell.nix.
51 lines
1.2 KiB
Nix
51 lines
1.2 KiB
Nix
let
|
|
nixpkgs = import ./compat/nixpkgs.nix;
|
|
in
|
|
{ pkgs ? import nixpkgs { }, nixpkgs ? nixpkgs' }:
|
|
let
|
|
configs = "${toString ./.}#nixosConfigurations";
|
|
build = "config.system.build";
|
|
|
|
installPkgs = (import "${nixpkgs}/nixos" {
|
|
configuration = { };
|
|
system = pkgs.system;
|
|
}).config.system.build;
|
|
|
|
flk = pkgs.writeShellScriptBin "flk" ''
|
|
if [[ -z $1 ]]; then
|
|
echo "Usage: $(basename $0) [ iso | install {host} | {host} [switch|boot|test] ]"
|
|
elif [[ $1 == "iso" ]]; then
|
|
nix build ${configs}.niximg.${build}.isoImage
|
|
elif [[ $1 == "install" ]]; then
|
|
nixos-install --flake ".#$2" $@
|
|
else
|
|
sudo nixos-rebuild --flake ".#$1" $@
|
|
fi
|
|
'';
|
|
in
|
|
pkgs.mkShell {
|
|
name = "nixflk";
|
|
nativeBuildInputs = with pkgs; with installPkgs; [
|
|
git
|
|
git-crypt
|
|
flk
|
|
nix-zsh-completions
|
|
python38Packages.grip
|
|
nixos-install
|
|
nixos-generate-config
|
|
nixos-enter
|
|
nixos-rebuild
|
|
];
|
|
|
|
shellHook = ''
|
|
mkdir -p secrets
|
|
if ! nix flake show &> /dev/null; then
|
|
PATH=${
|
|
pkgs.writeShellScriptBin "nix" ''
|
|
${pkgs.nixFlakes}/bin/nix --option experimental-features "nix-command flakes ca-references" "$@"
|
|
''
|
|
}/bin:$PATH
|
|
fi
|
|
'';
|
|
}
|