]>
Commit | Line | Data |
---|---|---|
1 | ifndef NIXOPS_ENV_LOADED | |
2 | $(error "Please load environment with direnv") | |
3 | endif | |
4 | ||
5 | ###### Current channel information | |
6 | nix-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 | |
14 | setup: | |
15 | ./scripts/setup | |
16 | .PHONY: setup | |
17 | ||
18 | ###### Morph regular tasks | |
19 | PROFILE=/nix/var/nix/profiles/per-user/immae/morph/immaeEu | |
20 | TARGET ?= | |
21 | MORPH_ARGS ?= | |
22 | ifdef TARGET | |
23 | # multiple targets: --on="{machine1,machine2}" (works with * glob too) | |
24 | override MORPH_ARGS +=--on=$(TARGET) | |
25 | endif | |
26 | SSH_ARGS ?= | |
27 | ||
28 | edit_env: | |
29 | pass edit Nixops/files/environment.nix || true | |
30 | ||
31 | ssh-eldiron: | |
32 | ./scripts/with_env bash -c 'ssh -i $$SSH_IDENTITY_FILE root@eldiron $(SSH_ARGS)' | |
33 | ||
34 | ssh-dilion: | |
35 | ./scripts/with_env bash -c 'ssh -i $$SSH_IDENTITY_FILE root@dilion $(SSH_ARGS)' | |
36 | ||
37 | ssh-backup-2: | |
38 | ./scripts/with_env bash -c 'ssh -i $$SSH_IDENTITY_FILE root@backup-2 $(SSH_ARGS)' | |
39 | ||
40 | ssh-monitoring-1: | |
41 | ./scripts/with_env bash -c 'ssh -i $$SSH_IDENTITY_FILE root@monitoring-1 $(SSH_ARGS)' | |
42 | ||
43 | ssh-4c: | |
44 | ./scripts/with_env bash -c 'ssh -i $$SSH_IDENTITY_FILE root@quatresaisons $(SSH_ARGS)' | |
45 | ||
46 | debug: | |
47 | ./scripts/with_env morph build --show-trace default.nix $(MORPH_ARGS) | |
48 | ||
49 | build: | |
50 | ./scripts/with_env morph build default.nix $(MORPH_ARGS) | |
51 | ||
52 | dry-run: | |
53 | ./scripts/with_env morph build --dry-run default.nix $(MORPH_ARGS) | |
54 | ||
55 | upload: | |
56 | ./scripts/with_env morph push default.nix $(MORPH_ARGS) | |
57 | ||
58 | deploy: | |
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 | ||
62 | deploy-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 | |
68 | GEN ?= "+3" | |
69 | ||
70 | list-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 | ||
75 | delete-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 | ||
83 | cleanup: 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 |