-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
282 lines (252 loc) · 8.41 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
{
description = "Coturnix: My personal computer setup";
#nixConfig.allow-import-from-derivation = false; # Only allow when `patches` is used.
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default-linux";
# System Manager
system-manager.url = "github:soupglasses/system-manager-lite";
system-manager.inputs.nixpkgs.follows = "nixpkgs";
nix-system-graphics.url = "github:soupglasses/nix-system-graphics";
nix-system-graphics.inputs.nixpkgs.follows = "nixpkgs";
# Home Manager
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
# Extra packages
aagl.url = "github:ezKEa/aagl-gtk-on-nix";
nixpkgs-xr.url = "github:nix-community/nixpkgs-xr";
# Utilities
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
# Formatting
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
pre-commit-hooks.inputs.nixpkgs-stable.follows = "nixpkgs";
pre-commit-hooks.inputs.flake-compat.follows = "flake-compat";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
# Utils
devshell.url = "github:numtide/devshell";
devshell.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
nixpkgs,
systems,
system-manager,
nix-system-graphics,
home-manager,
aagl,
nixpkgs-xr,
pre-commit-hooks,
treefmt-nix,
devshell,
...
}: let
eachSystem = f:
nixpkgs.lib.genAttrs (import systems) (system:
f {
inherit system;
pkgs = import nixpkgs {
inherit system;
overlays = [self.overlays.packages system-manager.overlays.default];
};
});
in {
# -- NixOS Configurations --
# Holds the set of our NixOS configured computers.
nixosConfigurations = {
desktop = self.lib.mkSystem self {
system = "x86_64-linux";
overlays = [nixpkgs-xr.overlays.default];
patches = [
# nixos/monado: init [2024-02-27] - https://nixpk.gs/pr-tracker.html?pr=245005
(self.lib.fetchPatchFromNixpkgs {
from = "33020597a32dcbd30cde7128336e9312a8104e98";
to = "3f7e9baeebab425f44caa19de37f004724c9c0fc";
sha256 = "1rq7qbfp8fr0vj4nkzj4czqjc0s1kk7bncin3am1sas8b1j9inrc";
})
# nixos/hardware.display: init module [2024-02-12] - https://nixpk.gs/pr-tracker.html?pr=279789
(self.lib.fetchPatchFromNixpkgs {
from = "f503294ee626eba5304d99f00f7297284050450b";
to = "5632715fb0a3579cf57e04096391061a293a37f7";
sha256 = "1frn7mq6121k8arjkzjxl53fd80f3d0f07s6gfbrdxfihbz8gx7c";
})
];
unfreePackages = [
"obsidian"
"steam"
"steam-original"
"steam-run"
"spotify"
"unityhub"
];
insecurePackages = [
"electron"
];
modules = [
aagl.nixosModules.default
self.nixosModules.variant-computer
self.nixosModules.hardware-amd-gpu
self.nixosModules.mixins-gaming
self.nixosModules.mixins-smartcard
self.nixosModules.extra-substituters
./hosts/desktop
];
};
yoga = self.lib.mkSystem self {
system = "x86_64-linux";
overlays = [self.overlays.packages];
unfreePackages = [
"obsidian"
"steam"
"steam-original"
"steam-run"
"spotify"
];
insecurePackages = [
"electron"
];
modules = [
aagl.nixosModules.default
self.nixosModules.variant-computer
self.nixosModules.kernel-patching
self.nixosModules.hardware-lenovo-yoga-7-14ARB7
self.nixosModules.mixins-gaming
self.nixosModules.mixins-smartcard
self.nixosModules.extra-substituters
./hosts/yoga
];
};
};
# -- System Configurations --
systemConfigs.default = system-manager.lib.makeSystemConfig {
modules = [
nix-system-graphics.systemModules.default
({...}: {
config = {
nixpkgs.hostPlatform = "x86_64-linux";
system-manager.allowAnyDistro = true;
system-graphics.enable = true;
system-graphics.enable32Bit = true;
};
})
];
};
# -- Home Configurations --
# Holds user-spessific dotfile configuration.
legacyPackages = eachSystem ({pkgs, ...}: {
homeConfigurations = pkgs.lib.recurseIntoAttrs {
sofie = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
./home
./home/generic-linux
rec {
home.username = "sofie";
home.homeDirectory = "/home/${home.username}";
nix.nixPath = ["nixpkgs=flake:nixpkgs"];
nix.registry.nixpkgs.to = {
type = "path";
path = nixpkgs;
};
}
];
};
};
});
# -- NixOS Modules --
# Modules create or modify configurable options included in a full nixos configuration.
nixosModules =
{
variant-generic = import ./variant/generic;
variant-computer = import ./variant/computer;
hardware-amd-gpu = import ./hardware/amd/gpu.nix;
hardware-nvidia-gpu = import ./hardware/nvidia/gpu.nix;
hardware-lenovo-yoga-7-14ARB7 = import ./hardware/lenovo-yoga-7-14ARB7;
mixins-gaming = import ./mixins/gaming.nix;
mixins-smartcard = import ./mixins/smartcard.nix;
extra-substituters = {
nix.settings.substituters = [
"https://ezkea.cachix.org"
"https://nix-community.cachix.org"
];
nix.settings.trusted-public-keys = [
"ezkea.cachix.org-1:ioBmUbJTZIKsHmWWXPe1FSFbeVe+afhfgqgTSNd34eI="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
}
// import ./modules;
# -- Packages --
# Exposes derivations as top level packages so others can use them.
packages = eachSystem ({pkgs, ...}: import ./packages {inherit pkgs;});
# -- Library --
# Holds our various functions and derivations aiding in deploying nixos.
lib = import ./lib {inherit (nixpkgs) lib;};
# -- Overlays --
# Allows modification of nixpkgs in-place, adding and modifying its functionality.
overlays =
import ./overlays
// {
packages = final: _prev: {
coturnix =
final.lib.recurseIntoAttrs
(import ./packages {inherit (final) pkgs;});
};
};
# -- Formatter --
# Abstracts all formatting tools into one command, `nix fmt <location>`.
formatter = eachSystem ({pkgs, ...}:
treefmt-nix.lib.mkWrapper pkgs {
projectRootFile = "flake.nix";
programs.alejandra.enable = true;
programs.deadnix.enable = true;
});
# -- Development Shells --
# Scoped environments including packages and shell-hooks to aid project development.
devShells = eachSystem ({
system,
pkgs,
}: {
default = devshell.legacyPackages.${system}.mkShell {
devshell = {
startup.motd = nixpkgs.lib.mkForce {text = "";};
startup.pre-commit.text = self.checks.${system}.pre-commit.shellHook;
packages = with pkgs; [
lix
nixos-rebuild
pkgs.system-manager
pkgs.home-manager
# Formatters
alejandra
deadnix
];
};
};
});
# -- Tests --
# Verify locally that our nix configurations and file formatting is correct.
checks = eachSystem ({
system,
pkgs,
}: {
pre-commit = pre-commit-hooks.lib.${system}.run {
src = ./.;
excludes = ["-deps.nix$" "-composition.nix$" ".patch$"];
hooks = {
alejandra.enable = true;
deadnix.enable = true;
editorconfig-checker.enable = true;
codespell = {
enable = true;
name = "codespell";
language = "system";
entry = "${pkgs.codespell}/bin/codespell -L ist -L anull -L statics -- ";
types = ["text"];
};
};
};
});
};
}