Skip to content

Commit de81c31

Browse files
authored
Fix materialization message (#1635)
Strings with context are the ones in the store that cannot be updated with the script (not the other way around).
1 parent c83b33f commit de81c31

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/materialize.nix

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,18 @@ let
8383
fi
8484
'')
8585
+ (
86-
let fixHint = if builtins.hasContext (toString materialized)
87-
then "To fix run: ${updateMaterialized}"
88-
else "To fix check you are in the right directory and run: ${generateMaterialized} ${__head (__match "/nix/store/[^/]*/(.*)" (toString materialized))}";
86+
let
87+
# When the materialized location is already in the store updateMaterialized
88+
# will not work, but generateMaterialized will. We can use this regex to get
89+
# a good idea of what directory might be (relative to some unknown parent).
90+
# In the regex `[^/]*/?` skips the name of the /nix/store sub directory.
91+
matches = __match "${builtins.storeDir}/[^/]*/?(.*)" (toString materialized);
92+
fixHint =
93+
if matches == null
94+
then "To fix run: ${updateMaterialized}" # Not in store so updateMaterialized may work
95+
else if __head matches == ""
96+
then "To fix run: ${generateMaterialized} <materialized files location>"
97+
else "To fix check you are in the right directory and run: ${generateMaterialized} ${__head matches}";
8998
in if materialized != null && !__pathExists materialized
9099
then ''
91100
echo "Materialized nix used for ${name} is missing. ${fixHint}" >> $ERR

0 commit comments

Comments
 (0)