on iko/ghcjs-patch-master help sign in
Symlinks in materialized cause permissions err (#650)
3356114Hamish Mackenzie
lib/materialize.nix+6−6
@@ -77,7 +77,7 @@ let
77 if materialized != null && !__pathExists materialized
77 if materialized != null && !__pathExists materialized
78 then ''
78 then ''
79 echo "Materialized nix used for ${name} is missing. To fix run :" >> $ERR
79 echo "Materialized nix used for ${name} is missing. To fix run :" >> $ERR
80− echo " cp -r ${calculateNoHash} ${toString materialized}" >> $ERR
80+ echo " cp -Lr ${calculateNoHash} ${toString materialized}" >> $ERR
81 echo " chmod -R +w ${toString materialized}" >> $ERR
81 echo " chmod -R +w ${toString materialized}" >> $ERR
82 cat $ERR
82 cat $ERR
83 false
83 false
@@ -91,7 +91,7 @@ let
91 diff -ru ${materialized} ${calculateNoHash} || true
91 diff -ru ${materialized} ${calculateNoHash} || true
92 echo "Materialized nix used for ${name} incorrect. To fix run :" >> $ERR
92 echo "Materialized nix used for ${name} incorrect. To fix run :" >> $ERR
93 echo " rm -rf ${toString materialized}" >> $ERR
93 echo " rm -rf ${toString materialized}" >> $ERR
94− echo " cp -r ${calculateNoHash} ${toString materialized}" >> $ERR
94+ echo " cp -Lr ${calculateNoHash} ${toString materialized}" >> $ERR
95 echo " chmod -R +w ${toString materialized}" >> $ERR
95 echo " chmod -R +w ${toString materialized}" >> $ERR
96 fi
96 fi
97 '')
97 '')
@@ -100,7 +100,7 @@ let
100 cat $ERR
100 cat $ERR
101 false
101 false
102 else
102 else
103− cp -r ${unchecked} $out
103+ cp -Lr ${unchecked} $out
104 # Make sure output files can be removed from the sandbox
104 # Make sure output files can be removed from the sandbox
105 chmod -R +w $out
105 chmod -R +w $out
106 fi
106 fi
@@ -114,10 +114,10 @@ let
114 };
114 };
115 calculateNoHash = derivation;
115 calculateNoHash = derivation;
116 calculateUseHash =
116 calculateUseHash =
117− # Use `cp -r` here to get rid of symlinks so we know the result
117+ # Use `cp -Lr` here to get rid of symlinks so we know the result
118 # can be safely materialized (no symlinks to the store).
118 # can be safely materialized (no symlinks to the store).
119 runCommand name hashArgs ''
119 runCommand name hashArgs ''
120− cp -r ${derivation} $out
120+ cp -Lr ${derivation} $out
121 # Make sure output files can be removed from the sandbox
121 # Make sure output files can be removed from the sandbox
122 chmod -R +w $out
122 chmod -R +w $out
123 '';
123 '';
@@ -125,7 +125,7 @@ let
125 assert materialized != null;
125 assert materialized != null;
126 assert __pathExists materialized;
126 assert __pathExists materialized;
127 runCommand name (pkgs.lib.optionalAttrs (sha256 == null) hashArgs) ''
127 runCommand name (pkgs.lib.optionalAttrs (sha256 == null) hashArgs) ''
128− cp -r ${materialized} $out
128+ cp -Lr ${materialized} $out
129 # Make sure output files can be removed from the sandbox
129 # Make sure output files can be removed from the sandbox
130 chmod -R +w $out
130 chmod -R +w $out
131 '';
131 '';
overlays/ghc-packages.nix+12−5
@@ -22,11 +22,18 @@ let
22
22
23 # Combines multiple derivations into one to make them
23 # Combines multiple derivations into one to make them
24 # easier to materialize.
24 # easier to materialize.
25+ # Using `cp -Lr` here follows the symlinks and prevents
26+ # `access to path is forbidden in restricted mode`
27+ # errors on hydra when the materialized files are not present.
25− combineFiles = name: ext: files: final.linkFarm name
28+ combineFiles = name: ext: files:
29+ let links = final.linkFarm name
26− (final.lib.mapAttrsToList (name: path: {
30+ (final.lib.mapAttrsToList (name: path: {
27− name = name + ext;
31+ name = name + ext;
28− inherit path;
32+ inherit path;
29− }) files);
33+ }) files);
34+ in final.evalPackages.runCommand "${name}${ext}" {} ''
35+ cp -Lr ${links} $out
36+ '';
30
37
31 # Combine the all the boot package nix files for a given ghc
38 # Combine the all the boot package nix files for a given ghc
32 # into a single derivation and materialize it.
39 # into a single derivation and materialize it.