diff options
| author | Xe Iaso <me@christine.website> | 2022-07-14 17:22:56 -0400 |
|---|---|---|
| committer | Xe Iaso <me@christine.website> | 2022-07-14 17:22:56 -0400 |
| commit | ecdf2115f83f762c7236f2b6cf4f9655e27aa601 (patch) | |
| tree | 4ad11dda4705a98a359d32b87e62a31b25720eea | |
| parent | 35e2696147b5549de7eb863ac94a2932823788c1 (diff) | |
| download | xesite-ecdf2115f83f762c7236f2b6cf4f9655e27aa601.tar.xz xesite-ecdf2115f83f762c7236f2b6cf4f9655e27aa601.zip | |
update niv
Signed-off-by: Xe Iaso <me@christine.website>
| -rw-r--r-- | nix/sources.nix | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/nix/sources.nix b/nix/sources.nix index b796fff..9a01c8a 100644 --- a/nix/sources.nix +++ b/nix/sources.nix @@ -31,8 +31,28 @@ let if spec ? branch then "refs/heads/${spec.branch}" else if spec ? tag then "refs/tags/${spec.tag}" else abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; + submodules = if spec ? submodules then spec.submodules else false; + submoduleArg = + let + nixSupportsSubmodules = builtins.compareVersions builtins.nixVersion "2.4" >= 0; + emptyArgWithWarning = + if submodules == true + then + builtins.trace + ( + "The niv input \"${name}\" uses submodules " + + "but your nix's (${builtins.nixVersion}) builtins.fetchGit " + + "does not support them" + ) + {} + else {}; + in + if nixSupportsSubmodules + then { inherit submodules; } + else emptyArgWithWarning; in - builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; + builtins.fetchGit + ({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg); fetch_local = spec: spec.path; @@ -98,7 +118,10 @@ let saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; in - if ersatz == "" then drv else ersatz; + if ersatz == "" then drv else + # this turns the string into an actual Nix path (for both absolute and + # relative paths) + if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; # Ports of functions for older nix versions |
