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