Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
192 lines (184 loc) · 6.36 KB
/
Copy pathflake.nix
File metadata and controls
192 lines (184 loc) · 6.36 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
treefmt-nix.url = "github:numtide/treefmt-nix";
agent-skills.url = "github:Kyure-A/agent-skills-nix";
anthropic-skills.url = "github:anthropics/skills";
anthropic-skills.flake = false;
lazy-nvim.url = "github:folke/lazy.nvim";
lazy-nvim.flake = false;
# For the hm module checks. The module itself does not depend on home-manager
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{
self,
nixpkgs,
treefmt-nix,
agent-skills,
anthropic-skills,
lazy-nvim,
home-manager,
}:
let
# x86_64-darwin is out of scope: nixpkgs 26.11 dropped support for it
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
pkgsFor = system: import nixpkgs { inherit system; };
nvimxLibFor =
system:
import ./nix/lib {
pkgs = pkgsFor system;
lazyNvimSeed = lazy-nvim;
};
# The agent skills catalog / allowlist / selection do not depend on pkgs.
# Only the bundle does, so it is assembled on the apps side.
agentLib = agent-skills.lib.agent-skills;
sources = {
anthropic = {
path = anthropic-skills;
subdir = "skills";
};
};
catalog = agentLib.discoverCatalog sources;
allowlist = agentLib.allowlistFor {
inherit catalog sources;
enable = [
"doc-coauthoring"
"skill-creator"
];
};
selection = agentLib.selectSkills {
inherit catalog allowlist sources;
skills = { };
};
localTargets = {
claude = agentLib.defaultLocalTargets.claude // {
enable = true;
};
};
in
{
lib = forAllSystems (
system:
(nvimxLibFor system)
// {
lazyNvimSeed = lazy-nvim;
}
);
homeModules = rec {
nvimx = import ./nix/home-manager { lazyNvimSeed = lazy-nvim; };
default = nvimx;
};
templates.default = {
path = ./templates/default;
description = "home-manager dotfiles template with nvimx integrated";
};
packages = forAllSystems (
system:
let
pkgs = pkgsFor system;
nvimxLib = nvimxLibFor system;
in
{
demo =
let
env = nvimxLib.makeEnv {
package = pkgs.neovim-unwrapped;
lockDir = ./tests/fixtures/basic-config/nvimx-lock;
};
configDir = ./tests/fixtures/basic-config;
in
pkgs.writeShellApplication {
name = "nvim";
text = ''
base="''${XDG_CACHE_HOME:-$HOME/.cache}/nvimx-demo"
mkdir -p "$base/config" "$base/data/nvim/lazy" "$base/state" "$base/cache"
ln -sfT ${configDir} "$base/config/nvim"
ln -sfT ${env.farm}/lazy.nvim "$base/data/nvim/lazy/lazy.nvim"
export XDG_CONFIG_HOME="$base/config"
export XDG_DATA_HOME="$base/data"
export XDG_STATE_HOME="$base/state"
export XDG_CACHE_HOME="$base/cache"
exec ${env.wrapped}/bin/nvim "$@"
'';
};
}
);
formatter = forAllSystems (
system:
let
pkgs = pkgsFor system;
in
treefmt-nix.lib.mkWrapper pkgs {
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
# stylua picks up the repo-root stylua.toml because treefmt runs from the tree root and
# stylua reads its cwd -- it does not search upwards unless asked (see stylua.toml).
# Deliberately not setting programs.stylua.settings: doing so would make treefmt-nix
# generate a
# store-path stylua.toml and pass it via --config-path, which wins over (and
# silently ignores) the repo's stylua.toml -- editors and CI would then disagree.
# The cost of that choice: treefmt caches on the file plus the command, so editing
# stylua.toml or .luacheckrc does not invalidate anything. Use `nix fmt --
# --clear-cache` after changing them. CI passes --ci, which implies --no-cache.
stylua.enable = true;
# stylua rewrites files, luacheck only reads them. treefmt applies formatters
# matching the same file in ascending priority order, so pin the order explicitly
# (omitting it falls back to name order, which runs luacheck before stylua).
stylua.priority = 1;
# Only tests/checks/scripts/*.sh today: check bodies that are plain shell live there
# instead of in a Nix string, which neither of these can see.
shellcheck.enable = true;
shfmt.enable = true;
};
# luacheck is a linter, not a formatter, so treefmt-nix has no programs.luacheck.
# treefmt only requires a formatter to accept paths and exit non-zero on failure;
# luacheck never rewrites files, so it fits as-is (upstream does the same for
# shellcheck / statix / yamllint, etc.). Configuration comes from .luacheckrc.
settings.formatter.luacheck = {
command = pkgs.luaPackages.luacheck;
includes = [ "*.lua" ];
priority = 2;
};
}
);
checks = forAllSystems (
system:
import ./tests/checks {
pkgs = pkgsFor system;
nvimxLib = nvimxLibFor system;
inherit self lazy-nvim home-manager;
}
);
apps = forAllSystems (
system:
let
pkgs = pkgsFor system;
nvimxLib = nvimxLibFor system;
bundle = agentLib.mkBundle { inherit pkgs selection; };
in
{
lock = {
type = "app";
program = "${nvimxLib.lockApp}/bin/nvimx-lock";
};
skills-install = {
type = "app";
program = "${
agentLib.mkLocalInstallScript {
inherit pkgs bundle;
targets = localTargets;
}
}/bin/skills-install-local";
};
}
);
};
}