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

32 lines
522 B
Nix
Raw Normal View History

2024-07-28 23:11:38 +02:00
{
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";
2024-07-28 23:11:38 +02:00
phases = [ "installPhase" "scriptOverridePhase" ];
installPhase = ''
runHook preInstall
cp -r $src $out
chmod u+w -R $out
runHook postInstall
'';
scriptOverridePhase = script;
} // lib.removeAttrs args [
"src"
"script"
2024-07-28 23:11:38 +02:00
]
))