mirror of
https://github.com/Ahwxorg/nixos-config.git
synced 2025-12-04 15:00:13 +01:00
feat: add createScript wrapper also stolen from @ivarwithoutbones
This commit is contained in:
parent
1e931d6876
commit
e9c413994f
2 changed files with 41 additions and 1 deletions
40
pkgs/createScript/default.nix
Normal file
40
pkgs/createScript/default.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
lib,
|
||||
runCommand,
|
||||
makeWrapper,
|
||||
}:
|
||||
|
||||
# A function which creates a shell script with optional dependencies added to PATH.
|
||||
|
||||
name: src:
|
||||
{
|
||||
dependencies ? [ ],
|
||||
...
|
||||
}@attrs:
|
||||
|
||||
runCommand name
|
||||
(
|
||||
{
|
||||
inherit src;
|
||||
nativeBuildInputs = lib.optionals (dependencies != [ ]) (attrs.nativeBuildInputs or [ ]) ++ [
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
meta = {
|
||||
mainProgram = name;
|
||||
} // attrs.meta or { };
|
||||
}
|
||||
// (builtins.removeAttrs attrs [
|
||||
"nativeBuildInputs"
|
||||
"meta"
|
||||
])
|
||||
)
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
install -Dm755 $src $out/bin/$name
|
||||
patchShebangs $out/bin/$name
|
||||
|
||||
${lib.optionalString (dependencies != [ ]) ''
|
||||
wrapProgram $out/bin/$name --prefix PATH : ${lib.makeBinPath dependencies}
|
||||
''}
|
||||
''
|
||||
Loading…
Add table
Add a link
Reference in a new issue