summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-06-28 15:04:45 +0200
committertv <tv@shackspace.de>2015-06-28 15:06:12 +0200
commit2e6221e095c0086674248526bae3e1ad03efc064 (patch)
tree3b84c415cbdc02394bed0b8ee698ea078842168a
parent3ca8eec45c93d6fd0f887613f7df2b16e63a8b69 (diff)
fetchgit: allow using dirty local work trees
-rwxr-xr-xbin/fetchgit26
-rwxr-xr-xbin/nixos-build5
-rwxr-xr-xinfest-cac-CentOS-7-64bit.sh8
-rw-r--r--modules/common/nixpkgs.nix9
4 files changed, 35 insertions, 13 deletions
diff --git a/bin/fetchgit b/bin/fetchgit
index 7862989be..ba5b40b6a 100755
--- a/bin/fetchgit
+++ b/bin/fetchgit
@@ -1,14 +1,27 @@
#! /bin/sh
#
-# usage: fetchgit git_rev git_url out_link
+# usage: fetchgit repo_name out_link
#
-# Clone the specified Git repository and make it available as out_link.
+# Make the specified repository available as out_link.
#
set -euf
-git_rev=$1
-git_url=$2
-out_link=$3
+repo_name=$1
+out_link=$2
+
+if test "$repo_name" != nixpkgs; then
+ echo "fetchgit: cannot fetch $repo_name, yet" >&2
+ exit -1
+fi
+
+git_rev=$(nixos-query nixpkgs.rev)
+git_url=$(nixos-query nixpkgs.url)
+dirty=$(nixos-query nixpkgs.dirty)
+
+case $dirty in true)
+ ln -snf "$git_url" "$out_link"
+ exit
+esac
# Put all bases in the same place as out_link.
# Notice how out_link must not clash with cache_dir and work_dir.
@@ -39,7 +52,8 @@ is_up_to_date() {
test "$(work_git rev-parse --verify HEAD)" = "$git_rev"
}
-# Notice how the remote name "origin" has been chosen arbitrarily.
+# Notice how the remote name "origin" has been chosen arbitrarily, but must be
+# kept in sync with the default value of nixpkgs.rev.
if ! is_up_to_date; then
if ! test -d "$cache_dir"; then
mkdir -p "$cache_dir"
diff --git a/bin/nixos-build b/bin/nixos-build
index 200f99e4a..d00fc4d6b 100755
--- a/bin/nixos-build
+++ b/bin/nixos-build
@@ -21,10 +21,7 @@ secrets_rsync=$secrets_root/$host/rsync
NIX_PATH=$NIX_PATH:secrets=$secrets_nix
export NIX_PATH
- rev=$(nixos-query nixpkgs.rev)
- url=$(nixos-query nixpkgs.url)
-
- fetchgit "$rev" "$url" tmp/nixpkgs/$host
+ fetchgit nixpkgs tmp/nixpkgs/$host
)
nix-build \
diff --git a/infest-cac-CentOS-7-64bit.sh b/infest-cac-CentOS-7-64bit.sh
index 207c403de..a4ef51ebf 100755
--- a/infest-cac-CentOS-7-64bit.sh
+++ b/infest-cac-CentOS-7-64bit.sh
@@ -14,10 +14,12 @@ systemname=$2
NIX_PATH=$NIX_PATH:secrets=$PWD/secrets/$systemname/nix
export NIX_PATH
- rev=$(nixos-query nixpkgs.rev)
- url=$(nixos-query nixpkgs.url)
+ case $(nixos-query nixpkgs.dirty) in true)
+ echo "$0: cannot use nixpkgs.dirty" >&2 # b/c ./cac pushconfig
+ exit -1
+ esac
- fetchgit "$rev" "$url" tmp/nixpkgs/$systemname
+ fetchgit nixpkgs tmp/nixpkgs/$systemname
)
./cac poll 10s 2>/dev/null &
diff --git a/modules/common/nixpkgs.nix b/modules/common/nixpkgs.nix
index 36ebbb075..486cf0207 100644
--- a/modules/common/nixpkgs.nix
+++ b/modules/common/nixpkgs.nix
@@ -10,7 +10,16 @@ with lib;
};
nixpkgs.rev = mkOption {
type = types.str;
+ default = "origin/master";
description = "Revision of the remote repository.";
};
+ nixpkgs.dirty = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ If nixpkgs.url is a local path, then use that as it is.
+ TODO this break if URL is not a local path.
+ '';
+ };
};
}