forked from wiltaylor/dotfiles-old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
123 lines (111 loc) · 2.86 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
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
115
116
117
118
119
120
121
122
123
with builtins;
rec {
defaultSystems = [
"aarch64-linux"
"aarch64-darwin"
"i686-linux"
"x86_64-darwin"
"x86_64-linux"
];
# Taken from flake-utils
# List of all systems defined in nixpkgs
# Keep in sync with nixpkgs wit the following command:
# $ nix-instantiate --json --eval --expr "with import <nixpkgs> {}; lib.platforms.all" | jq
allSystems = [
"aarch64-linux"
"armv5tel-linux"
"armv6l-linux"
"armv7a-linux"
"armv7l-linux"
"mipsel-linux"
"i686-cygwin"
"i686-freebsd"
"i686-linux"
"i686-netbsd"
"i686-openbsd"
"x86_64-cygwin"
"x86_64-freebsd"
"x86_64-linux"
"x86_64-netbsd"
"x86_64-openbsd"
"x86_64-solaris"
"x86_64-darwin"
"i686-darwin"
"aarch64-darwin"
"armv7a-darwin"
"x86_64-windows"
"i686-windows"
"wasm64-wasi"
"wasm32-wasi"
"x86_64-redox"
"powerpc64le-linux"
"riscv32-linux"
"riscv64-linux"
"arm-none"
"armv6l-none"
"aarch64-none"
"avr-none"
"i686-none"
"x86_64-none"
"powerpc-none"
"msp430-none"
"riscv64-none"
"riscv32-none"
"vc4-none"
"js-ghcjs"
"aarch64-genode"
"x86_64-genode"
];
evalMods = {allPkgs, systems ? defaultSystems, modules, args ?{}}: withSystems systems (sys: let
pkgs = allPkgs."${sys}";
in pkgs.lib.evalModules {
inherit modules;
specialArgs = { inherit pkgs;} // args;
});
mkPkgs = {nixpkgs, systems ? defaultSystems, cfg ? {}, overlays ? []}: withSystems systems (sys:
import nixpkgs {
system = sys;
config = cfg;
overlays = overlays;
});
mkOverlays = { allPkgs, systems ? defaultSystems, overlayFunc} : withSystems systems (sys:
let pkgs = allPkgs."${sys}";
in overlayFunc sys pkgs);
withDefaultSystems = withSystems defaultSystems;
withSystems = systems: f: foldl' (cur: nxt:
let
ret = {
"${nxt}" = f nxt;
};
in cur // ret) {} systems;
mkNixOSConfig = {name, nixpkgs, allPkgs, system, modules ? [../modules], cfg ? {}, ...}: let
pkgs = allPkgs."${system}";
secrets = LoadRepoSecrets ../.secrets;
in nixpkgs.lib.nixosSystem {
inherit system;
modules = [
cfg
{
imports = modules;
nixpkgs.pkgs = pkgs;
system.stateVersion = "22.05";
networking.hostName = "${name}";
# Disable building HTML/plain text documentation
documentation.doc.enable = false;
}
];
};
LoadRepoSecrets = path: let
data = tryEval (import path);
in if data.success then data.value else {};
mkSearchablePackages = allPkgs:
let
filterBadPkgs = pkgs:
let
badList = filter (a: let res = tryEval(getAttr a pkgs);
in (res.success == false)) (attrNames pkgs);
in removeAttrs pkgs badList;
in foldl' (l: r: let
ret = {"${r}" = (filterBadPkgs allPkgs."${r}"); };
in l // ret) {} (attrNames allPkgs);
}