update scripts

auto-flake-update
Yorick van Pelt 2017-01-30 17:41:05 +01:00
parent 352b50e090
commit 31dd1de293
2 changed files with 6 additions and 48 deletions

17
conf
View File

@ -5,20 +5,15 @@ then
sudo chgrp nixbld deploy_key
chmod 640 deploy_key
fi
export NIX_PATH="ssh-id-file=`pwd`/deploy_key":secrets=`pwd`/secrets.nix
case $1 in
local)
export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=`pwd`/ascanius/configuration.nix:secrets=`pwd`/secrets.nix
eval ${@:2}
;;
remote)
export NIX_PATH="nixpkgs=https://nixos.org/channels/nixos-16.09/nixexprs.tar.xz:nixos-config=`pwd`/$2/configuration.nix:ssh-id-file=`pwd`/deploy_key":secrets=`pwd`/secrets.nix
stable)
export NIX_PATH="nixpkgs=https://nixos.org/channels/nixos-16.09/nixexprs.tar.xz:nixos-config=`pwd`/$2/configuration.nix:$NIX_PATH"
eval ${@:3}
;;
local-deploy)
sudo $0 local nixos-rebuild switch
;;
remote-deploy)
$0 remote $2 nixos-rebuild --build-host localhost --target-host root@$2 switch
channel)
export NIX_PATH="/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=`pwd`/$2/configuration.nix:$NIX_PATH"
eval ${@:3}
;;
update-encrypt)
gpg -a -r yorick --encrypt-files secrets.nix deploy_key keys/*.key

View File

@ -1,37 +0,0 @@
#!/usr/bin/env bash
set -e
userspace_update_cmd="$(cat <<EOF
echo "updating dotfiles"
if [ ! -d ~/dotfiles ]
then
git clone git@git.yori.cc:yorick/dotfiles.git ~/dotfiles
else
cd ~/dotfiles/
git pull git@git.yori.cc:yorick/dotfiles.git
fi
~/dotfiles/install.sh
echo "updating userspace"
~/dotfiles/bin/update_userspace.sh
EOF
)"
if [ $1 == "local" ];
then
sudo nix-channel --update
echo "updating root conf"
./conf local-deploy
sh -c "$userspace_update_cmd"
else
echo "updating" $1
HOST=$(nix-instantiate --eval -A hostnames.$1 secrets.nix | tr -d '"')
./conf remote-deploy $1 root@$HOST switch
echo "updating userspace"
#nix-copy-closure --to root@$HOST $(./conf remote nix-build --no-out-link "\<nixpkgs\>" -A hosts.$1)
echo "nix-channel --update" | ssh root@$HOST
cp deploy_key deploy_key2
chmod 0600 deploy_key2
ssh-agent bash <<J
ssh-add ./deploy_key2
rm ./deploy_key2
ssh -A $HOST sh -c "$userspace_update_cmd"
J
fi