chore(overlays): trivial builder wrappers

This commit is contained in:
arcnmx 2024-06-13 14:59:35 -07:00
parent 7744e4389d
commit 7017c8c5f9
4 changed files with 134 additions and 13 deletions

76
overlays/builders.nix Normal file
View file

@ -0,0 +1,76 @@
final: prev: let
inherit (final.lib.attrsets) mapAttrs' nameValuePair;
subBuilders = {
applyPatches = args:
prev.applyPatches ({
allowSubstitutes = true;
}
// args);
writeTextFile = args:
prev.writeTextFile ({
allowSubstitutes = true;
}
// args);
writeText = name: text: final.writeTextFile' {inherit name text;};
writeShellScript = name: text:
final.writeTextFile' {
inherit name;
executable = true;
text = ''
#!${final.runtimeShell}
${text}
'';
checkPhase = ''
${final.stdenv.shellDryRun} "$target"
'';
};
writeShellScriptBin = name: text:
final.writeTextFile' {
inherit name;
destination = "/bin/${name}";
executable = true;
text = ''
#!${final.runtimeShell}
${text}
'';
checkPhase = ''
${final.stdenv.shellDryRun} "$target"
'';
};
symlinkJoin = args:
prev.symlinkJoin ({
allowSubstitutes = true;
}
// args);
linkFarm = name: entries:
(prev.linkFarm name entries).overrideAttrs (_: {
allowSubstitutes = true;
});
runCommandLocal = name: env:
final.runCommandWith {
stdenv = final.stdenvNoCC;
runLocal = true;
inherit name;
derivationArgs =
{
allowSubstitutes = true;
}
// env;
};
# TODO: writeScript, writeScriptBin, runCommandWith...
};
subBuilders' = mapAttrs' (name: nameValuePair "${name}'") subBuilders;
in {
inherit
(subBuilders')
applyPatches'
writeTextFile'
writeText'
writeShellScript'
writeShellScriptBin'
symlinkJoin'
linkFarm'
runCommandLocal'
;
__withSubBuilders = final // subBuilders;
}

View file

@ -3,6 +3,7 @@
in rec {
default = nixlib.composeManyExtensions [
barcodebuddy
builders
krb5
minecraft
nfs
@ -17,6 +18,7 @@ in rec {
nginx = import ./nginx.nix;
samba = import ./samba.nix;
openwebrx = import ./openwebrxplus.nix;
builders = import ./builders.nix;
deploy-rs = inputs.deploy-rs.overlays.default or inputs.deploy-rs.overlay;
systemd2mqtt = inputs.systemd2mqtt.overlays.default;
arc = inputs.arcexprs.overlays.default;