From 8f44460003ae10f543ccb6a29f15b57e42ca3aad Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 8 Aug 2019 17:12:48 +0200 Subject: populate git: add fetchAlways option --- lib/types/populate.nix | 4 ++++ pkgs/populate/default.nix | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/types/populate.nix b/lib/types/populate.nix index 49996f6..bf90ace 100644 --- a/lib/types/populate.nix +++ b/lib/types/populate.nix @@ -81,6 +81,10 @@ type = lib.types.listOf lib.types.str; }; }; + fetchAlways = lib.mkOption { + type = lib.types.bool; + default = false; + }; ref = lib.mkOption { type = lib.types.str; # TODO lib.types.git.ref }; diff --git a/pkgs/populate/default.nix b/pkgs/populate/default.nix index ad70d2e..1367a50 100644 --- a/pkgs/populate/default.nix +++ b/pkgs/populate/default.nix @@ -66,9 +66,13 @@ let hash=${quote source.ref} if ! test "$(git log --format=%H -1)" = "$hash"; then - if ! git log -1 "$hash" >/dev/null 2>&1; then + ${if source.fetchAlways then /* sh */ '' git fetch origin - fi + '' else /* sh */ '' + if ! git log -1 "$hash" >/dev/null 2>&1; then + git fetch origin + fi + ''} git reset --hard "$hash" >&2 git submodule update --init --recursive fi -- cgit v1.2.3