-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
87 lines (85 loc) · 3 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
{
description = "tuxnix NixOS configuration generator";
inputs = {
nixpkgs.url = "file:///Please.provide.nixpkgs.as.input";
};
outputs = { nixpkgs, self, ... }@flakeInputs:
{
tuxnixSystem =
{ inputattrs
, sets ? { }
, system
, modules
, modulesPaths ? [ ]
, extraArgs ? { }
}:
let
allChannels = flakeInputs // inputattrs;
lib = nixpkgs.lib;
tlib = import ./lib.nix lib;
effectiveModulesPaths = [ ./modules ] ++ modulesPaths;
instantiationconfig = inputattrs.instantiationdata.nixosConfig or { };
in
nixpkgs.lib.nixosSystem ({
inherit system;
modules = tlib.handleSetDeps
{
inherit sets;
inputs = modules;
modulesPaths = effectiveModulesPaths;
passthrus = [
instantiationconfig
{
environment.etc = nixpkgs.lib.mapAttrs'
(n: v: { name = "tuxnix/channels/${n}"; value = { source = v; }; })
allChannels;
nix.nixPath = [ "/etc/tuxnix/channels" ];
}
{
options.tuxnix.container = {
modulesPaths = lib.mkOption {
default = effectiveModulesPaths;
description = "Extra paths to load modules from.";
type = lib.types.listOf lib.types.path;
};
sets = lib.mkOption {
default = sets;
description = "Sets defined for containers.";
type = lib.types.attrsOf (lib.types.listOf lib.types.str);
};
};
}
{
options.tuxnix.update-system = {
selfFlakeFilePath = lib.mkOption {
default = inputattrs.self + "/flake.nix";
description = "Path of the flake.nix of top level flake";
type = lib.types.path;
};
selfFlakePath = lib.mkOption {
default = "./.";
description = "Path of the top level flake";
type = lib.types.str;
};
};
}
{
config.nix.registry = tlib.mapAttrs'
(n: v: {
name = builtins.replaceStrings [ "." ] [ "-" ] "t-${n}";
value = {
to = {
type = "path";
path = v;
};
};
})
allChannels //
{ nixos.to = { type = "path"; path = nixpkgs; }; };
}
];
};
specialArgs = { inputattrs = allChannels; };
} // extraArgs);
};
}