-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
204 lines (190 loc) · 6.73 KB
/
Copy pathflake.nix
File metadata and controls
204 lines (190 loc) · 6.73 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
192
193
194
195
196
197
198
199
200
201
202
203
204
{
description = "NixOS configuration for kaizen";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
# DEPRECATED: Migrated to nix-wrappers
# home-manager = {
# url = "github:nix-community/home-manager";
# inputs.nixpkgs.follows = "nixpkgs";
# };
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
base16.url = "github:SenchoPens/base16.nix";
tt-schemes = {
url = "github:tinted-theming/schemes";
flake = false;
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-topology = {
url = "github:oddlama/nix-topology";
inputs.nixpkgs.follows = "nixpkgs";
};
wrappers = {
type = "git";
url = "https://codeberg.org/midischwarz12/nix-wrappers";
};
};
outputs =
{
self,
nixpkgs,
nixpkgs-unstable,
# home-manager, # DEPRECATED: Migrated to wrappers
sops-nix,
treefmt-nix,
git-hooks,
nix-topology,
...
}@inputs:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [ nix-topology.overlays.default ];
};
pkgs-unstable = import nixpkgs-unstable {
inherit system;
config.allowUnfree = true;
};
# Eval the treefmt modules from ./treefmt.nix
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
in
{
nixosConfigurations = {
ikigai = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
./hosts/ikigai.nix
sops-nix.nixosModules.sops # SOPS-encrypted secrets management
nix-topology.nixosModules.default # Infrastructure topology visualization
# Configure nixpkgs to allow unfree packages (required for 1password)
(
{ ... }:
{
nixpkgs.config.allowUnfree = true;
}
)
];
specialArgs = { inherit inputs pkgs-unstable self; };
};
test-vm = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
./hosts/test-vm.nix
sops-nix.nixosModules.sops
nix-topology.nixosModules.default # Infrastructure topology visualization
# Configure nixpkgs to allow unfree packages (required for 1password)
(
{ ... }:
{
nixpkgs.config.allowUnfree = true;
}
)
];
specialArgs = { inherit inputs pkgs-unstable self; };
};
};
# DEPRECATED: Home Manager configuration removed - migrated to wrappers
# homeConfigurations = {
# kaizen = home-manager.lib.homeManagerConfiguration {
# inherit pkgs;
# modules = [
# ./home/kaizen/default.nix
# ];
# extraSpecialArgs = { inherit inputs; };
# };
# };
# Pre-commit hooks check (runs in sandbox with nix flake check)
# Reference: https://github.com/cachix/git-hooks.nix
# Uses treefmt.toml configuration for comprehensive formatting
checks.${system}.pre-commit-check = git-hooks.lib.${system}.run {
src = ./.;
hooks = {
# Comprehensive formatter (uses treefmt.toml)
# Formats: Nix (nixfmt, deadnix, statix), shell (shfmt), Python (ruff),
# YAML (yamlfmt), JS/TS/JSON/MD (prettier), GitHub Actions (actionlint)
treefmt.enable = true;
treefmt.settings = {
fail-on-change = true; # Fail if files need formatting
no-cache = true; # Ignore evaluation cache
};
};
};
# Formatter output for comprehensive formatting (all file types)
# Uses treefmt-nix to format: Nix, shell, Python, YAML, JS/TS/JSON/MD, etc.
# Reference: https://github.com/numtide/treefmt-nix
# Usage: nix fmt (formats all file types via treefmt)
formatter.${system} = treefmtEval.config.build.wrapper;
# treefmt app (alternative way to run treefmt)
# Reference: https://github.com/numtide/treefmt-nix
# Usage: nix run .#treefmt
apps.${system}.treefmt = {
type = "app";
program = "${treefmtEval.config.build.wrapper}/bin/treefmt";
};
# Infrastructure topology visualization
# Reference: https://github.com/oddlama/nix-topology
# Usage: nix build .#topology.${system}.config.output
# Result: SVG diagrams in result/ directory
topology.${system} = import nix-topology {
inherit pkgs;
modules = [
./topology.nix
{ nixosConfigurations = self.nixosConfigurations; }
];
};
# Development shell (minimal - use devshells for project-specific tools)
devShells.${system}.default =
let
preCommitCheck = self.checks.${system}.pre-commit-check;
in
pkgs.mkShell {
buildInputs =
with pkgs;
[
nh # NixOS helper
nix-tree # Visualize dependency tree
nixfmt # Official Nix formatter (for editor integration)
treefmt # Formatter multiplexer (runs all formatters in parallel)
nixd # Nix language server
deadnix # Find unused Nix code
statix # Lint and suggest improvements
]
++ preCommitCheck.enabledPackages;
shellHook = ''
${preCommitCheck.shellHook}
echo "NixOS Development Shell"
echo "======================"
echo "Available commands:"
echo " nh os switch - Switch to new configuration"
echo " nh os test - Test configuration without switching"
echo " nh clean - Clean build artifacts"
echo " nh update - Update flake inputs"
echo ""
echo "Formatting:"
echo " nix fmt - Format all files (via treefmt)"
echo " treefmt - Format all files (multiple formatters)"
echo " nix run .#treefmt - Run treefmt via flake"
echo ""
echo "Pre-commit hooks:"
echo " pre-commit run --all-files - Run all hooks"
echo " nix flake check - Run hooks in sandbox"
echo ""
echo "Topology visualization:"
echo " nix build .#topology.x86_64-linux.config.output - Generate infrastructure diagrams"
echo ""
'';
};
};
}