nix: nix-install nixpkgs-install nix-update: nix-update nixpkgs-update nix-install: if [ "$$(nix --version)" != "nix (Nix) $$(cat .lib/nix/version)" ]; then \ sh .lib/nix/install; \ fi nix-update: .lib/nix/install .lib/nix/install.asc .PHONY: .lib/nix/install .lib/nix/install.asc NIX_GPGKEY:=B541D55301270E0BCF15CA5D8170B4726D7198DE .lib/nix/install .lib/nix/install.asc: # DOC: https://nixos.org/nix/download.html cd .lib/nix && curl -OO https://nixos.org/releases/nix/nix-$$(cat .lib/nix/version)/{install,install.asc} gpg2 --recv-keys $(NIX_GPGKEY) gpg2 --verify .lib/nix/install.asc nixpkgs-update: .lib/nix/nixpkgs.nix .PHONY: .lib/nix/nixpkgs.nix .lib/nix/nixpkgs.nix: # NOTE: this pins down the specific nixpkgs revision # currently used by the last Nix channel of the user; # it should be run from time to time. # DOC: https://nixos.wiki/wiki/How_to_fetch_Nixpkgs_with_an_empty_NIX_PATH set -x; \ channel=$$(nix-channel --list | cut -f 1 -d ' ' | tail -1) && \ rev=$$(cat ~/.nix-defexpr/channels/$$channel/.git-revision) && \ sha256=$$(nix-prefetch-url --unpack https://github.com/NixOS/nixpkgs/archive/$$rev.tar.gz) && \ echo >$@ "builtins.fetchTarball {url=\"https://github.com/NixOS/nixpkgs/archive/$$rev.tar.gz\"; sha256=\"$$sha256\";}" nixpkgs-clean: # Remove dependencies no longer set in .lib/nix/shell.nix rm -rf .cache/nix/gcroots # To free disk space, you can now run something like: # nix-store --gc #cachix-update: # #! nix-shell -i bash https://github.com/NixOS/nixpkgs/tarball/db557aab7b690f5e0e3348459f2e4dc8fd0d9298 -A cachix # # NOTE: build the shell environment and exit on completion. # nix-shell .lib/nix/shell.nix --command exit # # NOTE: get a list of all the derivations used # # in the shell environment and push them to the cache. # nix-store -qR --include-outputs $(nix-instantiate .lib/nix/shell.nix) | cachix push $1