Browse Source

add writeSubstitutedShellScriptBin

Signed-off-by: Magic_RB <magic_rb@redalder.org>
master
Magic_RB 1 month ago
parent
commit
6236d9e963
Signed by: Magic_RB GPG Key ID: 08D5287CC5DDCA0E
2 changed files with 21 additions and 0 deletions
  1. +1
    -0
      flake.nix
  2. +20
    -0
      lib/write-substituted-shell-script-bin.nix

+ 1
- 0
flake.nix View File

@ -30,6 +30,7 @@
runInVm = callPackage ./lib/vm/run-in-vm.nix;
writeSubstitutedShellScript = callPackage ./lib/write-substituted-shell-script.nix {};
writeSubstitutedFile = callPackage ./lib/write-substituted-file.nix {};
writeSubstitutedShellScriptBin = callPackage ./lib/write-substituted-shell-script-bin.nix {};
};
giteaSystem = import ./examples/gitea self.lib;


+ 20
- 0
lib/write-substituted-shell-script-bin.nix View File

@ -0,0 +1,20 @@
{ runCommandNoCCLocal
, runtimeShell
, busybox
}:
{
name
, file
, substitutes
}:
runCommandNoCCLocal name ({
nativeBuildInputs = [ busybox ];
} // substitutes)
''
TMPFILE=$(mktemp)
substituteAll ${file} $TMPFILE
mkdir -p $out/bin && touch $out/bin/${name}
echo "#! ${runtimeShell}" > $out/bin/${name}
cat $TMPFILE >> $out/bin/${name}
chmod +x $out/bin/${name}
''

Loading…
Cancel
Save