fix: Make single-package mkTf2Config derivations neatly overridable
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{ runCommand, lib }:
|
||||
{ stdenv, lib }:
|
||||
|
||||
{ pname
|
||||
, version ? null
|
||||
, version ? "nover"
|
||||
, custom ? []
|
||||
, cfg ? []
|
||||
, maps ? []
|
||||
@@ -18,13 +18,50 @@ let
|
||||
mkdir -p "$out/${output}"
|
||||
${lib.toShellVar "outputList_${output}" var}
|
||||
for i in "''${outputList_${output}[@]}"; do
|
||||
ln -s "$i" "$out/${output}/$(basename "$i")"
|
||||
name="$(stripHash "$i")"
|
||||
vpkDir="#vpk-''${name}#"
|
||||
if [ -d "$vpkDir" ]; then
|
||||
mv "$vpkDir/$name" "$out/${output}/$name"
|
||||
else
|
||||
mv "$name" "$out/${output}/$name"
|
||||
fi
|
||||
done
|
||||
'';
|
||||
in runCommand name env ''
|
||||
|
||||
allSrcs = cfg ++ maps ++ custom;
|
||||
|
||||
srcArg =
|
||||
if builtins.length allSrcs == 1
|
||||
then { src = builtins.head allSrcs; }
|
||||
else { srcs = allSrcs; sourceRoot = "."; };
|
||||
in stdenv.mkDerivation ({
|
||||
inherit pname version;
|
||||
# Adapted from stdenv's _defaultUnpack().
|
||||
unpackCmd = ''
|
||||
if [ "''${curSrc##*.}" = "vpk" ]; then
|
||||
destination="#vpk-$(stripHash "$curSrc")#/$(stripHash "$curSrc")"
|
||||
mkdir "$(dirname "$destination")"
|
||||
if [ -e "$destination" ]; then
|
||||
echo "Cannot copy $curSrc to $destination: destination already exists!"
|
||||
echo "Did you specify two \"srcs\" with the same \"name\"?"
|
||||
return 1
|
||||
fi
|
||||
# We can't preserve hardlinks because they may have been
|
||||
# introduced by store optimization, which might break things
|
||||
# in the build.
|
||||
cp -r --preserve=mode,timestamps --reflink=auto -- "$curSrc" "$destination"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
'';
|
||||
installPhase = ''
|
||||
set -xe
|
||||
mkdir -p $out
|
||||
${lib.optionalString (builtins.length allSrcs == 1)
|
||||
"cd .."}
|
||||
ls -la
|
||||
${make-output "cfg" cfg}
|
||||
${make-output "custom" custom}
|
||||
${make-output "maps" maps}
|
||||
''
|
||||
'';
|
||||
} // srcArg // env)
|
||||
|
||||
Reference in New Issue
Block a user