nixos-configuration/pkgs/by-name/mk/mkScriptOverride/package.nix

31 lines
524 B
Nix

{
lib,
stdenv,
}:
{
src,
script,
...
} @ args:
lib.hiPrio (stdenv.mkDerivation (
{
src = src;
name = if lib.isDerivation src
then "${src.name}-script-override"
else "${builtins.baseNameOf src}-script-override";
phases = [ "installPhase" "scriptOverridePhase" ];
installPhase = ''
runHook preInstall
cp -r $src $out
chmod u+w -R $out
runHook postInstall
'';
scriptOverridePhase = script;
} // lib.removeAttrs args [
"pkg"
"commands"
]
))