-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix.save
219 lines (201 loc) · 5.69 KB
/
flake.nix.save
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
{
description = "My user configuration using home-manager";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
flake-utils.url = "github:numtide/flake-utils";
nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
nix-darwin = {
url = "github:LnL7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs = {
nixpkgs.follows = "nixpkgs";
utils.follows = "flake-utils";
};
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
attic.url = "github:zhaofengli/attic";
authentik-nix.url = "github:nix-community/authentik-nix";
stylix.url = "github:danth/stylix";
roam = {
url = "github:xgroleau/roam-flake";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{
self,
nixpkgs,
nixpkgs-unstable,
nixos-hardware,
nix-darwin,
flake-utils,
home-manager,
agenix,
deploy-rs,
disko,
attic,
authentik-nix,
roam,
...
}:
let
hosts = import ./hosts;
profiles = import ./home/profiles;
hmBaseConfig = {
home = rec {
username = "xgroleau";
homeDirectory = "/home/${username}";
stateVersion = "23.11";
};
};
hmModule = import ./home;
nixosModule = _: {
imports = [
./modules
agenix.nixosModules.default
disko.nixosModules.disko
attic.nixosModules.atticd
authentik-nix.nixosModules.default
];
};
in
{
deploy = {
remoteBuild = true;
nodes = nixpkgs.lib.mapAttrs (hostName: hostConfig: {
inherit (hostConfig.deploy) hostname;
profiles.system = {
inherit (hostConfig.deploy) user sshUser;
path = deploy-rs.lib.${hostConfig.system}.activate.nixos self.nixosConfigurations.${hostName};
};
}) (nixpkgs.lib.filterAttrs (hostName: hostConfig: hostConfig ? deploy) hosts);
};
homeManagerModules.default = hmModule;
nixosModules.default = nixosModule;
overlays = import ./overlays { inherit inputs; };
darwinConfigurations."Xaviers-Laptop" = nix-darwin.lib.darwinSystem {
modules = [ ./darwin ];
specialArgs = {
inherit inputs;
};
};
# Generate a home configuration for each profiles
homeConfigurations = nixpkgs.lib.mapAttrs (
profileName: profileConfig:
home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.${flake-utils.lib.system.x86_64-linux};
modules = [
hmBaseConfig
hmModule
profileConfig
];
extraSpecialArgs = {
inherit inputs;
};
}
) profiles;
# Generate a nixos configuration for each hosts
nixosConfigurations = nixpkgs.lib.mapAttrs (
hostName: hostConfig:
nixpkgs.lib.nixosSystem {
inherit (hostConfig) system;
specialArgs = {
inherit inputs;
};
modules = [
./secrets
hostConfig.cfg
nixosModule
];
}
) hosts;
}
# Utils of each system
// (flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
apps = {
fmt =
let
app = pkgs.writeShellApplication {
name = "fmt";
runtimeInputs = with pkgs; [
nixfmt-rfc-style
statix
];
text = ''
nixfmt ./**/*.nix && \
statix fix --config ${./statix.toml}
'';
};
in
{
type = "app";
program = "${app}/bin/${app.name}";
};
deploy =
let
app = pkgs.writeShellApplication {
name = "deploy";
runtimeInputs = with pkgs; [ deploy-rs.packages.${system}.default ];
text = ''
deploy .# --remote-build "$@"
'';
};
in
{
type = "app";
program = "${app}/bin/${app.name}";
};
};
formatter = pkgs.nixfmt-rfc-style;
checks = {
fmt =
pkgs.runCommand "fmt"
{
buildInputs = with pkgs; [
nixfmt-rfc-style
statix
];
}
''
${pkgs.nixfmt-rfc-style}/bin/nixfmt --check ${./.}/**/*.nix && \
${pkgs.statix}/bin/statix check --config ${./statix.toml} && \
touch $out
'';
};
devShells.default = pkgs.mkShell {
buildInputs =
with pkgs;
[
agenix.packages.${system}.default
deploy-rs.packages.${system}.default
git
nixfmt-rfc-style
statix
home-manager.defaultPackage.${system}
]
++ (lib.optionals stdenv.isDarwin [ nix-darwin.packages.${system}.default ]);
};
}
));
}