]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame_incremental - nixops/Makefile
Remove netdata stream key from the store
[perso/Immae/Config/Nix.git] / nixops / Makefile
... / ...
CommitLineData
1ifndef NIXOPS_ENV_LOADED
2 $(error "Please load environment with direnv")
3endif
4
5###### Current channel information
6nix-info:
7 @version=$$(nix eval --raw nixpkgs.lib.version) && \
8 mainversion=$$(echo $$version | cut -d"." -f -2) && \
9 echo "https://releases.nixos.org/nixos/$$mainversion/nixos-$$version/nixexprs.tar.xz" && \
10 nix-instantiate --find-file nixpkgs
11.PHONY: nix-info
12
13###### Initial setup
14setup:
15 ./scripts/setup
16.PHONY: setup
17
18###### Morph regular tasks
19PROFILE=/nix/var/nix/profiles/per-user/immae/morph/immaeEu
20TARGET ?=
21MORPH_ARGS ?=
22ifdef TARGET
23 # multiple targets: --on="{machine1,machine2}" (works with * glob too)
24 override MORPH_ARGS +=--on=$(TARGET)
25endif
26SSH_ARGS ?=
27
28edit_env:
29 pass edit Nixops/files/environment.nix || true
30
31ssh-eldiron:
32 ./scripts/with_env bash -c 'ssh -i $$SSH_IDENTITY_FILE root@eldiron $(SSH_ARGS)'
33
34ssh-dilion:
35 ./scripts/with_env bash -c 'ssh -i $$SSH_IDENTITY_FILE root@dilion $(SSH_ARGS)'
36
37ssh-backup-2:
38 ./scripts/with_env bash -c 'ssh -i $$SSH_IDENTITY_FILE root@backup-2 $(SSH_ARGS)'
39
40ssh-monitoring-1:
41 ./scripts/with_env bash -c 'ssh -i $$SSH_IDENTITY_FILE root@monitoring-1 $(SSH_ARGS)'
42
43ssh-4c:
44 ./scripts/with_env bash -c 'ssh -i $$SSH_IDENTITY_FILE root@quatresaisons $(SSH_ARGS)'
45
46debug:
47 ./scripts/with_env morph build --show-trace default.nix $(MORPH_ARGS)
48
49build:
50 ./scripts/with_env morph build default.nix $(MORPH_ARGS)
51
52dry-run:
53 ./scripts/with_env morph build --dry-run default.nix $(MORPH_ARGS)
54
55upload:
56 ./scripts/with_env morph push default.nix $(MORPH_ARGS)
57
58deploy:
59 ./scripts/with_env morph deploy default.nix switch --keep-result --upload-secrets $(MORPH_ARGS)
60 nix-env -p $(PROFILE) --set .gcroots/default.nix
61
62deploy-reboot:
63 ./scripts/with_env morph deploy default.nix boot --reboot --upload-secrets $(MORPH_ARGS)
64
65.PHONY: ssh-eldiron ssh-dilion ssh-monitoring-1 ssh-backup-2 debug build upload deploy deploy-reboot
66
67###### Cleanup generations and garbage collection
68GEN ?= "+3"
69
70list-generations:
71 nix-env -p $(PROFILE) --list-generations
72 $(MAKE) ssh-eldiron SSH_ARGS="nix-env -p /nix/var/nix/profiles/system --list-generations"
73.PHONY: list-generations
74
75delete-generations:
76 nix-env -p $(PROFILE) --delete-generations $(GEN)
77 $(MAKE) ssh-eldiron SSH_ARGS="nix-env -p /nix/var/nix/profiles/system --delete-generations $(GEN)"
78 $(MAKE) ssh-dilion SSH_ARGS="nix-env -p /nix/var/nix/profiles/system --delete-generations $(GEN)"
79 $(MAKE) ssh-backup-2 SSH_ARGS="nix-env -p /nix/var/nix/profiles/system --delete-generations $(GEN)"
80 $(MAKE) ssh-monitoring-1 SSH_ARGS="nix-env -p /nix/var/nix/profiles/system --delete-generations $(GEN)"
81.PHONY: delete-generations
82
83cleanup: delete-generations
84 nix-store --gc
85 $(MAKE) ssh-eldiron SSH_ARGS="nix-store --gc"
86 $(MAKE) ssh-dilion SSH_ARGS="nix-store --gc"
87 $(MAKE) ssh-backup-2 SSH_ARGS="nix-store --gc"
88 $(MAKE) ssh-monitoring-1 SSH_ARGS="nix-store --gc"
89.PHONY: cleanup