Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
302 lines (278 loc) · 9.15 KB
/
Copy pathflake.nix
File metadata and controls
302 lines (278 loc) · 9.15 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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
{
description = "user3301's dotfiles for native NixOS and NixOS WSL2";
inputs = {
# Nixpkgs - stable release
nixpkgs.url = "github:nixos/nixpkgs/nixos-26.05";
claude-code-nix = {
url = "github:sadjow/claude-code-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Herdr - terminal agent multiplexer (https://herdr.dev)
herdr = {
url = "github:ogulcancelik/herdr";
inputs.nixpkgs.follows = "nixpkgs";
};
# Home Manager - for user-level configuration
home-manager = {
url = "github:nix-community/home-manager/release-26.05";
inputs.nixpkgs.follows = "nixpkgs";
};
# NixOS WSL - for WSL2 support
nixos-wsl = {
url = "github:nix-community/NixOS-WSL";
inputs.nixpkgs.follows = "nixpkgs";
};
# Pinned nixpkgs providing azure-cli 2.77.0 (nixpkgs went 2.75.0 -> 2.77.0
# directly; 2.76.0 was never packaged). Deliberately not following the
# main nixpkgs input, since the whole point is to freeze this one package.
nixpkgs-azure-cli.url = "github:nixos/nixpkgs/286615174c6bd765907ef9975d0acdc799c7bf7e";
};
outputs =
{
self,
nixpkgs,
home-manager,
nixos-wsl,
...
}@inputs:
let
# The NixOS user, passed to the system modules as the `user` argument
user = "user3301";
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
claudeOverlay = inputs.claude-code-nix.overlays.default;
# nixpkgs lags upstream copilot-cli releases; bump to the latest GitHub
# release, using the platform tarballs since the universal one no longer
# runs unpatched (see nixpkgs#534884 — drop once it lands)
copilotOverlay = final: prev: {
github-copilot-cli = prev.github-copilot-cli.overrideAttrs (
finalAttrs: oldAttrs:
let
platform =
{
"x86_64-linux" = "linux-x64";
"aarch64-linux" = "linux-arm64";
}
.${prev.stdenv.hostPlatform.system};
in
{
version = "1.0.98";
buildInputs = oldAttrs.buildInputs ++ [
final.webkitgtk_4_1
final.gtk3
final.cairo
final.gdk-pixbuf
final.libsoup_3
final.wayland
final.dbus
final.xdotool
];
src = final.fetchurl {
url = "https://github.com/github/copilot-cli/releases/download/v${finalAttrs.version}/github-copilot-${finalAttrs.version}-${platform}.tgz";
hash =
{
"x86_64-linux" = "sha256-pPX/6cooiGypsfiQFpmjpFZQJl27RzzBdXcsv8e4io8=";
"aarch64-linux" = "sha256-jAlbr0kiWueOUWMy1Qa4rQil2mD6pBu5OSXb1s4pkKc=";
}
.${prev.stdenv.hostPlatform.system};
};
}
);
};
# roslyn.nvim requires a newer server than this channel provides.
roslynOverlay =
final: _prev:
let
recipe = final.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
rev = "ca0dc65018ebc2b7669325a31e2519c524866f81";
hash = "sha256-147ZUA9Sqw17lyo+Fntiqv73Nu0c6IfVb/0ilcFcZYQ=";
};
in
{
roslyn-ls = final.callPackage "${recipe}/pkgs/by-name/ro/roslyn-ls/package.nix" { };
};
# azure-cli 2.77.0 (see nixpkgs-azure-cli input above) instead of
# whatever version the main nixpkgs channel currently carries.
azureCliOverlay = final: _prev: {
inherit (import inputs.nixpkgs-azure-cli { inherit (final.stdenv.hostPlatform) system; })
azure-cli
;
};
# Build an x86_64 NixOS host from the shared system settings, the host's
# own modules, the package overlays, and the host's Home Manager config
mkSystem =
{ modules, home }:
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = modules ++ [
./systems/common.nix
home-manager.nixosModules.home-manager
{
nixpkgs.overlays = [
claudeOverlay
copilotOverlay
roslynOverlay
azureCliOverlay
];
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.${user} = home;
extraSpecialArgs = { inherit inputs; };
};
}
];
specialArgs = { inherit inputs user; };
};
wslModules = [
nixos-wsl.nixosModules.wsl
./systems/wsl/configuration.nix
];
in
{
# NixOS Configurations
nixosConfigurations = {
# One-time installer that clones the mutable dotfiles checkout before
# Home Manager activates the same configuration as nixos-wsl.
nixos-wsl-bootstrap = mkSystem {
home = ./home/nixos-wsl.nix;
modules = wslModules ++ [
(
{ pkgs, ... }:
{
system.activationScripts.bootstrapDotfiles = {
deps = [ "users" ];
text = ''
target=/home/${user}/dotfiles
if [[ ! -e "$target" ]]; then
echo "cloning dotfiles into $target..."
${pkgs.coreutils}/bin/install -d -o ${user} -g users /home/${user}
${pkgs.util-linux}/bin/runuser -u ${user} -- \
${pkgs.git}/bin/git clone \
https://github.com/user3301/dotfiles.git "$target"
elif [[ ! -d "$target/.git" ]]; then
echo "error: $target exists but is not a Git checkout" >&2
exit 1
fi
'';
};
}
)
];
};
# NixOS WSL2 Configuration
nixos-wsl = mkSystem {
home = ./home/nixos-wsl.nix;
modules = wslModules;
};
# Native NixOS Configuration
nixos-native = mkSystem {
home = ./home/nixos-native.nix;
modules = [ ./systems/native/configuration.nix ];
};
};
packages.x86_64-linux.bootstrap-wsl =
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
in
pkgs.writeShellApplication {
name = "bootstrap-nixos-wsl";
runtimeInputs = with pkgs; [
gnugrep
];
text = builtins.readFile ./scripts/bootstrap-nixos-wsl.sh;
};
apps.x86_64-linux.bootstrap-wsl = {
type = "app";
program = "${self.packages.x86_64-linux.bootstrap-wsl}/bin/bootstrap-nixos-wsl";
};
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt);
checks = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
nix-quality =
pkgs.runCommand "nix-quality"
{
nativeBuildInputs = with pkgs; [
deadnix
findutils
nixfmt
statix
];
}
''
find ${self} -type f -name '*.nix' -print0 | xargs -0 nixfmt --check
statix check ${self}
deadnix --fail ${self}
touch "$out"
'';
lua-format =
pkgs.runCommand "lua-format"
{
nativeBuildInputs = [ pkgs.stylua ];
}
''
stylua \
--check \
--config-path ${self}/nvim/.config/nvim/stylua.toml \
${self}/nvim/.config/nvim \
${self}/wezterm/.config/wezterm
touch "$out"
'';
zsh-syntax =
pkgs.runCommand "zsh-syntax"
{
nativeBuildInputs = [ pkgs.zsh ];
}
''
zsh -n ${self}/zsh/.zshenv
zsh -n ${self}/zsh/.zshrc
touch "$out"
'';
bash-syntax =
pkgs.runCommand "bash-syntax"
{
nativeBuildInputs = [ pkgs.bash ];
}
''
bash -n ${self}/bash/.bash_profile
bash -n ${self}/bash/.bashrc
touch "$out"
'';
}
);
# Development shell (optional but useful)
devShells = forAllSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
default = pkgs.mkShell {
packages = with pkgs; [
deadnix
git
nil # Nix LSP
nixfmt
statix
stylua
vim
zsh
];
shellHook = ''
echo "Dotfiles development environment"
echo "Use 'nixos-rebuild' to apply NixOS and Home Manager configurations"
'';
};
}
);
};
}