2022-03-08 05:02:25 +00:00
|
|
|
{ busybox, contentAddressed ? false }:
|
2020-06-25 16:26:34 +00:00
|
|
|
|
2009-03-17 17:11:55 +00:00
|
|
|
with import ./config.nix;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2022-03-08 05:02:25 +00:00
|
|
|
caArgs = if contentAddressed then {
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
__contentAddressed = true;
|
|
|
|
} else {};
|
|
|
|
|
2020-06-25 16:26:34 +00:00
|
|
|
mkDerivation = args:
|
|
|
|
derivation ({
|
|
|
|
inherit system;
|
|
|
|
builder = busybox;
|
2024-03-07 09:46:47 +00:00
|
|
|
args = ["sh" "-e" args.builder or (builtins.toFile "builder-${args.name}.sh" ''
|
|
|
|
if [ -e "$NIX_ATTRS_SH_FILE" ]; then source $NIX_ATTRS_SH_FILE; fi;
|
|
|
|
eval "$buildCommand"
|
|
|
|
'')];
|
2022-03-08 05:02:25 +00:00
|
|
|
} // removeAttrs args ["builder" "meta" "passthru"]
|
|
|
|
// caArgs)
|
2022-02-20 14:56:22 +00:00
|
|
|
// { meta = args.meta or {}; passthru = args.passthru or {}; };
|
2020-06-25 16:26:34 +00:00
|
|
|
|
2009-03-17 17:11:55 +00:00
|
|
|
input1 = mkDerivation {
|
2020-06-25 16:26:34 +00:00
|
|
|
shell = busybox;
|
|
|
|
name = "build-remote-input-1";
|
2022-03-04 15:58:27 +00:00
|
|
|
buildCommand = "echo hi-input1; echo FOO > $out";
|
2017-05-02 13:35:35 +00:00
|
|
|
requiredSystemFeatures = ["foo"];
|
2009-03-17 17:11:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
input2 = mkDerivation {
|
2020-06-25 16:26:34 +00:00
|
|
|
shell = busybox;
|
|
|
|
name = "build-remote-input-2";
|
2022-02-20 14:56:22 +00:00
|
|
|
buildCommand = "echo hi; echo BAR > $out";
|
2020-08-12 16:32:36 +00:00
|
|
|
requiredSystemFeatures = ["bar"];
|
2009-03-17 17:11:55 +00:00
|
|
|
};
|
|
|
|
|
2020-08-12 13:24:39 +00:00
|
|
|
input3 = mkDerivation {
|
|
|
|
shell = busybox;
|
|
|
|
name = "build-remote-input-3";
|
|
|
|
buildCommand = ''
|
2022-03-04 15:58:27 +00:00
|
|
|
echo hi-input3
|
2020-08-12 13:24:39 +00:00
|
|
|
read x < ${input2}
|
|
|
|
echo $x BAZ > $out
|
|
|
|
'';
|
|
|
|
requiredSystemFeatures = ["baz"];
|
|
|
|
};
|
|
|
|
|
2009-03-17 17:11:55 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
mkDerivation {
|
2020-06-25 16:26:34 +00:00
|
|
|
shell = busybox;
|
|
|
|
name = "build-remote";
|
2022-02-20 14:56:22 +00:00
|
|
|
passthru = { inherit input1 input2 input3; };
|
2020-06-25 16:26:34 +00:00
|
|
|
buildCommand =
|
|
|
|
''
|
|
|
|
read x < ${input1}
|
2020-08-12 13:24:39 +00:00
|
|
|
read y < ${input3}
|
2020-08-12 16:32:36 +00:00
|
|
|
echo "$x $y" > $out
|
2020-06-25 16:26:34 +00:00
|
|
|
'';
|
2009-03-17 17:11:55 +00:00
|
|
|
}
|