diff options
author | tv <tv@shackspace.de> | 2015-06-24 20:00:52 +0200 |
---|---|---|
committer | tv <tv@shackspace.de> | 2015-06-24 20:00:52 +0200 |
commit | 0fa8921e803876d85e1a0d49d925c2919714ee56 (patch) | |
tree | ef5cd237fc110842e64cc3ecf889093d1f63b365 | |
parent | bea25b5640e72a64605406b40f3cbcf5d0c6c9de (diff) |
infest-cac-CentOS-7-64bit: fetchgit
-rwxr-xr-x | infest-cac-CentOS-7-64bit.sh | 13 | ||||
-rwxr-xr-x | newbin/fetchgit | 25 | ||||
-rwxr-xr-x | newbin/nixos-query | 8 |
3 files changed, 46 insertions, 0 deletions
diff --git a/infest-cac-CentOS-7-64bit.sh b/infest-cac-CentOS-7-64bit.sh index 32090ae9e..0f2efae6b 100755 --- a/infest-cac-CentOS-7-64bit.sh +++ b/infest-cac-CentOS-7-64bit.sh @@ -4,6 +4,19 @@ set -xeuf serverspec=$1 systemname=$2 +( + # Notice NIX_PATH used from host + # Notice secrets required to evaluate configuration + NIX_PATH=$NIX_PATH:nixos-config=$PWD/modules/$systemname + NIX_PATH=$NIX_PATH:secrets=$PWD/secrets/$systemname/nix + export NIX_PATH + + rev=$(newbin/nixos-query nixpkgs.rev) + url=$(newbin/nixos-query nixpkgs.url) + + newbin/fetchgit "$rev" "$url" tmp/nixpkgs/$systemname +) + ./cac poll 10s 2>/dev/null & pollpid=$! trap "kill $pollpid; trap - EXIT" EXIT diff --git a/newbin/fetchgit b/newbin/fetchgit new file mode 100755 index 000000000..b9fe90854 --- /dev/null +++ b/newbin/fetchgit @@ -0,0 +1,25 @@ +#! /bin/sh +# usage: fetchgit REVISION URL WORKTREE +set -euf + +git_rev=$1 +git_url=$2 +worktree=$3 + +if [ ! -d "$worktree" ]; then + mkdir -p "$worktree" +fi + +cd "$worktree" + +git init -q + +if ! current_url=$(git config remote.src.url); then + git remote add src "$git_url" +elif [ "$current_url" != "$git_url" ]; then + git remote set-url src "$git_url" +fi + +git fetch src + +git checkout "$git_rev" diff --git a/newbin/nixos-query b/newbin/nixos-query new file mode 100755 index 000000000..57761b520 --- /dev/null +++ b/newbin/nixos-query @@ -0,0 +1,8 @@ +#! /bin/sh +set -euf +nix-instantiate \ + -A config."$1" \ + --eval \ + --json \ + '<nixos>' \ + | jq -r . |