-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
175 lines (158 loc) · 5.38 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
{
inputs = {
# NixPkgs stable and unstable branches
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.05";
nixpkgs2311.url = "github:NixOS/nixpkgs/nixos-23.11";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
atro-nvim = {
url = "github:atropos112/nvim";
flake = false;
};
# Hyprland packages
# Do not override the nixpkgs input in them as it will be built with different nxipkgs than it was tested with and
# it will bust the cache on the hyprland cachix server.
hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1";
stylix.url = "github:danth/stylix";
impermanence.url = "github:nix-community/impermanence";
atuin.url = "github:atuinsh/atuin";
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
attic = {
url = "github:zhaofengli/attic";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
nix-topology = {
url = "github:oddlama/nix-topology";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
flake-utils.url = "github:numtide/flake-utils";
nix-index-database = {
url = "github:nix-community/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
eza = {
url = "github:eza-community/eza";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
waybar = {
url = "github:Alexays/Waybar";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
};
outputs = {self, ...} @ inputs: let
config = {
allowUnfree = true;
allowBroken = false;
};
mkHost = hostName: system: (
(_:
inputs.nixpkgs-unstable.lib.nixosSystem {
inherit system;
specialArgs = {
inherit inputs self;
inherit (inputs) stylix;
pkgs = import inputs.nixpkgs-unstable {
inherit system config;
};
pkgs-unstable = import inputs.nixpkgs-unstable {
inherit system config;
};
pkgs-stable = import inputs.nixpkgs-stable {
inherit system config;
};
pkgs2311 = import inputs.nixpkgs2311 {
inherit system config;
};
};
modules = [
#1. Home-manager
inputs.home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
};
}
#2. Loading device specific configuration
./devices/${hostName}
#3. Topology
inputs.nix-topology.nixosModules.default
];
}) {}
);
# Little hack to get colmena to work with nixos-rebuild switch interoperably.
conf = self.nixosConfigurations;
sdImages = {
sdImage-opi1 = self.nixosConfigurations.opi1.config.system.build.sdImage;
sdImage-opi2 = self.nixosConfigurations.opi2.config.system.build.sdImage;
sdImage-opi3 = self.nixosConfigurations.opi3.config.system.build.sdImage;
sdImage-opi4 = self.nixosConfigurations.opi4.config.system.build.sdImage;
sdImage-opi021 = self.nixosConfigurations.opi021.config.system.build.sdImage;
};
in
{
nixosConfigurations = {
surface = mkHost "surface" "x86_64-linux";
giant = mkHost "giant" "x86_64-linux";
smol = mkHost "smol" "x86_64-linux";
a21 = mkHost "a21" "x86_64-linux";
rzr = mkHost "rzr" "x86_64-linux";
opi1 = mkHost "opi1" "aarch64-linux";
opi2 = mkHost "opi2" "aarch64-linux";
opi3 = mkHost "opi3" "aarch64-linux";
opi4 = mkHost "opi4" "aarch64-linux";
opi021 = mkHost "opi021" "aarch64-linux";
};
packages = {
x86_64-linux = sdImages;
aarch64-linux = sdImages;
};
colmena =
{
meta = {
description = "my personal machines";
nixpkgs = import inputs.nixpkgs-unstable {system = "x86_64-linux";}; # Gets overwritten by the host-specific nixpkgs.
nodeSpecialArgs = builtins.mapAttrs (_name: value: value._module.specialArgs) conf;
};
}
// builtins.mapAttrs (name: value: {
deployment = {
allowLocalDeployment = true;
targetUser = "root";
buildOnTarget = true;
targetHost = name;
};
# Change arch to aarch64 if the system is aarch64-linux
nixpkgs.system =
if (value.config.nixpkgs.system == "aarch64-linux")
then "aarch64-linux"
else "x86_64-linux";
imports = value._module.args.modules;
})
conf;
}
// inputs.flake-utils.lib.eachDefaultSystem (system: {
topology = import inputs.nix-topology {
pkgs = import inputs.nixpkgs-unstable {
inherit system;
overlays = [inputs.nix-topology.overlays.default];
};
modules = [
./lib/topology/networks.nix
./lib/topology/services.nix
{inherit (self) nixosConfigurations;}
];
};
});
}