1
1
mirror of https://github.com/nmattia/niv.git synced 2024-09-19 11:27:40 +03:00

Turn NIV_OVERRIDE values into paths

Otherwise they're not accessible from the sandbox.
This commit is contained in:
Nicolas Mattia 2020-09-28 16:25:43 +02:00
parent 29ddaaf4e0
commit 9d35b9e483
2 changed files with 8 additions and 1 deletions

View File

@ -98,7 +98,10 @@ let
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
in 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 # Ports of functions for older nix versions

View File

@ -170,6 +170,8 @@ data SourcesNixVersion
V22 V22
| -- Allow to pass custom system to bootstrap niv in pure mode | -- Allow to pass custom system to bootstrap niv in pure mode
V23 V23
| -- Fix NIV_OVERRIDE_{name} for sandbox
V24
deriving stock (Bounded, Enum, Eq) deriving stock (Bounded, Enum, Eq)
-- | A user friendly version -- | A user friendly version
@ -198,6 +200,7 @@ sourcesVersionToText = \case
V21 -> "21" V21 -> "21"
V22 -> "22" V22 -> "22"
V23 -> "23" V23 -> "23"
V24 -> "24"
latestVersionMD5 :: T.Text latestVersionMD5 :: T.Text
latestVersionMD5 = sourcesVersionToMD5 maxBound latestVersionMD5 = sourcesVersionToMD5 maxBound
@ -233,6 +236,7 @@ sourcesVersionToMD5 = \case
V21 -> "c501eee378828f7f49828a140dbdbca3" V21 -> "c501eee378828f7f49828a140dbdbca3"
V22 -> "935d1d2f0bf95fda977a6e3a7e548ed4" V22 -> "935d1d2f0bf95fda977a6e3a7e548ed4"
V23 -> "4111204b613ec688e2669516dd313440" V23 -> "4111204b613ec688e2669516dd313440"
V24 -> "116c2d936f1847112fef0013771dab28"
-- | The MD5 sum of ./nix/sources.nix -- | The MD5 sum of ./nix/sources.nix
sourcesNixMD5 :: IO T.Text sourcesNixMD5 :: IO T.Text