blob: cd4b601c3d43abd6fe0bc8e86ef1166043e07d1f (
plain) (
blame)
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
|
lib: _: with lib; rec {
my = import ./my.nix lib;
dns = import ./dns.nix;
isEven =
number:
assert (builtins.isInt number) || (builtins.isFloat number);
builtins.div number 2 == 0;
isOdd = number: !isEven number;
pow =
base: exponent:
assert (builtins.isInt base) && (builtins.isInt exponent);
assert exponent > 0;
builtins.foldl' (x: _: x * base) 1 (builtins.genList (_: _) exponent);
mkTcpMem =
min: ini: max:
assert min <= ini && ini <= max;
concatMapStrings (x: toString x + " ") (
map (pow 2) [
min
ini
max
]
);
modulesIn =
dir:
pipe dir [
builtins.readDir
(mapAttrsToList (
name: type:
if type == "regular" && hasSuffix ".nix" name && name != "default.nix" then
[
{
name = removeSuffix ".nix" name;
value = dir + "/${name}";
}
]
else if type == "directory" && pathExists (dir + "/${name}/default.nix") then
[
{
inherit name;
value = dir + "/${name}";
}
]
else
[ ]
))
concatLists
listToAttrs
];
moduleFromRef = module: ref: sha256: {
disabledModules = [ module ];
imports = [
(
let
src = builtins.fetchTarball {
url =
let
cons = splitString ":" ref;
owner = head cons;
branch = last cons;
in
"https://github.com/${owner}/nixpkgs/archive/refs/heads/${branch}.tar.gz";
inherit sha256;
};
in
"${src}/nixos/modules/${module}"
)
];
};
}
|