-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
180 lines (157 loc) · 5.08 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
{
inputs = {
# Base {{{
flake-parts.url = "github:hercules-ci/flake-parts";
home-manager = {
url = "github:nix-community/home-manager/release-24.11";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
wrapper-manager = {
url = "github:viperML/wrapper-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
# }}}
# Discord {{{
boris = { # Bot
url = "github:skettisouls/boris";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
midnight-discord = {
type = "git";
url = "https://github.com/refact0r/midnight-discord";
flake = false;
};
nixcord = {
url = "github:skettisouls/nixcord";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
# }}}
# Hyprland {{{
hyprland = {
type = "git";
url = "https://github.com/hyprwm/hyprland";
submodules = true;
};
hyprpicker = {
url = "github:hyprwm/hyprpicker";
inputs.nixpkgs.follows = "hyprland";
};
# }}}
# Dev {{{
bin = {
url = "github:skettisouls/bin";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
neovim = {
url = "github:skettisouls/neovim";
inputs = {
nixpkgs.follows = "nixpkgs-unstable";
flake-parts.follows = "flake-parts";
};
};
# }}}
# Server {{{
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-mc = {
url = "github:skettisouls/nix-mc";
inputs.nixpkgs.follows = "nixpkgs";
};
# }}}
# Wireguard {{{
asluni.url = "github:the-computer-club/automous-zones";
lynx.url = "github:the-computer-club/lynx";
# }}}
};
outputs = inputs @ { self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; }
({ config, options, flake-parts-lib, ... }:
let
inherit (nixpkgs) lib;
inherit (lib)
genAttrs
mapAttrs
nixosSystem
;
flakeModules = {
hardware = import ./src/hardware;
home-manager = import ./src/home-manager;
libs = import ./src/libs;
machines = import ./src/machines;
nixos = import ./src/nixos;
overlays = import ./src/overlays;
packages = import ./src/packages;
river = import ./src/river;
roles = import ./src/roles;
services = import ./src/services;
users = import ./src/users;
wireguard = import ./src/wireguard;
};
flakeRoot = ./.;
specialArgs = { inherit inputs self flakeRoot; };
in
{
imports = (builtins.attrValues flakeModules) ++ [
inputs.lynx.flakeModules.builtins
inputs.lynx.flakeModules.flake-guard
inputs.asluni.flakeModules.asluni
];
config = {
systems = [
"x86_64-linux"
];
flake = let
hostList = builtins.attrNames config.flake.machines;
in {
# Debug
_config = config;
_options = options;
inherit flakeModules flakeRoot;
deploy.nodes = {
fluorine = {
hostname = "192.168.1.17";
profiles.system = {
user = "root";
sshUser = "root";
sshOpts = [ "-T" ];
path = inputs.deploy-rs.lib.x86_64-linux.activate.nixos config.flake.nixosConfigurations.fluorine;
};
};
};
nixosConfigurations = genAttrs hostList (host: let
enabledUsers = lib.filterAttrs (_: v: lib.elem host v.machines) config.flake.users;
checkForHM = lib.filterAttrs (_: v: v.home-manager.enable) enabledUsers;
hm-exists = if checkForHM != {} then true else false;
in nixosSystem {
specialArgs = specialArgs;
modules = with config.flake; [
./src/global.nix
machines.${host}
nixosModules.default
] ++ lib.optionals hm-exists [
nixosModules.home-manager
];
});
# FIXME: broken
homeConfigurations = mapAttrs (user: hostList:
genAttrs hostList (host:
inputs.home-manager.lib.homeManagerConfiguration {
# TODO: Support other arch
pkgs = nixpkgs.legacyPackages.x86_64-linux;
extraSpecialArgs = specialArgs;
modules = [
config.flake.nixosModules.overlays
# Use the home-manager config from nixos.
config.flake.nixosConfigurations.${host}.config.home-manager.users.${user}
];
}
)
) config.homes;
};
};
});
}