fetchgit: allow using dirty local work trees
This commit is contained in:
parent
3ca8eec45c
commit
2e6221e095
26
bin/fetchgit
26
bin/fetchgit
|
@ -1,14 +1,27 @@
|
||||||
#! /bin/sh
|
#! /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
|
set -euf
|
||||||
|
|
||||||
git_rev=$1
|
repo_name=$1
|
||||||
git_url=$2
|
out_link=$2
|
||||||
out_link=$3
|
|
||||||
|
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.
|
# Put all bases in the same place as out_link.
|
||||||
# Notice how out_link must not clash with cache_dir and work_dir.
|
# 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"
|
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 ! is_up_to_date; then
|
||||||
if ! test -d "$cache_dir"; then
|
if ! test -d "$cache_dir"; then
|
||||||
mkdir -p "$cache_dir"
|
mkdir -p "$cache_dir"
|
||||||
|
|
|
@ -21,10 +21,7 @@ secrets_rsync=$secrets_root/$host/rsync
|
||||||
NIX_PATH=$NIX_PATH:secrets=$secrets_nix
|
NIX_PATH=$NIX_PATH:secrets=$secrets_nix
|
||||||
export NIX_PATH
|
export NIX_PATH
|
||||||
|
|
||||||
rev=$(nixos-query nixpkgs.rev)
|
fetchgit nixpkgs tmp/nixpkgs/$host
|
||||||
url=$(nixos-query nixpkgs.url)
|
|
||||||
|
|
||||||
fetchgit "$rev" "$url" tmp/nixpkgs/$host
|
|
||||||
)
|
)
|
||||||
|
|
||||||
nix-build \
|
nix-build \
|
||||||
|
|
|
@ -14,10 +14,12 @@ systemname=$2
|
||||||
NIX_PATH=$NIX_PATH:secrets=$PWD/secrets/$systemname/nix
|
NIX_PATH=$NIX_PATH:secrets=$PWD/secrets/$systemname/nix
|
||||||
export NIX_PATH
|
export NIX_PATH
|
||||||
|
|
||||||
rev=$(nixos-query nixpkgs.rev)
|
case $(nixos-query nixpkgs.dirty) in true)
|
||||||
url=$(nixos-query nixpkgs.url)
|
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 &
|
./cac poll 10s 2>/dev/null &
|
||||||
|
|
|
@ -10,7 +10,16 @@ with lib;
|
||||||
};
|
};
|
||||||
nixpkgs.rev = mkOption {
|
nixpkgs.rev = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
default = "origin/master";
|
||||||
description = "Revision of the remote repository.";
|
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.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue