]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - nixops/scripts/setup
Freeze channel version when deploying.
[perso/Immae/Config/Nix.git] / nixops / scripts / setup
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