]> Git — Sourcephile - sourcephile-nix.git/blob - .lib/nix/Makefile.make
nix: add install scripts
[sourcephile-nix.git] / .lib / nix / Makefile.make
1 nix: nix-install nixpkgs-install
2 nix-update: nix-update nixpkgs-update
3
4 nix-install:
5 if [ "$$(nix --version)" != "nix (Nix) $$(cat .lib/nix/version)" ]; then \
6 sh .lib/nix/install; \
7 fi
8
9 nix-update: .lib/nix/install .lib/nix/install.asc
10 .PHONY: .lib/nix/install .lib/nix/install.asc
11 NIX_GPGKEY:=B541D55301270E0BCF15CA5D8170B4726D7198DE
12 .lib/nix/install .lib/nix/install.asc:
13 # DOC: https://nixos.org/nix/download.html
14 cd .lib/nix && curl -OO https://nixos.org/releases/nix/nix-$$(cat .lib/nix/version)/{install,install.asc}
15 gpg2 --recv-keys $(NIX_GPGKEY)
16 gpg2 --verify .lib/nix/install.asc
17
18 nixpkgs-update: .lib/nix/nixpkgs.nix
19 .PHONY: .lib/nix/nixpkgs.nix
20 .lib/nix/nixpkgs.nix:
21 # NOTE: this pins down the specific nixpkgs revision
22 # currently used by the last Nix channel of the user;
23 # it should be run from time to time.
24 # DOC: https://nixos.wiki/wiki/How_to_fetch_Nixpkgs_with_an_empty_NIX_PATH
25 set -x; \
26 channel=$$(nix-channel --list | cut -f 1 -d ' ' | tail -1) && \
27 rev=$$(cat ~/.nix-defexpr/channels/$$channel/.git-revision) && \
28 sha256=$$(nix-prefetch-url --unpack https://github.com/NixOS/nixpkgs/archive/$$rev.tar.gz) && \
29 echo >$@ "builtins.fetchTarball {url=\"https://github.com/NixOS/nixpkgs/archive/$$rev.tar.gz\"; sha256=\"$$sha256\";}"
30 nixpkgs-clean:
31 # Remove dependencies no longer set in .lib/nix/shell.nix
32 rm -rf .cache/nix/gcroots
33 # To free disk space, you can now run something like:
34 # nix-store --gc
35
36 #cachix-update:
37 # #! nix-shell -i bash https://github.com/NixOS/nixpkgs/tarball/db557aab7b690f5e0e3348459f2e4dc8fd0d9298 -A cachix
38 # # NOTE: build the shell environment and exit on completion.
39 # nix-shell .lib/nix/shell.nix --command exit
40 # # NOTE: get a list of all the derivations used
41 # # in the shell environment and push them to the cache.
42 # nix-store -qR --include-outputs $(nix-instantiate .lib/nix/shell.nix) | cachix push $1