-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
191 lines (165 loc) · 6.3 KB
/
flake.nix
File metadata and controls
191 lines (165 loc) · 6.3 KB
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 = "BAUER GROUP Infrastructure — Parametric NixOS Templates";
inputs = {
# Stable channel for production
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
# Unstable channel for latest kernel & bleeding-edge packages
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
# Home Manager for user-level config
home-manager = {
url = "github:nix-community/home-manager/release-25.11";
inputs.nixpkgs.follows = "nixpkgs";
};
# Deployment
colmena = {
url = "github:zhaofengli/colmena";
inputs.nixpkgs.follows = "nixpkgs";
};
# Declarative disk partitioning
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
# Secret management
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Code formatting
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Pre-commit hooks
git-hooks-nix = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{
self,
nixpkgs,
nixpkgs-unstable,
home-manager,
disko,
agenix,
treefmt-nix,
git-hooks-nix,
...
}:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
# ── Overlays ────────────────────────────────────────────────────
overlays = import ./overlays { inherit nixpkgs-unstable; };
unstableOverlay = overlays.unstable;
specialArgs = { inherit inputs self; };
# ── Base modules (shared by all templates) ──────────────────────
baseModules = [
{ nixpkgs.overlays = [ unstableOverlay ]; }
# Parameter definitions
./modules/params.nix
# Home Manager
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = specialArgs;
}
# Agenix + Disko
agenix.nixosModules.default
disko.nixosModules.disko
];
# Machine-local params + hardware config (requires --impure)
machineModules =
[ /etc/nixos/params.nix ]
++ (
if builtins.pathExists /etc/nixos/hardware-configuration.nix then
[ /etc/nixos/hardware-configuration.nix ]
else
[ ]
);
# ── Home Manager wiring ─────────────────────────────────────────
# Dynamically sets home-manager.users.<name> from bauergroup.params.user
homeManagerModule =
{ config, ... }:
{
home-manager.users.${config.bauergroup.params.user.name} = import ./home/user.nix;
};
# ── Template builder ────────────────────────────────────────────
mkTemplate =
templatePath:
nixpkgs.lib.nixosSystem {
inherit system specialArgs;
modules =
baseModules
++ machineModules
++ [
templatePath
homeManagerModule
];
};
# ── Formatting ──────────────────────────────────────────────────
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
# ── Pre-commit hooks ────────────────────────────────────────────
pre-commit-check = git-hooks-nix.lib.${system}.run {
src = self;
hooks = {
nixfmt-rfc-style.enable = true;
statix.enable = true;
deadnix.enable = true;
check-merge-conflicts.enable = true;
};
};
in
{
# ── NixOS Templates ──────────────────────────────────────────────
# Deploy with: nixos-rebuild switch --flake .#<template> --impure
nixosConfigurations = {
desktop-dev = mkTemplate ./templates/desktop-dev.nix;
desktop-kiosk = mkTemplate ./templates/desktop-kiosk.nix;
server = mkTemplate ./templates/server.nix;
};
# ── Overlays ────────────────────────────────────────────────────
overlays.default = unstableOverlay;
# ── Formatter ───────────────────────────────────────────────────
formatter.${system} = treefmtEval.config.build.wrapper;
# ── Checks ──────────────────────────────────────────────────────
checks.${system} = {
formatting = treefmtEval.config.build.check self;
pre-commit = pre-commit-check;
lint =
pkgs.runCommand "lint"
{
nativeBuildInputs = with pkgs; [
deadnix
];
}
''
cd ${self}
deadnix . --exclude params.example.nix
touch $out
'';
};
# ── Dev Shell ───────────────────────────────────────────────────
devShells.${system}.default = pkgs.mkShell {
inherit (pre-commit-check) shellHook;
buildInputs = with pkgs; [
# Deployment
nixos-rebuild
inputs.colmena.packages.${system}.colmena
agenix.packages.${system}.default
git
ssh-to-age
# Code quality
statix
deadnix
treefmtEval.config.build.wrapper
];
};
};
}