refactor(readTree): Move 'drvTargets' into readTree
This function is also generally useful for readTree consumers that have the concept of subtargets. Change-Id: Ic7fc03380dec6953fb288763a28e50ab3624d233
This commit is contained in:
parent
5cad3f7b81
commit
4f1249e46f
19 changed files with 34 additions and 40 deletions
|
@ -14,7 +14,7 @@ let
|
||||||
};
|
};
|
||||||
package = python3Packages.buildPythonPackage opts;
|
package = python3Packages.buildPythonPackage opts;
|
||||||
script = python3Packages.buildPythonApplication opts;
|
script = python3Packages.buildPythonApplication opts;
|
||||||
in depot.nix.utils.drvTargets {
|
in depot.nix.readTree.drvTargets {
|
||||||
inherit script;
|
inherit script;
|
||||||
python = python3.withPackages (_: [ package ]);
|
python = python3.withPackages (_: [ package ]);
|
||||||
setAlarm = pkgs.writeShellScriptBin "set-alarm" ''
|
setAlarm = pkgs.writeShellScriptBin "set-alarm" ''
|
||||||
|
|
|
@ -157,6 +157,10 @@ let
|
||||||
})
|
})
|
||||||
(node.meta.targets or []))
|
(node.meta.targets or []))
|
||||||
else [];
|
else [];
|
||||||
|
|
||||||
|
# Determine whether a given value is a derivation.
|
||||||
|
# Copied from nixpkgs/lib for cases where lib is not available yet.
|
||||||
|
isDerivation = x: isAttrs x && x ? type && x.type == "derivation";
|
||||||
in {
|
in {
|
||||||
inherit gather;
|
inherit gather;
|
||||||
|
|
||||||
|
@ -210,4 +214,17 @@ in {
|
||||||
#
|
#
|
||||||
# It is often required to create the args attribute set.
|
# It is often required to create the args attribute set.
|
||||||
fix = f: let x = f x; in x;
|
fix = f: let x = f x; in x;
|
||||||
|
|
||||||
|
# Takes an attribute set and adds a meta.targets attribute to it
|
||||||
|
# which contains all direct children of the attribute set which are
|
||||||
|
# derivations.
|
||||||
|
#
|
||||||
|
# Type: attrs -> attrs
|
||||||
|
drvTargets = attrs: attrs // {
|
||||||
|
meta = {
|
||||||
|
targets = builtins.filter
|
||||||
|
(x: isDerivation attrs."${x}")
|
||||||
|
(builtins.attrNames attrs);
|
||||||
|
} // (attrs.meta or {});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,6 @@
|
||||||
{ depot, lib, ... }:
|
{ depot, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
/* Takes an attribute set and adds a meta.targets
|
|
||||||
attribute to it which contains all direct children
|
|
||||||
of the attribute set which are derivations.
|
|
||||||
|
|
||||||
Type: attrs -> attrs
|
|
||||||
*/
|
|
||||||
drvTargets = attrs:
|
|
||||||
attrs // {
|
|
||||||
meta = {
|
|
||||||
targets = builtins.filter
|
|
||||||
(x: lib.isDerivation attrs."${x}")
|
|
||||||
(builtins.attrNames attrs);
|
|
||||||
} // (attrs.meta or {});
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Get the basename of a store path without
|
/* Get the basename of a store path without
|
||||||
the leading hash.
|
the leading hash.
|
||||||
|
|
||||||
|
@ -186,7 +170,6 @@ let
|
||||||
|
|
||||||
in {
|
in {
|
||||||
inherit
|
inherit
|
||||||
drvTargets
|
|
||||||
storePathName
|
storePathName
|
||||||
pathType
|
pathType
|
||||||
isDirectory
|
isDirectory
|
||||||
|
|
|
@ -60,7 +60,7 @@ let
|
||||||
'');
|
'');
|
||||||
|
|
||||||
|
|
||||||
in depot.nix.utils.drvTargets {
|
in depot.nix.readTree.drvTargets {
|
||||||
inherit
|
inherit
|
||||||
rustTransitiveLib
|
rustTransitiveLib
|
||||||
rustWithLib
|
rustWithLib
|
||||||
|
|
|
@ -2,15 +2,11 @@
|
||||||
{ depot, pkgs, ... }:
|
{ depot, pkgs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (depot.nix.utils)
|
|
||||||
drvTargets
|
|
||||||
;
|
|
||||||
|
|
||||||
checkZone = zone: file: pkgs.runCommandNoCC "${zone}-check" {} ''
|
checkZone = zone: file: pkgs.runCommandNoCC "${zone}-check" {} ''
|
||||||
${pkgs.bind}/bin/named-checkzone -i local ${zone} ${file} | tee $out
|
${pkgs.bind}/bin/named-checkzone -i local ${zone} ${file} | tee $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in drvTargets {
|
in depot.nix.readTree.drvTargets {
|
||||||
nixery-dev = checkZone "nixery.dev" ./nixery.dev.zone;
|
nixery-dev = checkZone "nixery.dev" ./nixery.dev.zone;
|
||||||
tvl-fyi = checkZone "tvl.fyi" ./tvl.fyi.zone;
|
tvl-fyi = checkZone "tvl.fyi" ./tvl.fyi.zone;
|
||||||
tvl-su = checkZone "tvl.su" ./tvl.su.zone;
|
tvl-su = checkZone "tvl.su" ./tvl.su.zone;
|
||||||
|
|
2
third_party/gerrit_plugins/default.nix
vendored
2
third_party/gerrit_plugins/default.nix
vendored
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (import ./builder.nix args) buildGerritBazelPlugin;
|
inherit (import ./builder.nix args) buildGerritBazelPlugin;
|
||||||
in depot.nix.utils.drvTargets {
|
in depot.nix.readTree.drvTargets {
|
||||||
# https://gerrit.googlesource.com/plugins/owners
|
# https://gerrit.googlesource.com/plugins/owners
|
||||||
owners = buildGerritBazelPlugin rec {
|
owners = buildGerritBazelPlugin rec {
|
||||||
name = "owners";
|
name = "owners";
|
||||||
|
|
2
third_party/nixery/default.nix
vendored
2
third_party/nixery/default.nix
vendored
|
@ -3,7 +3,7 @@
|
||||||
{ depot, pkgs, ... }:
|
{ depot, pkgs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (depot.nix.utils) drvTargets;
|
inherit (depot.nix.readTree) drvTargets;
|
||||||
|
|
||||||
commit = "6c4a69fa4280f0154ce257a1dfd23fb463c1ec5b";
|
commit = "6c4a69fa4280f0154ce257a1dfd23fb463c1ec5b";
|
||||||
src = pkgs.fetchFromGitHub {
|
src = pkgs.fetchFromGitHub {
|
||||||
|
|
|
@ -77,7 +77,7 @@ let
|
||||||
bins.s6-touch "$out"
|
bins.s6-touch "$out"
|
||||||
];
|
];
|
||||||
|
|
||||||
in depot.nix.utils.drvTargets {
|
in depot.nix.readTree.drvTargets {
|
||||||
|
|
||||||
check-all-our-crates =
|
check-all-our-crates =
|
||||||
depot.nix.drvSeqL
|
depot.nix.drvSeqL
|
||||||
|
|
|
@ -37,4 +37,4 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
in depot.nix.utils.drvTargets netencode
|
in depot.nix.readTree.drvTargets netencode
|
||||||
|
|
|
@ -358,7 +358,7 @@ let
|
||||||
bins.cdbget "$2"
|
bins.cdbget "$2"
|
||||||
];
|
];
|
||||||
|
|
||||||
in depot.nix.utils.drvTargets {
|
in depot.nix.readTree.drvTargets {
|
||||||
inherit
|
inherit
|
||||||
router
|
router
|
||||||
depotCgitLink
|
depotCgitLink
|
||||||
|
|
|
@ -5,7 +5,7 @@ let
|
||||||
name = "exec-helpers";
|
name = "exec-helpers";
|
||||||
} (builtins.readFile ./exec_helpers.rs);
|
} (builtins.readFile ./exec_helpers.rs);
|
||||||
|
|
||||||
in depot.nix.utils.drvTargets {
|
in depot.nix.readTree.drvTargets {
|
||||||
inherit
|
inherit
|
||||||
exec-helpers
|
exec-helpers
|
||||||
;
|
;
|
||||||
|
|
|
@ -135,7 +135,7 @@ let
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in depot.nix.utils.drvTargets {
|
in depot.nix.readTree.drvTargets {
|
||||||
inherit
|
inherit
|
||||||
netencode-rs
|
netencode-rs
|
||||||
pretty-rs
|
pretty-rs
|
||||||
|
|
|
@ -55,7 +55,7 @@ let
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in depot.nix.utils.drvTargets {
|
in depot.nix.readTree.drvTargets {
|
||||||
inherit
|
inherit
|
||||||
python-netstring
|
python-netstring
|
||||||
rust-netstring
|
rust-netstring
|
||||||
|
|
|
@ -53,7 +53,7 @@ let
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in depot.nix.utils.drvTargets {
|
in depot.nix.readTree.drvTargets {
|
||||||
inherit
|
inherit
|
||||||
python-netstring-test
|
python-netstring-test
|
||||||
rust-netstring-test
|
rust-netstring-test
|
||||||
|
|
|
@ -101,7 +101,7 @@ let
|
||||||
"nix-instantiate" "$1" "-A" "{}"
|
"nix-instantiate" "$1" "-A" "{}"
|
||||||
];
|
];
|
||||||
|
|
||||||
in depot.nix.utils.drvTargets {
|
in depot.nix.readTree.drvTargets {
|
||||||
inherit
|
inherit
|
||||||
instantiate-nixpkgs-randomly
|
instantiate-nixpkgs-randomly
|
||||||
# requires hnix, which we don’t want in tvl for now
|
# requires hnix, which we don’t want in tvl for now
|
||||||
|
|
|
@ -169,7 +169,7 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
in depot.nix.utils.drvTargets {
|
in depot.nix.readTree.drvTargets {
|
||||||
inherit
|
inherit
|
||||||
print-ast
|
print-ast
|
||||||
tree-sitter-nix
|
tree-sitter-nix
|
||||||
|
|
|
@ -41,7 +41,7 @@ let
|
||||||
assert(test_lib.test() == "test 1 2 3")
|
assert(test_lib.test() == "test 1 2 3")
|
||||||
'');
|
'');
|
||||||
|
|
||||||
in depot.nix.utils.drvTargets {
|
in depot.nix.readTree.drvTargets {
|
||||||
inherit
|
inherit
|
||||||
pythonWithLib
|
pythonWithLib
|
||||||
;
|
;
|
||||||
|
|
|
@ -2,13 +2,11 @@
|
||||||
{ depot, pkgs, ... }:
|
{ depot, pkgs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (depot.nix.utils) drvTargets;
|
|
||||||
|
|
||||||
checkZone = zone: file: pkgs.runCommandNoCC "${zone}-check" {} ''
|
checkZone = zone: file: pkgs.runCommandNoCC "${zone}-check" {} ''
|
||||||
${pkgs.bind}/bin/named-checkzone -i local ${zone} ${file} | tee $out
|
${pkgs.bind}/bin/named-checkzone -i local ${zone} ${file} | tee $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in drvTargets {
|
in depot.nix.readTree.drvTargets {
|
||||||
kontemplate-works = checkZone "kontemplate.works"./kontemplate.works.zone;
|
kontemplate-works = checkZone "kontemplate.works"./kontemplate.works.zone;
|
||||||
tazj-in = checkZone "tazj.in" ./tazj.in.zone;
|
tazj-in = checkZone "tazj.in" ./tazj.in.zone;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ let
|
||||||
</svg>
|
</svg>
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in depot.nix.utils.drvTargets(lib.fix (self: {
|
in depot.nix.readTree.drvTargets(lib.fix (self: {
|
||||||
# Expose the logo construction functions.
|
# Expose the logo construction functions.
|
||||||
inherit palette darkCss lightCss animatedCss staticCss;
|
inherit palette darkCss lightCss animatedCss staticCss;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue