-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
207 lines (193 loc) · 5.99 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
{
description = "NixOS systems and tools by richban";
inputs = {
# determinate.url = "https://flakehub.com/f/DeterminateSystems/determinate/0";
# nixpkgs.url = "https://flakehub.com/f/nixos/nixpkgs/0.2411.*";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
# nixpkgs-unstable.url = "https://flakehub.com/f/DeterminateSystems/nixpkgs-weekly/0";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-homebrew.url = "github:zhaofengli/nix-homebrew";
devenv = {
url = "github:cachix/devenv/latest";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-index-database.url = "github:Mic92/nix-index-database";
nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
catppuccin.url = "github:catppuccin/nix";
# Neovim flakes
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
projections = {
url = "github:gnikdroy/projections.nvim/pre_release";
flake = false;
};
nui = {
url = "github:MunifTanjim/nui.nvim";
flake = false;
};
incRename = {
url = "github:smjonas/inc-rename.nvim";
flake = false;
};
diffview = {
url = "github:sindrets/diffview.nvim";
flake = false;
};
oxacarbonColors = {
url = "github:nyoom-engineering/oxocarbon.nvim";
flake = false;
};
copilot = {
url = "github:zbirenbaum/copilot.lua";
flake = false;
};
copilotCmp = {
url = "github:zbirenbaum/copilot-cmp";
flake = false;
};
copilotLualine = {
url = "github:AndreM222/copilot-lualine";
flake = false;
};
copilotChat = {
url = "github:CopilotC-Nvim/CopilotChat.nvim";
flake = false;
};
conformNvim = {
url = "github:stevearc/conform.nvim";
flake = false;
};
ropeVim = {
url = "github:python-rope/ropevim";
flake = false;
};
};
outputs = {
self,
nixpkgs,
...
} @ inputs: let
inherit (inputs.nixpkgs) lib;
inherit (lib) filterAttrs genAttrs intersectLists mapAttrs mapAttrs' mapAttrsToList mergeAttrsList nameValuePair platforms;
stateVersion = "24.11";
helper = import ./system/lib {inherit inputs self stateVersion;};
defaultSystems =
intersectLists
(platforms.linux ++ platforms.darwin)
(platforms.x86_64 ++ platforms.aarch64);
darwinSystems = intersectLists defaultSystems platforms.darwin;
eachSystemMap = genAttrs;
mkHooks = system:
inputs.pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
black.enable = true;
shellcheck.enable = true;
alejandra.enable = true;
shfmt.enable = false;
stylua.enable = true;
deadnix = {
enable = true;
settings = {
edit = true;
noLambdaArg = true;
};
};
};
};
in {
checks = mergeAttrsList [
# verify devShell + pre-commit hooks;
(eachSystemMap defaultSystems (
system: {
devShell = self.devShells.${system}.default;
pre-commit-check = mkHooks system;
}
))
# home-manager checks; add _home suffix to original config to avoid nixos coflict
(eachSystemMap defaultSystems (system:
mapAttrs'
(name: drv: (nameValuePair "${name}_home" drv.activationPackage))
(filterAttrs
(name: drv: lib.strings.hasSuffix system name)
self.homeConfigurations)))
# darwin checks; limit these to darwinSystems
(eachSystemMap darwinSystems (system:
mapAttrs
(name: drv: drv.config.system.build.toplevel)
(filterAttrs
(name: drv: lib.strings.hasSuffix system name)
self.darwinConfigurations)))
];
darwinConfigurations = {
"melchior@aarch64-darwin" = helper.mkDarwin {
hostname = "mac-mini";
username = "melchior";
platform = "aarch64-darwin";
};
};
homeConfigurations = {
"melchior@aarch64-darwin" = helper.mkHome {
hostname = "mac-mini";
username = "melchior";
platform = "aarch64-darwin";
};
};
devShells = eachSystemMap defaultSystems (system: let
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [self.overlays.default];
};
pre-commit-check = mkHooks system;
in {
default = pkgs.mkShell {
inherit (pre-commit-check) shellHook;
packages = with pkgs;
[
bashInteractive # Enhanced bash shell
fd # Fast alternative to 'find'
nixd # Nix language server
ripgrep # Fast text search tool
uv # Python packaging tool
]
++ (mapAttrsToList (name: value: value) self.packages.${system}); # Adds all packages defined in packages attribute
inputsFrom = pre-commit-check.enabledPackages;
};
});
packages = eachSystemMap defaultSystems (
system: let
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [self.overlays.default];
};
in rec {
sysdo = pkgs.writeShellScriptBin "sysdo" "${pkgs.uv}/bin/uv run -q ${./bin/do.py} $@";
}
);
apps = eachSystemMap defaultSystems (system: rec {
sysdo = {
type = "app";
program = "${self.packages.${system}.sysdo}/bin/sysdo";
};
default = sysdo;
});
overlays = {
neovimOverlay = import ./system/overlays/neovim.nix {inherit inputs;};
default = final: prev: {
sysdo = self.packages.${prev.system}.sysdo;
};
};
# Formatter for .nix files, available via 'nix fmt'
formatter = eachSystemMap defaultSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
};
}