bscpkgs/garlic/stages/experiment.nix
2020-10-09 16:42:06 +02:00

44 lines
705 B
Nix

{
stdenv
, nixPrefix ? ""
}:
units:
with stdenv.lib;
let
stageProgram = stage:
if stage ? programPath
then "${stage}${stage.programPath}" else "${stage}";
unitsString = builtins.concatStringsSep "\n"
(map (x: "${stageProgram x}") units);
desc = builtins.concatStringsSep "\n"
(map (x: ''
# ${x}
${x.desc}'') units);
in
stdenv.mkDerivation {
name = "experiment";
phases = [ "installPhase" ];
preferLocalBuild = true;
dontPatchShebangs = true;
inherit units;
inherit desc;
installPhase = ''
cat > $out << EOF
#!/bin/sh
${desc}
# This is an experiment formed by the following units:
${unitsString}
EOF
chmod +x $out
'';
}