Use Makefile for some env/deploy scripts
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 25 May 2019 13:11:11 +0000 (15:11 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 27 May 2019 22:40:06 +0000 (00:40 +0200)
Makefile
scripts/make-env
scripts/nix_env
scripts/nix_infos [deleted file]

index 62a0f9d..3ab58cf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,17 @@
-subrecipes = setup ssh-eldiron info debug dry-run build upload deploy reboot push pull pull-deployment list-generations delete-generations cleanup
+subrecipes = setup
+subrecipes += nixops ssh-eldiron info debug dry-run build upload deploy deploy-reboot reboot
+subrecipes += list-generations delete-generations cleanup
+subrecipes += pull pull_environment pull_deployment deployment_is_set push push_deployment push_environment
 ${subrecipes}:
        @$(MAKE) --no-print-directory -C nixops/ $@
+.PHONY: ${subrecipes}
+
+# This will automatically upgrade to latest version at each build
+nixpkgs ?= https://nixos.org/channels/nixos-19.03/nixexprs.tar.xz
+NIX_PATH = nixpkgs=${nixpkgs}:nixpkgsNext=${nixpkgs}:nixpkgsPrevious=${nixpkgs}
+
+nix-path:
+       @echo "export NIX_PATH=$(NIX_PATH)"
 
 env:
        ./scripts/make-env
@@ -9,10 +20,13 @@ env-dry-run:
        ./scripts/make-env --dry-run
 
 nix-info:
-       NIXOPS_DEPLOYMENT="" ./scripts/nix_infos
+       @version=$$(nix eval --raw nixpkgs.lib.version) && \
+         mainversion=$$(echo $$version | cut -d"." -f -2) && \
+         echo "https://releases.nixos.org/nixos/$$mainversion/nixos-$$version/nixexprs.tar.xz" && \
+         nix eval --raw nixpkgs.bc.meta.position | cut -d"/" -f-4
 
 nix-info-nixops:
-       NIXOPS_DEPLOYMENT="n" ./scripts/nix_infos
+       @$(MAKE) --no-print-directory -C nixops/ nix-info
 
 nur:
        ./scripts/make-nur
@@ -21,4 +35,4 @@ nur:
 shellcheck:
        shellcheck scripts/* nixops/scripts/* modules/private/gitolite/gitolite_ldap_groups.sh modules/private/ssh/ldap_authorized_keys.sh modules/private/pub/restrict
 
-.PHONY: env env-dry-run nix-info nix-info-nixops nur shellcheck
+.PHONY: env env-dry-run nix-info nur shellcheck
index 983a359..25aa869 100755 (executable)
@@ -2,11 +2,11 @@
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
 
-source $DIR/nix_env
+eval "$(make --no-print-directory -C $(dirname $DIR) nix-path)"
 nix-env -r -i -A myEnvironments.immae-eu -f "<nixpkgs>" "$@"
 result=$?
 
 cat >> $(dirname $DIR)/versions_log <<EOF
 Ran $(date) with args "$@" and returned "$result"
-$($DIR/nix_infos | sed -e "s/^/    /")
+$(make --no-print-directory -C $(dirname $DIR) nix-info | sed -e "s/^/    /")
 EOF
index 7bc14dd..7fb6646 100644 (file)
@@ -1,17 +1,7 @@
 #!/bin/bash
 
-if [ -z "$NIXOPS_DEPLOYMENT" ]; then
-  # This will automatically upgrade to latest version at each build
-  nixpkgs="https://nixos.org/channels/nixos-19.03/nixexprs.tar.xz"
-else
-  nixpkgs="https://releases.nixos.org/nixos/19.03/nixos-19.03.172731.3efdf45dbd1/nixexprs.tar.xz"
-fi
+# This will automatically upgrade to latest version at each build
+nixpkgs="https://nixos.org/channels/nixos-19.03/nixexprs.tar.xz"
 nixpkgsPrevious="$nixpkgs"
 nixpkgsNext="$nixpkgs"
 export NIX_PATH="nixpkgs=$nixpkgs:nixpkgsNext=$nixpkgsNext:nixpkgsPrevious=$nixpkgsPrevious"
-
-nixops_custom () {
-  _DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-  d=$(nix-build --no-out-link -E "with import <nixpkgs> { overlays = builtins.attrValues (import $(dirname $_DIR)/overlays); }; nixops")
-  ${d}/bin/nixops "$@"
-}
diff --git a/scripts/nix_infos b/scripts/nix_infos
deleted file mode 100755 (executable)
index 56e5b19..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-
-source $DIR/nix_env
-version=$(nix eval --raw nixpkgs.lib.version)
-mainversion=$(echo $version | cut -d"." -f -2)
-
-echo "https://releases.nixos.org/nixos/$mainversion/nixos-$version/nixexprs.tar.xz"
-nix eval --raw nixpkgs.bc.meta.position | cut -d"/" -f-4