summaryrefslogtreecommitdiffstats
path: root/bin/nixos-fetch-git
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-05-21 23:52:06 +0200
committertv <tv@shackspace.de>2015-05-21 23:52:06 +0200
commitf8b1e849a6a3bd53f24a4aac70bc904cdb5ff711 (patch)
tree826235e1b776665ab32ee787bb96cd3b6f519d95 /bin/nixos-fetch-git
parentac764394050f6fc39e406799085259d3fc08956a (diff)
deploy: merge next
Diffstat (limited to 'bin/nixos-fetch-git')
-rwxr-xr-xbin/nixos-fetch-git32
1 files changed, 32 insertions, 0 deletions
diff --git a/bin/nixos-fetch-git b/bin/nixos-fetch-git
new file mode 100755
index 000000000..7002208b5
--- /dev/null
+++ b/bin/nixos-fetch-git
@@ -0,0 +1,32 @@
+#! /bin/sh
+#
+# nixos-fetch-git : nixos-config -> ...
+#
+set -euf
+
+host=$1
+
+target=root@$host
+
+git_rev=$(nixos-query "$host" nixpkgs.rev)
+git_url=$(nixos-query "$host" nixpkgs.url)
+
+worktree=$nixpkgs_root/$host
+
+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"