Skip to content

Commit 32510c3

Browse files
johnalotoskiJimbo4350
authored andcommitted
nixStyle: inherit reused lib/builtins in flake.nix
1 parent 063fe1e commit 32510c3

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

flake.nix

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@
7676
utils,
7777
...
7878
} @ input: let
79+
inherit (builtins) elem match;
7980
inherit (nixpkgs) lib;
80-
inherit (lib) head mapAttrs recursiveUpdate optionalAttrs;
81+
inherit (lib) collect getAttr genAttrs filterAttrs hasPrefix head isDerivation mapAttrs optionalAttrs optionals recursiveUpdate ;
8182
inherit (utils.lib) eachSystem flattenTree;
8283
inherit (iohkNix.lib) prefixNamesWith;
8384
removeRecurse = lib.filterAttrsRecursive (n: _: n != "recurseForDerivations");
@@ -137,20 +138,20 @@
137138
# have no git revision but for the same compilation alternative.
138139
cardano-node =
139140
let node = project.exes.cardano-node;
140-
in lib.recursiveUpdate
141+
in recursiveUpdate
141142
(set-git-rev node)
142143
{passthru = {noGitRev = node;};}
143144
;
144145
cardano-cli =
145146
let cli = cardano-cli.components.exes.cardano-cli;
146-
in lib.recursiveUpdate
147+
in recursiveUpdate
147148
(set-git-rev cli)
148149
{passthru = {noGitRev = cli;};}
149150
;
150151
} // optionalAttrs (project.exes ? tx-generator) {
151152
tx-generator =
152153
let tx-gen = project.exes.tx-generator;
153-
in lib.recursiveUpdate
154+
in recursiveUpdate
154155
(set-git-rev tx-gen)
155156
{passthru = {noGitRev = tx-gen;};}
156157
;
@@ -279,7 +280,7 @@
279280
// (prefixNamesWith "checks/" checks);
280281

281282
apps =
282-
lib.mapAttrs (n: p: {
283+
mapAttrs (n: p: {
283284
type = "app";
284285
program =
285286
p.exePath
@@ -326,11 +327,11 @@
326327
roots.project = project.roots;
327328
plan-nix.project = project.plan-nix;
328329
};
329-
profiled = lib.genAttrs ["cardano-node" "tx-generator" "locli"] (
330+
profiled = genAttrs ["cardano-node" "tx-generator" "locli"] (
330331
n:
331332
packages.${n}.passthru.profiled
332333
);
333-
asserted = lib.genAttrs ["cardano-node"] (
334+
asserted = genAttrs ["cardano-node"] (
334335
n:
335336
packages.${n}.passthru.asserted
336337
);
@@ -346,8 +347,8 @@
346347
inherit pkgs;
347348
inherit (exes.cardano-node.identifier) version;
348349
platform = "linux";
349-
exes = lib.collect lib.isDerivation (
350-
lib.filterAttrs (n: _: builtins.elem n releaseBins) projectExes
350+
exes = collect isDerivation (
351+
filterAttrs (n: _: elem n releaseBins) projectExes
351352
);
352353
};
353354
internal.roots.project = muslProject.roots;
@@ -364,8 +365,8 @@
364365
inherit pkgs;
365366
inherit (exes.cardano-node.identifier) version;
366367
platform = "win64";
367-
exes = lib.collect lib.isDerivation (
368-
lib.filterAttrs (n: _: builtins.elem n releaseBins) projectExes
368+
exes = collect isDerivation (
369+
filterAttrs (n: _: elem n releaseBins) projectExes
369370
);
370371
};
371372
internal.roots.project = windowsProject.roots;
@@ -374,18 +375,18 @@
374375
}
375376
// optionalAttrs (system == "x86_64-darwin") {
376377
native =
377-
lib.filterAttrs
378+
filterAttrs
378379
(n: _:
379380
# Only build docker images once on linux:
380-
!(lib.hasPrefix "dockerImage" n))
381+
!(hasPrefix "dockerImage" n))
381382
packages
382383
// {
383384
cardano-node-macos = import ./nix/binary-release.nix {
384385
inherit pkgs;
385386
inherit (exes.cardano-node.identifier) version;
386387
platform = "macos";
387-
exes = lib.collect lib.isDerivation (
388-
lib.filterAttrs (n: _: builtins.elem n releaseBins) (collectExes project)
388+
exes = collect isDerivation (
389+
filterAttrs (n: _: elem n releaseBins) (collectExes project)
389390
);
390391
};
391392
shells = removeAttrs devShells ["profiled"];
@@ -406,7 +407,7 @@
406407
# system-tests are build and run separately:
407408
"native\\.(.*\\.)?system-tests"
408409
]
409-
++ lib.optionals (system == "x86_64-darwin") [
410+
++ optionals (system == "x86_64-darwin") [
410411
# FIXME: make variants nonrequired for macos until CI has more capacity for macos builds
411412
"native\\.variants\\..*"
412413
"native\\.checks/cardano-testnet/cardano-testnet-test"
@@ -415,7 +416,7 @@
415416
pkgs.callPackages iohkNix.utils.ciJobsAggregates
416417
{
417418
inherit ciJobs;
418-
nonRequiredPaths = map (r: p: builtins.match r p != null) nonRequiredPaths;
419+
nonRequiredPaths = map (r: p: match r p != null) nonRequiredPaths;
419420
}
420421
// ciJobs;
421422
};
@@ -463,7 +464,7 @@
463464
inherit
464465
(pkgs.callPackages iohkNix.utils.ciJobsAggregates {
465466
ciJobs =
466-
lib.mapAttrs (_: lib.getAttr "required") flake.ciJobs
467+
mapAttrs (_: getAttr "required") flake.ciJobs
467468
// {
468469
# Ensure hydra notify:
469470
gitrev = pkgs.writeText "gitrev" pkgs.gitrev;

0 commit comments

Comments
 (0)