diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-25 15:11:11 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-04-25 00:04:22 +0200 |
commit | a8e4bf7554dc7219b23c0ff076321f62c24b2b82 (patch) | |
tree | 0f6f2512811374036e29d9c66e18fff1f20cadc1 | |
parent | 6afdbd8c052a347284772d6d7b2d90977f174018 (diff) | |
download | NUR-a8e4bf7554dc7219b23c0ff076321f62c24b2b82.tar.gz NUR-a8e4bf7554dc7219b23c0ff076321f62c24b2b82.tar.zst NUR-a8e4bf7554dc7219b23c0ff076321f62c24b2b82.zip |
Use Makefile for some env/deploy scripts
-rw-r--r-- | Makefile | 22 | ||||
-rwxr-xr-x | scripts/make-env | 4 | ||||
-rw-r--r-- | scripts/nix_env | 14 | ||||
-rwxr-xr-x | scripts/nix_infos | 10 |
4 files changed, 22 insertions, 28 deletions
@@ -1,6 +1,17 @@ | |||
1 | subrecipes = setup ssh-eldiron info debug dry-run build upload deploy reboot push pull pull-deployment list-generations delete-generations cleanup | 1 | subrecipes = setup |
2 | subrecipes += nixops ssh-eldiron info debug dry-run build upload deploy deploy-reboot reboot | ||
3 | subrecipes += list-generations delete-generations cleanup | ||
4 | subrecipes += pull pull_environment pull_deployment deployment_is_set push push_deployment push_environment | ||
2 | ${subrecipes}: | 5 | ${subrecipes}: |
3 | @$(MAKE) --no-print-directory -C nixops/ $@ | 6 | @$(MAKE) --no-print-directory -C nixops/ $@ |
7 | .PHONY: ${subrecipes} | ||
8 | |||
9 | # This will automatically upgrade to latest version at each build | ||
10 | nixpkgs ?= https://nixos.org/channels/nixos-19.03/nixexprs.tar.xz | ||
11 | NIX_PATH = nixpkgs=${nixpkgs}:nixpkgsNext=${nixpkgs}:nixpkgsPrevious=${nixpkgs} | ||
12 | |||
13 | nix-path: | ||
14 | @echo "export NIX_PATH=$(NIX_PATH)" | ||
4 | 15 | ||
5 | env: | 16 | env: |
6 | ./scripts/make-env | 17 | ./scripts/make-env |
@@ -9,10 +20,13 @@ env-dry-run: | |||
9 | ./scripts/make-env --dry-run | 20 | ./scripts/make-env --dry-run |
10 | 21 | ||
11 | nix-info: | 22 | nix-info: |
12 | NIXOPS_DEPLOYMENT="" ./scripts/nix_infos | 23 | @version=$$(nix eval --raw nixpkgs.lib.version) && \ |
24 | mainversion=$$(echo $$version | cut -d"." -f -2) && \ | ||
25 | echo "https://releases.nixos.org/nixos/$$mainversion/nixos-$$version/nixexprs.tar.xz" && \ | ||
26 | nix eval --raw nixpkgs.bc.meta.position | cut -d"/" -f-4 | ||
13 | 27 | ||
14 | nix-info-nixops: | 28 | nix-info-nixops: |
15 | NIXOPS_DEPLOYMENT="n" ./scripts/nix_infos | 29 | @$(MAKE) --no-print-directory -C nixops/ nix-info |
16 | 30 | ||
17 | nur: | 31 | nur: |
18 | ./scripts/make-nur | 32 | ./scripts/make-nur |
@@ -21,4 +35,4 @@ nur: | |||
21 | shellcheck: | 35 | shellcheck: |
22 | shellcheck scripts/* nixops/scripts/* modules/private/gitolite/gitolite_ldap_groups.sh modules/private/ssh/ldap_authorized_keys.sh modules/private/pub/restrict | 36 | shellcheck scripts/* nixops/scripts/* modules/private/gitolite/gitolite_ldap_groups.sh modules/private/ssh/ldap_authorized_keys.sh modules/private/pub/restrict |
23 | 37 | ||
24 | .PHONY: env env-dry-run nix-info nix-info-nixops nur shellcheck | 38 | .PHONY: env env-dry-run nix-info nur shellcheck |
diff --git a/scripts/make-env b/scripts/make-env index 983a3590..25aa869a 100755 --- a/scripts/make-env +++ b/scripts/make-env | |||
@@ -2,11 +2,11 @@ | |||
2 | 2 | ||
3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
4 | 4 | ||
5 | source $DIR/nix_env | 5 | eval "$(make --no-print-directory -C $(dirname $DIR) nix-path)" |
6 | nix-env -r -i -A myEnvironments.immae-eu -f "<nixpkgs>" "$@" | 6 | nix-env -r -i -A myEnvironments.immae-eu -f "<nixpkgs>" "$@" |
7 | result=$? | 7 | result=$? |
8 | 8 | ||
9 | cat >> $(dirname $DIR)/versions_log <<EOF | 9 | cat >> $(dirname $DIR)/versions_log <<EOF |
10 | Ran $(date) with args "$@" and returned "$result" | 10 | Ran $(date) with args "$@" and returned "$result" |
11 | $($DIR/nix_infos | sed -e "s/^/ /") | 11 | $(make --no-print-directory -C $(dirname $DIR) nix-info | sed -e "s/^/ /") |
12 | EOF | 12 | EOF |
diff --git a/scripts/nix_env b/scripts/nix_env index 7bc14dd3..7fb6646d 100644 --- a/scripts/nix_env +++ b/scripts/nix_env | |||
@@ -1,17 +1,7 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | if [ -z "$NIXOPS_DEPLOYMENT" ]; then | 3 | # This will automatically upgrade to latest version at each build |
4 | # This will automatically upgrade to latest version at each build | 4 | nixpkgs="https://nixos.org/channels/nixos-19.03/nixexprs.tar.xz" |
5 | nixpkgs="https://nixos.org/channels/nixos-19.03/nixexprs.tar.xz" | ||
6 | else | ||
7 | nixpkgs="https://releases.nixos.org/nixos/19.03/nixos-19.03.172731.3efdf45dbd1/nixexprs.tar.xz" | ||
8 | fi | ||
9 | nixpkgsPrevious="$nixpkgs" | 5 | nixpkgsPrevious="$nixpkgs" |
10 | nixpkgsNext="$nixpkgs" | 6 | nixpkgsNext="$nixpkgs" |
11 | export NIX_PATH="nixpkgs=$nixpkgs:nixpkgsNext=$nixpkgsNext:nixpkgsPrevious=$nixpkgsPrevious" | 7 | export NIX_PATH="nixpkgs=$nixpkgs:nixpkgsNext=$nixpkgsNext:nixpkgsPrevious=$nixpkgsPrevious" |
12 | |||
13 | nixops_custom () { | ||
14 | _DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
15 | d=$(nix-build --no-out-link -E "with import <nixpkgs> { overlays = builtins.attrValues (import $(dirname $_DIR)/overlays); }; nixops") | ||
16 | ${d}/bin/nixops "$@" | ||
17 | } | ||
diff --git a/scripts/nix_infos b/scripts/nix_infos deleted file mode 100755 index 56e5b197..00000000 --- a/scripts/nix_infos +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
4 | |||
5 | source $DIR/nix_env | ||
6 | version=$(nix eval --raw nixpkgs.lib.version) | ||
7 | mainversion=$(echo $version | cut -d"." -f -2) | ||
8 | |||
9 | echo "https://releases.nixos.org/nixos/$mainversion/nixos-$version/nixexprs.tar.xz" | ||
10 | nix eval --raw nixpkgs.bc.meta.position | cut -d"/" -f-4 | ||