-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
197 lines (188 loc) · 5.34 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
{
description = "My NixOS configuration";
# Sources
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
plasma-manager = {
url = "github:nix-community/plasma-manager";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
};
nur = {
url = "github:nix-community/NUR";
};
daeuniverse = {
url = "github:daeuniverse/flake.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-flatpak.url = "github:gmodena/nix-flatpak";
};
outputs =
inputs@{
nixpkgs,
home-manager,
plasma-manager,
nur,
daeuniverse,
nix-flatpak,
...
}:
let
# List of hosts
hosts = rec {
desktop-template = {
system = "x86_64-linux";
profile = "desktop";
env = [
"plasma"
"steam"
"obs"
];
users = [ "ccicnce113424" ];
};
ccic-desktop = desktop-template;
test-vmware = desktop-template;
};
# Configuration of Nix and Flake
nixConfigModules = [
./nix-config.nix
];
# Configuration of system
systemModules = system: [
./system/${system}
];
# Configuration of profile
profileModules = system: profile: [
./profile/${system}/${profile}
];
envModules = env: map (env: ./env/${env}) env;
# Configuration of host
hostModules = hostname: [
(
{ ... }:
{
networking.hostName = hostname;
}
)
./hosts/${hostname}
];
# Configuration of users
userModules =
users:
(
[
(
{ ... }:
{
users.users = builtins.listToAttrs (
map (username: {
name = username;
value = {
home = "/home/${username}";
};
}) users
);
}
)
]
++ (map (username: ./users/${username}) users)
);
# Configuration of Home Manager
homeManagerModules = specialArgs: [
home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = specialArgs;
backupFileExtension = "backup";
sharedModules =
[
nur.hmModules.nur
nix-flatpak.homeManagerModules.nix-flatpak
]
++ nixpkgs.lib.optional (builtins.elem "plasma" specialArgs.host.env) plasma-manager.homeManagerModules.plasma-manager;
users = builtins.listToAttrs (
map (username: {
name = username;
value = import ./home/${username};
}) specialArgs.host.users
);
};
}
];
in
{
nixosConfigurations =
builtins.listToAttrs (
map (
hostname:
let
specialArgs = {
inherit inputs;
host = hosts.${hostname};
};
in
{
name = hostname;
value = nixpkgs.lib.nixosSystem {
inherit specialArgs;
system = hosts.${hostname}.system;
modules =
[
nur.nixosModules.nur
daeuniverse.nixosModules.daed
nix-flatpak.nixosModules.nix-flatpak
]
++ nixConfigModules
++ (systemModules (hosts.${hostname}.system))
++ (profileModules (hosts.${hostname}.system) (hosts.${hostname}.profile))
++ (envModules (hosts.${hostname}.env))
++ (hostModules hostname)
++ (userModules (hosts.${hostname}.users))
++ (homeManagerModules specialArgs);
};
}
) (builtins.attrNames hosts)
)
// {
livecd = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
(
{ pkgs, modulesPath, ... }:
{
isoImage.squashfsCompression = "zstd";
imports = [
(modulesPath + "/installer/cd-dvd/installation-cd-minimal-new-kernel-no-zfs.nix")
./nix-config.nix
daeuniverse.nixosModules.daed
];
services.daed = {
enable = true;
openFirewall = {
enable = true;
port = 12345;
};
configDir = "/etc/daed";
listen = "127.0.0.1:2023";
};
environment.systemPackages = [
pkgs.git
pkgs.elinks
];
services.openssh = {
enable = true;
settings.PermitRootLogin = "yes";
};
}
)
];
};
};
};
}