-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
38 lines (36 loc) · 1.39 KB
/
default.nix
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
33
34
35
36
37
38
{ pkgs, lib, ... }: rec {
# gets drv and all outputs for derivation
aggregateDrvAndResults = { name, drv ? true, output ? true }: list: pkgs.releaseTools.aggregate {
inherit name;
constituents = lib.concatMap (d:
(if drv then [ d.drvPath ] else []) ++
(if output then (map (o: d.${o}) d.outputs) else [])
) list;
};
# gets all: packages.*.*, nixosConfigurations.*.config.system.build.toplevel
extractFromFlake = { flake, limitSystem ? null, gatherExtraFnc ? null }:
let
# TODO: generify getting system so we can re-use for devShell, apps, etc
# TODO: add prebuildExtra or similar key to expose other things for build
pkgs = if flake ? "packages" then
(let
systems =
if limitSystem != null then (if flake.packages ? limitSystem then [ limitSystem ] else [])
else builtins.attrNames flake.packages;
in
lib.concatMap (system: builtins.attrValues flake.packages.${system}) systems)
else [];
configs = if flake ? "nixosConfigurations" then
map (nixos: nixos.config.system.build.toplevel) (builtins.attrValues flake.nixosConfigurations)
else [];
in
pkgs ++ configs;
prebuildFlake = { flake, limitSystem ? null, build ? true }: let
extracted = extractFromFlake { inherit flake limitSystem; };
in
aggregateDrvAndResults {
name = "pre";
drv = true;
output = true;
} extracted;
}