Skip to content

Instantly share code, notes, and snippets.

@LisannaAtHome
Created December 4, 2017 07:17
Show Gist options
  • Save LisannaAtHome/4e7b38fbd426e9d5d78b25512aff526f to your computer and use it in GitHub Desktop.
Save LisannaAtHome/4e7b38fbd426e9d5d78b25512aff526f to your computer and use it in GitHub Desktop.
{
fixup = options: name: file: stdenvNoCC.mkDerivation
( options //
{ inherit name;
installPhase =
''cp -r ${file} $out
'';
}
);
wrap = { paths ? [], vars ? {}, file ? null, script ? null, name ? "wrap" }:
assert file != null || script != null ||
abort "wrap needs 'file' or 'script' argument";
with rec
{ set = n: v:
"--set ${escapeShellArg (escapeShellArg n)} " +
"'\"'${escapeShellArg (escapeShellArg v)}'\"'";
args =
(map (p: "--prefix PATH : ${p}/bin") paths) ++
(attrValues (mapAttrs set vars));
};
runCommand name
{ f =
if file == null then writeScript name script
else file;
buildInputs = [ makeWrapper ];
}
'' makeWrapper "$f" "$out" ${toString args}
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment