nix-clojure
Skill3 starsChanged 18 days agoApache-2.0View on GitHub
Package Clojure and ClojureScript projects in Nix flakes with clj-nix. Covers `mkCljApp` and `mkCljsApp` with their defaults written out, committing `deps-lock.json` beside `flake.lock`, a JDK pinned through `clojure.override`, a deterministic `node_modules` for shadow-cljs, a comment on every overridden `buildCommand`, `cljfmt`, `clj-kondo` and tests wired as flake checks, and the tools the dev shell ships. Use when packaging a Clojure project with Nix, debugging a clj-nix build, or adding ClojureScript or shadow-cljs to a flake.
In this repository6 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- nix-flake-recursive-bump-input-versionsSkill
- nix-flakesSkill
- nix-javaSkill
- nix-language-packagingSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Use clj-nix.lib.mkCljApp (JVM) or mkCljsApp (ClojureScript) with projectSrc = ./., rather than a hand-written derivation.
- Very specific: line 13
Write the defaults out (nativeImage.enable = false, customJdk.enable = false, buildId, buildTarget), so the file says what the build is …
- Very specific: line 24
Commit deps-lock.json, clj-nix's lockfile for Maven dependencies, alongside flake.lock.
- Very specific: line 30
When overriding mkCljsApp's buildCommand, comment why the default wasn't enough, for example: "the default clj-builder cljs-compile runs …
- Very specific: line 62
If your agent doesn't run the line above, read these files yourself if they exist: nix-clojure.preferences.md next to this skill's folder, …
- Distinctive: line 69
When one of these applies and it's in your skill listing, load it without asking.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Nix + Clojure / ClojureScript
For Clojure and ClojureScript projects packaged with clj-nix. The generic flake conventions this builds on (input pinning, flake-parts, dev shell commands, treefmt, git ls-files) are in nix-flakes.
Packaging
- Use
clj-nix.lib.mkCljApp(JVM) ormkCljsApp(ClojureScript) withprojectSrc = ./., rather than a hand-written derivation. - Write the defaults out (
nativeImage.enable = false,customJdk.enable = false,buildId,buildTarget), so the file says what the build is without a trip to the clj-nix README. Override
clojurewith the project's pinned JDK, so build, tests, REPL and IDE all run the same one:clojure.override { jdk = pinnedJdk; }Take
pinnedJdkfrom the single toolchain constant innix-flakes; the JDK overrides for other JVM tools are innix-java.
Lockfiles
- Commit
deps-lock.json, clj-nix's lockfile for Maven dependencies, alongsideflake.lock. Dependency resolution is reproducible only with both. - Make
update-deps(regeneratedeps-lock.json) andupdate-flake(nix flake update) dev shell commands.
ClojureScript / shadow-cljs
- Build
node_modulesfrompackage-lock.jsonwithpkgs.importNpmLock.buildNodeModules { npmRoot = ./.; inherit nodejs; }(nodejsis a required argument) and symlink it inpreBuild. The build needs no network. - When overriding
mkCljsApp'sbuildCommand, comment why the default wasn't enough, for example: "the defaultclj-builder cljs-compileruns shadow-cljs directly and wouldn't see the:shadow-cljsalias's deps". - In a dev command that relinks
node_modules,rmit only if it points into the Nix store (readlink -fstarts with${builtins.storeDir}), so a developer's ownnpm installsurvives.
Lint, format, test as flake checks
Wire the Clojure tooling as checks.${system}, so nix flake check runs the same way locally and in CI:
cljfmt check: formatting.clj-kondo: linting.- The project's test runner (
clojure -M:test,bb test, and so on).
For a repo that mixes Clojure with other languages, drive cljfmt from treefmt alongside nixfmt and shfmt, as nix-flakes describes.
Dev shell contents
Ship every tool a contributor needs, so the README has no "install this globally" step:
clj-kondo,cljfmt: lint and format.clojure, overridden with the pinned JDK.nodejsandnpm, for ClojureScript projects.git,tree,jq.
References
clj-nix: upstream docs, including themkCljAppandmkCljsAppreference.cljfmtandclj-kondo.- shadow-cljs.
Your preferences
!cat "${CLAUDE_SKILL_DIR}/../nix-clojure.preferences.md" "${CLAUDE_PROJECT_DIR}/.agents/skills/nix-clojure.preferences.md" 2>/dev/null || true
If your agent doesn't run the line above, read these files yourself if they
exist: nix-clojure.preferences.md next to this skill's folder, then
.agents/skills/nix-clojure.preferences.md in the project. A project's
file overrides the user's, and the user's overrides this skill's defaults.
Related skills
When one of these applies and it's in your skill listing, load it without asking. If it isn't in your listing, tell the user which skill is missing and ask whether to install it from the same collection this skill came from; don't apply it from memory.
nix-flakes: flake conventions this skill builds on: input pinning,flake-parts, toolchain pinning, dev shell commands,treefmt.nix-java: JDK pinning across JVM tools, the IDE-stablenix-jdksymlink andlowPriofor clashing wrappers.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

