-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
114 lines (91 loc) · 3.82 KB
/
flake.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{
description = "Nicball's package collection";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
let overlay = import ./pkgs/all-packages.nix; in
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ overlay ];
config = {
allowUnfree = true;
permittedInsecurePackages = [ "openssl-1.1.1w" ];
};
};
lib = pkgs.lib;
filter-pkgset-recursive = f: attrs:
let go = f: prefixes: attrs:
let first-level = lib.filterAttrs (k: v: k == "recurseForDerivations" || f (prefixes ++ [ k ]) v) attrs; in
lib.mapAttrs (k: v: if is-recursive-pkgs v then go f (prefixes ++ [ k ]) v else v) first-level;
in
go f [] attrs;
get-paths-recursive = ps:
let
flatten = prefix: ps:
lib.concatMapAttrs
(k: v:
if k == "recurseForDerivations" then
{}
else if is-recursive-pkgs v then
flatten "${prefix}.${k}" v
else
{ "${prefix}.${k}" = v; })
ps;
in
builtins.map (lib.removePrefix ".") (builtins.attrNames (flatten "" ps));
filter-my-pkgs = ps:
let
skeleton = overlay dummy-pkgs {};
dummy-pkgs = {
lib = { inherit (lib) recurseIntoAttrs; };
callPackage = fnOrPath: additionalArgs:
let
fn = if builtins.isPath fnOrPath then import fnOrPath else fnOrPath;
args = lib.mapAttrs (k: v: dummy-pkgs.${k} or 42) (lib.functionArgs fn) // additionalArgs;
in
fn args;
};
in
filter-pkgset-recursive (path: _: lib.hasAttrByPath path skeleton) ps;
is-broken = lib.attrByPath [ "meta" "broken" ] false;
is-good = system: p: lib.isDerivation p && !is-broken p && lib.meta.availableOn { inherit system; } p;
is-recursive-pkgs = p: builtins.isAttrs p && (p.recurseForDerivations or false);
filter-good-pkgs = system: ps: filter-pkgset-recursive (_: p: is-recursive-pkgs p || is-good system p) ps;
add-everything = system: pkgs: ps: ps // {
build-everything-unsubstitutable =
let
good-pkgs = filter-good-pkgs system ps;
nameList = lib.concatMapStringsSep " " lib.escapeShellArg (get-paths-recursive good-pkgs);
in
pkgs.writeShellApplication {
name = "build-everything-unsubstitutable";
runtimeInputs = with pkgs; [ jq nix ];
text = ''
bincache=''${1:?"Please tell me which binary cache to check"}
build=''${2:-"nix build .#"}
for name in ${nameList}; do
path=$(nix path-info --json .#"$name"^out 2>/dev/null | jq -r 'keys[]')
if nix path-info "$path" --store "$bincache" >/dev/null 2>&1; then
echo "$name already exists, skipping..."
else
echo "Building $name..."
eval "$build'$name'"
fi
done
'';
};
};
final-pkgs = system: pkgs: filter-good-pkgs system (add-everything system pkgs (filter-my-pkgs pkgs));
in {
packages = final-pkgs system pkgs;
packagesCross = builtins.mapAttrs (arch: cpkgs: final-pkgs arch cpkgs) pkgs.pkgsCross;
}
) // {
overlays.default = overlay;
homeModules.default = import ./home-modules { inherit overlay; };
nixosModules.default = import ./nixos-modules { inherit overlay; };
};
}