Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bevuta/clojure-nix-locker
Simple and flexible tool to build clojure projects with Nix
https://github.com/bevuta/clojure-nix-locker
clojure lockfile nix
Last synced: 3 months ago
JSON representation
Simple and flexible tool to build clojure projects with Nix
- Host: GitHub
- URL: https://github.com/bevuta/clojure-nix-locker
- Owner: bevuta
- License: gpl-3.0
- Created: 2022-04-13T00:14:30.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-04-10T21:03:33.000Z (10 months ago)
- Last Synced: 2024-08-01T19:51:48.040Z (6 months ago)
- Topics: clojure, lockfile, nix
- Language: Nix
- Homepage:
- Size: 44.9 KB
- Stars: 23
- Watchers: 7
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# clojure-nix-locker
Simple and flexible tool to build clojure projects with Nix.
## Usage
The [example/](example) directory has a small clojure program and the nix code required to build it.
### Stable non-flake way
To generate/update the lockfile:
```sh
nix-shell --run clojure-nix-locker
```To build:
```sh
nix-build -A uberjar
```### With flakes
You can generate a flake example with:
```sh
mkdir play-with-clojure-nix-locker && cd play-with-clojure-nix-locker && nix flake init -t github:bevuta/clojure-nix-locker
```The [example README](example/README.md) has some next steps.
## Why another tool?
There are two existing projects with a similar goal already, [clj2nix](https://github.com/hlolli/clj2nix) and [clj-nix](https://github.com/jlesquembre/clj-nix).
Both of these are designed to be used roughly like this:- At lock-time, call into `clojure.tools.deps` to resolve all dependencies, then generate a lockfile from this.
- At nix-eval-time, use the information from the lockfile to compute the classpath.
- At build-time, invoke clojure and pass it the precomputed classpath.By contrast, `clojure-nix-locker` is designed around letting classpath computation happen later, at build-time.
It works roughly like this:- At lock-time, call arbitrary user-provided commands (like `clojure -P`) to pre-populate the caches in `.m2` and `.gitlibs`, then crawl those to generate the lockfile.
- At nix-eval-time, use the information from the lockfile to recreate these caches in a way that's "close enough" to the real thing.
- At build-time, invoke clojure as normal. If the prefetching was done correctly, it will resolve its dependencies just fine without hitting the network.This approach results in a pretty simple implementation and loose coupling to the clojure tooling.
As a consequence, things like aliases "just work" without requiring `clojure-nix-locker` to know about them.Of course, this has its downsides too:
- If the directory layout of these caches changes, this tool breaks.
- Whatever classpath(s) your clojure tools compute at build-time will only work for the duration of that build.## License
Distributed under the GNU General Public License, Version 3. See `LICENSE` for more details.