48 lines
892 B
Nix
48 lines
892 B
Nix
{
|
|
pkgs,
|
|
lib,
|
|
vaculib,
|
|
...
|
|
}:
|
|
let
|
|
runCommandBare =
|
|
{
|
|
cmd,
|
|
local ? true,
|
|
...
|
|
}@args:
|
|
assert !vaculib.isPrefixOf "-" cmd;
|
|
derivation (
|
|
{
|
|
builder = lib.getExe pkgs.bash;
|
|
args = [
|
|
"-c"
|
|
cmd
|
|
];
|
|
system = pkgs.buildPlatform.system;
|
|
}
|
|
// (lib.optionalAttrs local {
|
|
allowSubstitutes = false;
|
|
preferLocalBuild = true;
|
|
})
|
|
// (lib.removeAttrs args [
|
|
"cmd"
|
|
"local"
|
|
])
|
|
);
|
|
outputOf =
|
|
{
|
|
removeNewline ? true,
|
|
...
|
|
}@args:
|
|
let
|
|
passThruArgs = lib.removeAttrs args [ "removeNewline" ];
|
|
res = builtins.readFile (runCommandBare passThruArgs);
|
|
noNewline = lib.removeSuffix "\n" res;
|
|
in
|
|
if removeNewline then noNewline else res;
|
|
in
|
|
{
|
|
config.vacu.vaculib = { inherit runCommandBare outputOf; };
|
|
}
|