-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
282 lines (260 loc) · 9.11 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
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
{
description = "Dotfiles configuration";
nixConfig = {
experimental-features = [ "nix-command" "flakes" ];
extra-substituters = [
"https://nix-community.cachix.org/"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
emacs-overlay.url = "github:nix-community/emacs-overlay";
darwin.url = "github:LnL7/nix-darwin";
nixgl = {
url = "github:nix-community/nixGL";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-homebrew = {
url = "github:zhaofengli-wip/nix-homebrew";
inputs.nixpkgs.follows = "nixpkgs";
};
homebrew-core = {
url = "github:Homebrew/homebrew-core";
flake = false;
};
homebrew-cask = {
url = "github:Homebrew/homebrew-cask";
flake = false;
};
};
outputs = { self, nixpkgs, darwin, nix-homebrew, homebrew-core, homebrew-cask, emacs-overlay, nixgl, rust-overlay, ... }@inputs:
let
system = builtins.currentSystem;
user = builtins.getEnv "USER";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
config.input-fonts.acceptLicense = true;
overlays = [ emacs-overlay.overlay nixgl.overlay rust-overlay.overlays.default ];
};
isDarwin = pkgs.stdenv.hostPlatform.isDarwin;
isLinux = pkgs.stdenv.hostPlatform.isLinux;
hostname = builtins.getEnv "HOSTNAME";
# Kitty on linux requires nixGL
wrappedKitty = pkgs.writeShellScriptBin "kitty" ''
${pkgs.nixgl.auto.nixGLDefault}/bin/nixGL ${pkgs.kitty}/bin/kitty "$@"
'';
# Common packages for all platforms
commonPackages = with pkgs; [
# Development tools
nixVersions.latest
tectonic pandoc ghostscript
imagemagick ffmpeg yt-dlp
rust-bin.nightly.latest.minimal
rust-analyzer clippy rustfmt
go gopls basedpyright janet
shellcheck tree-sitter zig zls
lua-language-server
# Ref: https://mplanchard.com/posts/installing-a-specific-version-of-a-package-with-nix.html
ruby rubyPackages.pry colorls ruby-lsp # <- LSP not working
rubyPackages.reline rubyPackages.prism # <- FIXME lsp needs 0.22-0.24
# Core utilities
wezterm git fish yazi gh stow
zellij direnv nix-direnv cachix
# CLI tools
fzf fishPlugins.fzf-fish fishPlugins.z
ripgrep bat fd delta yq jq tmux
tmuxPlugins.resurrect
tmuxPlugins.tmux-fzf
tmuxPlugins.tmux-thumbs
];
# Linux-specific packages
linuxPackages = with pkgs; [
pkgs.nixgl.auto.nixGLDefault
emacs-git
racket-minimal
wrappedKitty
syncthing
git-graph
gdb mpv
# Fonts
nerd-fonts.symbols-only
nerd-fonts.victor-mono
merriweather input-fonts fira-sans victor-mono
# ia-writer-duospace ia-writer-quattro iosevka-comfy.comfy
];
# Darwin-specific packages
darwinPackages = with pkgs; [
# moved to brew
];
# Create platform-specific outputs
platformOutputs = if isDarwin then {
darwinConfigurations.${hostname} = darwin.lib.darwinSystem {
inherit system;
modules = [
({ config, ... }: {
homebrew.taps = builtins.attrNames config.nix-homebrew.taps;
})
nix-homebrew.darwinModules.nix-homebrew
{
nix.settings.trusted-users = [ "${user}" ]; # FIXME
nix-homebrew = {
user = "${user}";
enable = true;
enableRosetta = true;
autoMigrate = true;
mutableTaps = true;
};
fonts.packages = [
pkgs.nerd-fonts.symbols-only
pkgs.nerd-fonts.victor-mono
pkgs.victor-mono
pkgs.merriweather
pkgs.input-fonts
pkgs.fira-sans
];
homebrew = {
enable = true;
onActivation = {
autoUpdate = true;
upgrade = true;
cleanup = "zap";
};
taps = [
"derailed/k9s"
"gardener/tap"
"gitguardian/tap"
"int128/kubelogin"
];
brews = [
# deps
"coreutils" "gnu-sed" "gnu-tar" "grep" "gzip" "parallel" "iproute2mac"
# workPackages
"kubernetes-cli" "kubebuilder" "kubectx" "kind" "helm"
"lazydocker" "k9s" "kubecolor"
"gardenlogin" "gardenctl-v2" "ggshield" "kubelogin"
"yaml-language-server" "helm-ls"
# personal
"minimal-racket" "mpv"
# pdf-tools
"pkg-config" "poppler" "autoconf" "automake"
];
casks = [
"emacs@pretest"
"kitty"
"syncthing"
"rectangle"
"jordanbaird-ice"
"ubersicht"
"docker"
];
};
programs.fish.enable = true;
programs.zsh.enable = true;
programs.tmux.enable = true;
environment = {
shells = [ pkgs.fish ];
systemPackages = commonPackages ++ darwinPackages;
};
# NOTE doesnt work with tmux: https://github.com/LnL7/nix-darwin/pull/1020
security.pam.enableSudoTouchIdAuth = true;
system = {
keyboard = {
enableKeyMapping = true;
remapCapsLockToControl = true;
};
defaults = {
dock = {
tilesize = 50;
autohide = false;
orientation = "bottom";
show-recents = false;
};
finder = {
AppleShowAllExtensions = true;
AppleShowAllFiles = true;
ShowPathbar = true;
FXEnableExtensionChangeWarning = false;
};
trackpad = {
Clicking = true;
TrackpadThreeFingerDrag = false;
};
LaunchServices = {
# Disable quarantine for downloaded apps
LSQuarantine = false;
};
NSGlobalDomain = {
AppleShowAllExtensions = true;
InitialKeyRepeat = 15;
KeyRepeat = 1;
};
CustomSystemPreferences = {
"com.apple.finder" = {
# Show directories first
_FXSortFoldersFirst = true; # TODO: https://github.com/LnL7/nix-darwin/pull/594
# New window use the $HOME path
NewWindowTarget = "PfHm";
NewWindowTargetPath = "file://$HOME/";
};
"com.apple.AdLib" = {
# Disable personalized advertising
forceLimitAdTracking = true;
allowApplePersonalizedAdvertising = false;
allowIdentifierForAdvertising = false;
};
};
};
## run darwin-rebuild changelog to check this
stateVersion = 5;
};
system.activationScripts.setting.text = ''
# Allow opening apps from any source
sudo spctl --master-disable
'';
}
];
};
defaultPackage.${system} = pkgs.buildEnv {
name = "packages-darwin";
paths = commonPackages ++ darwinPackages;
};
} else {
defaultPackage.${system} = pkgs.buildEnv {
name = "packages-linux";
paths = commonPackages ++ linuxPackages;
};
};
in platformOutputs // {
# Shared configuration that's platform-independent
programs.direnv = {
package = pkgs.direnv;
silent = false;
loadInNixShell = true;
direnvrcExtra = "";
nix-direnv = {
enable = true;
package = pkgs.nix-direnv;
};
};
fonts.fontconfig.enable = true;
programs.bash.enable = true;
programs.fish = {
enable = true;
plugins = with pkgs.fishPlugins; [
fzf-fish.src
z.src
];
};
programs.fzf.enableFishIntegration = false;
environment.shells = with pkgs; [ fish ];
users.defaultUserShell = pkgs.fish;
};
}