]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Freeze channel version when deploying.
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 1 Feb 2019 12:25:57 +0000 (13:25 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 1 Feb 2019 12:25:57 +0000 (13:25 +0100)
nixops/scripts/nixops_wrap
nixops/scripts/setup

index 1efe8a9bc082870b10b0a88be7abac701d2dbbd7..1de38f5a8879fd64573d127568cfea50a51f95e9 100755 (executable)
@@ -18,4 +18,6 @@ trap finish EXIT
 pass show "$NIXOPS_CONFIG_PASS_SUBTREE_PATH/NixConfig" >> $TEMP
 nixops set-args --argstr environment "$TEMP"
 
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+export NIX_PATH="ssh-config-file=$(dirname $DIR)/ssh/config:nixpkgs=$HOME/.nix-defexpr/channels/immaeNixpkgs"
 nixops "$@"
index ff20fc91df48c16d166affd44e9eadf99ad47c77..d9d42585a9dd58244419d4b57bf4283a5c14ed4b 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/bash
 
 RemoteRepo="gitolite@git.immae.eu:perso/Immae/Prive/Password_store/Mes_Sites/Paul"
+NixChannelUrl='https://releases.nixos.org/nixos/18.09/nixos-18.09.1834.9d608a6f592'
+NixChannelName='immaeNixpkgs'
 
 if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_REMOTE" \
     -o -z "$NIXOPS_CONFIG_PASS_SUBTREE_PATH" ]; then
@@ -67,16 +69,27 @@ EOF
   fi
 fi
 
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-nix_config="ssh-config-file=$(dirname $DIR)/ssh/config"
-if echo "$NIX_PATH" | grep -q "$nix_config"; then
-  cat <<EOF
-All set up
-EOF
-else
+if ! nix-channel --list | grep -q "$NixChannelName $NixChannelUrl"; then
 cat <<EOF
-All set up, please add
-ssh-config-file=$(dirname $DIR)/ssh/config
-to your NIX_PATH environment variable (colon-separated)
+A new nix channel will be installed (or upgraded) to freeze the packages
+version:
+$NixChannelName $NixChannelUrl
+> nix-channel --add $NixChannelUrl $NixChannelName
+> nix-channel --update
+If this step fail, you may have to disable sandboxing in
+/etc/nix/nix.conf and rerun
+> nix-channel --update
+manually.
+Continue? [y/N]
 EOF
+  read y
+  if [ "$y" = "y" -o "$y" = "Y" ]; then
+    nix-channel --add $NixChannelUrl $NixChannelName
+    nix-channel --update
+  fi
 fi
+
+cat <<EOF
+All set up.
+Please make sure you’re using scripts/nixops_wrap when deploying
+EOF