-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
173 lines (161 loc) · 4.56 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
{
description = "seraphim, piret + kala";
inputs = {
flake-utils.url = github:numtide/flake-utils;
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
nix-darwin = {
url = github:LnL7/nix-darwin/master;
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = github:nix-community/home-manager;
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = github:Mic92/sops-nix;
inputs.nixpkgs.follows = "nixpkgs";
};
furpoll = {
url = git+https://github.com/kivikakk/furpoll;
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
nixos-hardware.url = github:NixOS/nixos-hardware;
comenzar = {
url = git+https://github.com/kivikakk/comenzar;
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
plasma-manager = {
url = github:nix-community/plasma-manager;
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
};
jj = {
url = github:charlottia/jj/ssh-openssh;
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = inputs @ {
self,
flake-utils,
nixpkgs,
nix-darwin,
home-manager,
sops-nix,
furpoll,
nixos-hardware,
comenzar,
plasma-manager,
jj,
}: let
mkHost = hostName: system: specifiedModules: let
isDarwin = builtins.elem system nixpkgs.lib.platforms.darwin;
specifics =
{
nixos = {
nixpkgs = nixpkgs;
nixSystem = nixpkgs.lib.nixosSystem;
modules = [
home-manager.nixosModules.home-manager
sops-nix.nixosModules.sops
furpoll.nixosModules.${system}.default
comenzar.nixosModules.${system}.default
];
hm-modules = [
sops-nix.homeManagerModules.sops
plasma-manager.homeManagerModules.plasma-manager
];
};
darwin = {
nixpkgs = nixpkgs;
nixSystem = nix-darwin.lib.darwinSystem;
modules = [
home-manager.darwinModules.home-manager
comenzar.darwinModules.${system}.default
];
hm-modules = [
sops-nix.homeManagerModules.sops
];
};
}
.${
if isDarwin
then "darwin"
else "nixos"
};
in let
hostConfig = import ./hosts/${hostName}.nix {
inherit (specifics) nixpkgs;
inherit system hostName;
};
lib = specifics.nixpkgs.lib.extend (final: prev: {
# …
});
freezeRegistry = {
nix.registry = lib.mapAttrs (_: flake: {inherit flake;}) inputs;
};
hostRootModule =
{
system.configurationRevision =
if (self ? rev)
then self.rev
else throw "refuse to build: git tree is dirty";
}
// hostConfig.root;
homeManagerModules = [
({config, ...}: {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.${config.vyxos.vyxUser} = import ./home.nix;
sharedModules = specifics.hm-modules;
extraSpecialArgs = {
inherit isDarwin;
inherit (config.vyxos) isServer;
};
};
})
];
vyxos-git-base = nixpkgs.legacyPackages.${system}.git;
in
specifics.nixSystem {
inherit system;
specialArgs = {
inherit (specifics) nixpkgs;
inherit isDarwin hostName lib vyxos-git-base;
};
modules =
[
./common.nix
freezeRegistry
./modules
]
++ specifics.modules
++ [
hostRootModule
hostConfig.module
]
++ homeManagerModules
++ specifiedModules;
};
in
flake-utils.lib.eachDefaultSystem (system: {
formatter = nixpkgs.legacyPackages.${system}.alejandra;
checks.vyxnix = import ./tests/vyxnix.nix {inherit system nixpkgs;};
})
// {
nixosConfigurations = {
kala = mkHost "kala" "x86_64-linux" [];
piret = mkHost "piret" "x86_64-linux" [
nixos-hardware.nixosModules.framework-16-7040-amd
{nixpkgs.overlays = [jj.overlays.default];}
];
};
darwinConfigurations = {
seraphim = mkHost "seraphim" "aarch64-darwin" [
{nixpkgs.overlays = [jj.overlays.default];}
];
};
};
}