-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
191 lines (185 loc) · 5.97 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
{
description = "viv's nixos client base";
inputs = { # update a single input; nix flake lock --update-input unstable
nixpkgs = { url = "github:NixOS/nixpkgs/nixos-23.11"; };
unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs-unstable-tailscale.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
vscode-server.url = "github:nix-community/nixos-vscode-server";
};
outputs = inputs@{ self, nixpkgs, unstable, nixpkgs-unstable-tailscale, nixos-generators, vscode-server, ... }:
let
# configuration = { pkgs, ... }: { nix.package = pkgs.nixflakes; }; # doesn't do anything?
overlay = final: prev: {
unstable-tailscale = nixpkgs-unstable-tailscale.legacyPackages.${prev.system}.tailscale;
unstable = import unstable {
system = prev.system;
config = { # need to set config for each of these channels separately.
permittedInsecurePackages = [
];
};
};
};
# make pkgs.unstable available in configuration.nix
overlays = [ overlay ];
overlayModule =
({ config, pkgs, ... }: {
nixpkgs = {
config = {
permittedInsecurePackages = [
];
};
inherit overlays;
};
});
moduleBundles =
rec {
system-base = [
./system-base/core.nix
./system-base/ssh.nix
./system-base/user.nix
./applications/tools.nix
] ++ nixosModules;
server-base = [
./system-base/glances.nix
] ++ system-base;
system-physical = [
./system-physical/networkmanager.nix
./system-physical/systemd-boot-efi.nix
];
gaming-hardware = [
./gaming-hardware/game-controllers.nix
./gaming-hardware/game-controllers.nix
];
amd = [
./hardware-specific/amd.nix
];
plasma-desktop = [
./desktop/core.nix
./desktop/plasma.nix
./desktop/pulseaudio.nix
./applications/flatpak.nix
./applications/nix-ld.nix
./applications/gui-tools.nix
./applications/vlc.nix
];
nixosModules = [ # 'true' nixos modules that don't do anything on their own but add configuration options that machines can use.
./modules/prometheus_exporters.nix
];
obs = [ # todo: refactor to enumerate the modules so i can pick and choose individually.
./applications/obs.nix
];
dev = [
vscode-server.nixosModules.default
({ config, pkgs, ... }: {
services.vscode-server.enable = true;
})
];
};
machineFactory =
{ modules, system, hostname, inputs, ... }:
nixpkgs.lib.nixosSystem {
inherit system;
modules = nixpkgs.lib.lists.flatten [
({ config, pkgs, ... }: {
networking.hostName = hostname;
})
modules
];
specialArgs = {
inherit inputs;
channels = {
inherit unstable;
inherit nixpkgs;
};
};
};
colmenaTargetFactory =
({ modules, system, hostname, inputs, ... }:
{
networking.hostName = hostname;
imports = nixpkgs.lib.lists.flatten modules;
});
in {
inherit moduleBundles;
inherit machineFactory;
inherit colmenaTargetFactory;
src = ./.;
nixosConfigurations = {
basic = (machineFactory {
system = "x86_64-linux";
hostname = "nixos-basic";
inherit inputs;
modules = [
moduleBundles.system-base
moduleBundles.dev
];
});
gui = (machineFactory {
system = "x86_64-linux";
hostname = "nixos-gui";
inherit inputs;
modules = [
moduleBundles.system-base
moduleBundles.plasma-desktop
moduleBundles.system-physical
moduleBundles.gaming-hardware
];
});
amdgui = (machineFactory {
system = "x86_64-linux";
hostname = "nixos-amdgui";
inherit inputs;
modules = [
moduleBundles.system-base
moduleBundles.plasma-desktop
moduleBundles.system-physical
moduleBundles.amd
moduleBundles.gaming-hardware
];
});
};
packages.x86_64-linux = {
pc-efi = nixos-generators.nixosGenerate {
system = "x86_64-linux";
format = "raw-efi";
specialArgs = {
inherit inputs;
};
modules = nixpkgs.lib.lists.flatten [
moduleBundles.system-base
moduleBundles.plasma-desktop
moduleBundles.system-physical
moduleBundles.gaming-hardware
({ config, pkgs, ... }: {
networking.hostName = "viv-nixos-graphical-efi";
boot.growPartition = true; # Make the rootfs bigger if there's space
})
];
};
};
devShells = let
devShellSupportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
devShellForEachSupportedSystem = f: nixpkgs.lib.genAttrs devShellSupportedSystems (system: f {
pkgs = import nixpkgs { inherit system; inherit overlays; };
inherit system;
});
in devShellForEachSupportedSystem ({ pkgs, system }: {
default = pkgs.mkShell {
packages = let
build-gui = pkgs.writeShellScriptBin "build-gui" ''
nix build .#nixosConfigurations.gui.config.system.build.vm
./result/bin/run-nixos-gui-vm
'';
in [
pkgs.nil
pkgs.nixfmt
build-gui
];
};
});
};
}