-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
245 lines (218 loc) · 8.35 KB
/
flake.nix
File metadata and controls
245 lines (218 loc) · 8.35 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-25.11";
nixpkgs-ckb-next-qt6.url = "github:4JX/nixpkgs/ckb-next-qt6";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
nix-darwin.url = "github:nix-darwin/nix-darwin";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
nix-homebrew.url = "github:zhaofengli/nix-homebrew";
sops-nix.url = "github:Mic92/sops-nix";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
emacs-overlay.url = "github:nix-community/emacs-overlay";
emacs-overlay.inputs.nixpkgs.follows = "nixpkgs";
doom-emacs.url = "github:hlissner/doom-emacs";
doom-emacs.flake = false;
nixos-nvidia-vgpu.url = "github:danielfullmer/nixos-nvidia-vgpu";
hyprland.url = "github:hyprwm/Hyprland/v0.52.1";
hyprland.inputs.nixpkgs.follows = "nixpkgs";
vscode-server.url = "github:nix-community/nixos-vscode-server";
vscode-server.inputs.nixpkgs.follows = "nixpkgs";
lanzaboote.url = "github:nix-community/lanzaboote/v0.4.3";
lanzaboote.inputs.nixpkgs.follows = "nixpkgs";
kubectl-aliases.url = "github:ahmetb/kubectl-aliases";
kubectl-aliases.flake = false;
determinate.url = "https://flakehub.com/f/DeterminateSystems/determinate/3";
determinate.inputs.nixpkgs.follows = "nixpkgs";
mac-app-util.url = "github:hraban/mac-app-util";
mac-app-util.inputs.nixpkgs.follows = "nixpkgs";
bash-env-json.url = "github:tesujimath/bash-env-json/main";
bash-env-json.inputs.nixpkgs.follows = "nixpkgs";
bash-env-nushell.url = "github:tesujimath/bash-env-nushell/main";
bash-env-nushell.inputs.nixpkgs.follows = "nixpkgs";
bash-env-nushell.inputs.bash-env-json.follows = "bash-env-json";
opencode.url = "github:anomalyco/opencode";
# opencode.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{
self,
nix-darwin,
nix-homebrew,
nixpkgs,
nixpkgs-stable,
sops-nix,
home-manager,
nixos-nvidia-vgpu,
hyprland,
vscode-server,
lanzaboote,
determinate,
mac-app-util,
...
}:
let
inherit (nixpkgs) lib;
platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllPlatforms = f: lib.genAttrs platforms (platform: f platform);
# inlined LOL
nixosSystem' = args:
import "${nixpkgs}/nixos/lib/eval-config.nix" (args // {
modules = args.modules ++ [ {
system.nixos.versionSuffix = ".${lib.substring 0 8 (nixpkgs.lastModifiedDate or nixpkgs.lastModified or "19700101")}.${nixpkgs.shortRev or "dirty"}";
system.nixos.revision = lib.mkIf (nixpkgs ? rev) nixpkgs.rev;
} ];
});
patchedNixpkgs = forAllPlatforms (platform: let
originalNixpkgs = (import nixpkgs { system = platform; });
in (originalNixpkgs.applyPatches {
name = "patched-nixpkgs";
src = nixpkgs;
patches = [
# (originalNixpkgs.fetchpatch { # https://github.com/NixOS/nixpkgs/pull/446679
# url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/446679.patch";
# sha256 = "sha256-fxG7fWyn4T1AvXPvOUgDaM7QxDF36epfUjcTaBXZ48s=";
# })
];
}));
nixpkgsFor = forAllPlatforms (platform:
import patchedNixpkgs.${platform} {
system = platform;
config.allowUnfree = true;
overlays = lib.flatten [
(lib.optional (platform == "x86_64-linux")
(self: super: {
# Use packages from stable because they are broken on unstable
# inherit (nixpkgs-stable.legacyPackages.${platform}) azure-cli;
inherit (inputs.nixpkgs-ckb-next-qt6.legacyPackages.${platform}) ckb-next;
cosmic-comp = super.cosmic-comp.overrideAttrs (old: {
patches = (old.patches or []) ++ [
./cosmic-fix.patch
];
});
# azure-cli = super.azure-cli.overrideAttrs (old: {
# patches = (old.patches or []) ++ [
# (self.fetchpatch { # https://github.com/NixOS/nixpkgs/pull/436682
# url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/436682.patch";
# sha256 = "sha256-RHV36R5Dpxw5qUtGgy98xvHxs4u9Tr110FImYpYoNd0=";
# })
# ];
# });
# python39Packages = super.python39Packages // { inherit (nixpkgs-stable.legacyPackages.${platform}.python39Packages) h2; };
}))
inputs.emacs-overlay.overlay
# Apple Silicon backport overlay:
# In other words, x86 packages to install instead of
# arm packages which don't build yet for any reason
(lib.optional (platform == "aarch64-darwin")
# Apple Silicon backport overlay:
# In other words, x86 packages to install instead of
# arm packages which don't build yet for any reason
(self: super: {
# This is bad for libraries but okay for programs.
# See: https://github.com/LnL7/nix-darwin/issues/334#issuecomment-850857148
# For libs, I will use pkgsX86 defined below.
# inherit (nixpkgsX86darwin) kitty;
}))
];
});
nixpkgsX86darwin = import nixpkgs {
localSystem = "x86_64-darwin";
};
in {
devShells = forAllPlatforms (platform: let
pkgs = nixpkgsFor.${platform};
sops = inputs.sops-nix.packages.${platform};
NIX_CONF_DIR = (pkgs.writeTextDir "etc/nix.conf" ''
experimental-features = nix-command flakes
!include /etc/nix/nix.conf
# include /etc/nix/doesnt-exist-nix.conf
'') + "/etc";
in { default = pkgs.mkShell {
sopsPGPKeyDirs = [
"./secrets/keys/hosts"
"./secrets/keys/users"
];
nativeBuildInputs = with pkgs; [
git
nixfmt
sops.sops-import-keys-hook
];
shellHook = ''
export NIX_CONF_DIR=${NIX_CONF_DIR}
'';
}; });
nixosConfigurations = {
luna = let
system = "x86_64-linux";
in nixosSystem' {
system = system;
modules = [
home-manager.nixosModules.home-manager
sops-nix.nixosModules.sops
nixos-nvidia-vgpu.nixosModules.nvidia-vgpu
hyprland.nixosModules.default
lanzaboote.nixosModules.lanzaboote
vscode-server.nixosModules.default
./modules
./hosts/luna/configuration.nix
];
pkgs = nixpkgsFor.${system};
specialArgs = { inherit inputs; };
};
helia = let
system = "x86_64-linux";
in nixosSystem' {
system = system;
modules = [
home-manager.nixosModules.home-manager
sops-nix.nixosModules.sops
./hosts/helia/configuration.nix
];
pkgs = nixpkgsFor.${system};
specialArgs = { inherit inputs; };
};
};
darwinConfigurations = let
commonDarwinModules = [
nix-homebrew.darwinModules.nix-homebrew
home-manager.darwinModules.home-manager
determinate.darwinModules.default
mac-app-util.darwinModules.default
./modules/common-darwin
{
home-manager.sharedModules = [
mac-app-util.homeManagerModules.default
];
}
];
in {
mac-LM43LXFC70 = nix-darwin.lib.darwinSystem {
system = "aarch64-darwin";
modules = commonDarwinModules ++ [
./hosts/mac-LM43LXFC70/darwin-configuration.nix
];
pkgs = nixpkgsFor.aarch64-darwin;
specialArgs = {
# Rosetta 2 is installed, define a special pkgsX86 to install
# packages that don't build on aarch64-darwin yet as a fallback
pkgsX86 = nixpkgsX86darwin;
inputs = inputs // { darwin = nix-darwin; };
};
};
Zecora = nix-darwin.lib.darwinSystem {
system = "aarch64-darwin";
modules = commonDarwinModules ++ [
./hosts/zecora/darwin-configuration.nix
];
pkgs = nixpkgsFor.aarch64-darwin;
specialArgs = {
# Rosetta 2 is installed, define a special pkgsX86 to install
# packages that don't build on aarch64-darwin yet as a fallback
pkgsX86 = nixpkgsX86darwin;
inputs = inputs // { darwin = nix-darwin; };
};
};
};
};
}