-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
197 lines (185 loc) · 7.23 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
{
inputs = {
home-manager.url = "github:nix-community/home-manager";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:nixos/nixpkgs/24.11-pre";
nixos-wsl.url = "github:nix-community/NixOS-WSL";
nixos-wsl.inputs.nixpkgs.follows = "nixpkgs";
nix-darwin.url = "github:lnl7/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
nix-homebrew.url = "github:zhaofengli/nix-homebrew";
nix-homebrew.inputs.nixpkgs.follows = "nixpkgs";
sops-nix.url = "github:Mic92/sops-nix";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
# Fix for emacs 29/pgtk hanging on rebuild
nix-straight.url = "github:codingkoi/nix-straight.el?ref=codingkoi/apply-librephoenixs-fix";
nix-straight.flake = false;
emacs-overlay.url = "github:nix-community/emacs-overlay/master";
doom-emacs.url = "github:hlissner/doom-emacs";
doom-emacs.flake = false;
nixos-nvidia-vgpu.url = "github:danielfullmer/nixos-nvidia-vgpu";
devenv.url = "github:cachix/devenv/latest";
nixd.url = "github:nix-community/nixd";
hyprland.url = "github:hyprwm/Hyprland/v0.40.0";
vscode-server.url = "github:nix-community/nixos-vscode-server";
};
outputs = inputs@{ self, nix-darwin, nix-homebrew, nixpkgs, nixpkgs-stable, nixos-wsl, sops-nix, home-manager, nixos-nvidia-vgpu, devenv, nixd, hyprland, vscode-server, ... }: 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/362117
url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/362117.patch";
sha256 = "sha256-s1TBY9kkmlnInnvd2WXrjTNS9vKGs0Xc1Uiv6oEN54E=";
})
];
});
nixpkgsFor = forAllPlatforms (platform: let
nixpkgsToImport =
if (builtins.elem platform [ "x86_64-darwin" "aarch64-darwin" ])
then lib.trace "using original nixpkgs" nixpkgs
else lib.trace "building patched nixpkgs" patchedNixpkgs.${platform};
in (import nixpkgsToImport {
system = platform;
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;
# python39Packages = super.python39Packages // { inherit (nixpkgs-stable.legacyPackages.${platform}.python39Packages) h2; };
}))
inputs.emacs-overlay.overlay
inputs.nixd.overlays.default
(self: super: {
inherit (devenv.packages.${platform}) devenv;
})
# 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;
}))
];
config.allowUnfree = true;
}));
nixpkgsX86darwin = import nixpkgs {
localSystem = "x86_64-darwin";
};
in {
devShell = 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 pkgs.mkShell {
sopsPGPKeyDirs = [
"./secrets/keys/hosts"
"./secrets/keys/users"
];
nativeBuildInputs = with pkgs; [
git
nixfmt-rfc-style
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
./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; };
};
WL-DN0HG14 = let
system = "x86_64-linux";
in nixosSystem' {
system = system;
modules = [
home-manager.nixosModules.home-manager
sops-nix.nixosModules.sops
nixos-wsl.nixosModules.wsl
vscode-server.nixosModules.default
./hosts/WL-DN0HG14/configuration.nix
];
pkgs = nixpkgsFor.${system};
specialArgs = { inherit inputs; };
};
};
darwinConfigurations = {
NightmareMoon = inputs.nix-darwin.lib.darwinSystem {
system = "x86_64-darwin";
modules = [
home-manager.darwinModules.home-manager
./hosts/nightmaremoon/darwin-configuration.nix
];
specialArgs = {
pkgs = nixpkgsFor.x86_64-darwin;
inputs = inputs // { darwin = inputs.nix-darwin; };
};
};
Zecora = inputs.nix-darwin.lib.darwinSystem {
system = "aarch64-darwin";
modules = [
nix-homebrew.darwinModules.nix-homebrew
home-manager.darwinModules.home-manager
./hosts/zecora/darwin-configuration.nix
];
specialArgs = {
# Was having trouble getting nix to serve me arm64 packages
# so we are being explicit here :)
pkgs = nixpkgsFor.aarch64-darwin;
# 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 = inputs.nix-darwin; };
};
};
};
};
}