aboutsummaryrefslogtreecommitdiff
path: root/nixos/tests/scope-fun.nix
blob: 9dc0cf05797e547bcfb25511a6ebd9adb83835db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{ lib, nodes }:
assert builtins.isAttrs nodes;
self:
let
  mkBuildInputs =
    propagated:
    lib.flip lib.pipe [
      builtins.attrValues
      (builtins.filter ({ runtime, ... }: (propagated && runtime) || (!propagated && !runtime)))
      (map ({ name, ... }: self.${name}))
    ];
in
builtins.mapAttrs (
  name: node:
  assert builtins.isString name;
  assert builtins.isAttrs node;
  let
    inherit (node) inputs;
  in
  self.callPackage (
    { runCommand }:
    runCommand name
      {
        buildInputs = mkBuildInputs false inputs;
        propagatedBuildInputs = mkBuildInputs true inputs;
      }
      ''
        mkdir $out 
        echo ${name} > $out/name
      ''
  ) { }
) nodes