hlolli / clj2nix Goto Github PK
View Code? Open in Web Editor NEWConvert deps.edn to a nix expression
License: GNU Affero General Public License v3.0
Convert deps.edn to a nix expression
License: GNU Affero General Public License v3.0
I am working with a dep that is located at (for instance)
https://repo1.maven.org/maven2/com/github/jnr/jffi/1.2.23/jffi-1.2.23-native.jar
clj2nix wants to generate the deps.nix file for this dep with
{
name = "com.github.jnr/jffi$native";
path = pkgs.fetchMavenArtifact {
inherit repos;
artifactId = "jffi$native";
groupId = "com.github.jnr";
sha512 = "e8b8040df1135f2a7dd67161374ca9a76f978eeaf16ad72756363ef353fce6e67d0155682799fd54dedf6fda907eb809edd58d8948fd3c855ee1c24443538c18";
version = "1.2.23";
};
}
..which is invalid of course
so I end up with
$ nix-build --show-trace
error: while evaluating the attribute 'buildInputs' of the derivation 'hello' at /home/myproj/default.nix:14:3:
while evaluating the attribute 'installPhase' of the derivation 'com_github_jnr_jffi$native-1.2.23' at /nix/store/n5rmm4yw7gk5w7sinbndimdndbdwzxqm-source/pkgs/build-support/fetchmavenartifact/default.nix:64:5:
invalid character '$' in name 'com_github_jnr_jffi$native-1.2.23.jar'
However, because clj2nix appears to want a convention that builds an URL from the above expression, and appends the version to the end of the url for the dependency and apparently the people who created this jffi-1.2.23-native
did not follow this convention, I am now in a position where I cannot build with this dependency.
I am wondering if anyone has run into this and has workarounds for dealing with these kinds of dependencies?
Thanks
How to install default.nix at config.nix.
https://discourse.nixos.org/t/maintained-usable-tooling-for-building-clojure-projects-in-nix/1556/4
When using clj2nix with -A
the only supported option I get the following warning:
WARNING: Use of -A with clojure.main is deprecated, use -M instead
I guess it would be good to support -M
and also potentially -X
.
Since different aliases have different deps, woud it be useful to have the option to generate one nix file for each alias? Or is it better to run clj2nix
multiple times and saving the different deps to different files?
I was thinking you could for example have deps-test.nix
and then use it like clojure -Scp ${testClassp} -M:test
.
Perhaps nicest would be to generate all the deps in the same file, but generate an attrset with aliases and within each a function to generate the classpath.
Hello hlolli.
Thanks.
building '/nix/store/bg2h31q4j4ff3km4w9n29hqikghclayn-clj2nix.drv'...
trying https://github.com/hlolli/clj2nix/archive/e6d09dd8c5cda68eb0534bd8501f2d5dcd7b2e95.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 156 100 156 0 0 2943 0 --:--:-- --:--:-- --:--:-- 2943
100 25784 0 25784 0 0 68211 0 --:--:-- --:--:-- --:--:-- 68211
unpacking source archive /private/tmp/nix-build-clj2nix.drv-0/e6d09dd8c5cda68eb0534bd8501f2d5dcd7b2e95.tar.gz
error: while evaluating the attribute 'passAsFile' of the derivation 'pnix' at /nix/store/1xl4yrp6yw69j9kyxdb7bby64vp4wwnj-nixpkgs-21.11pre294098.4df31757808/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'passAsFile' at /nix/store/1xl4yrp6yw69j9kyxdb7bby64vp4wwnj-nixpkgs-21.11pre294098.4df31757808/nixpkgs/pkgs/build-support/buildenv/default.nix:77:5:
while evaluating the attribute 'installPhase' of the derivation 'clj2nix-1.0.7' at /nix/store/1xl4yrp6yw69j9kyxdb7bby64vp4wwnj-nixpkgs-21.11pre294098.4df31757808/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating 'makeClasspaths' at /nix/store/sr70gvqwiql179j5jd76j9ay94drd4zm-clj2nix/deps.nix:30:24, called from /nix/store/sr70gvqwiql179j5jd76j9ay94drd4zm-clj2nix/default.nix:7:15:
while evaluating the derivation attribute 'name' at /nix/store/1xl4yrp6yw69j9kyxdb7bby64vp4wwnj-nixpkgs-21.11pre294098.4df31757808/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'name' at /nix/store/1xl4yrp6yw69j9kyxdb7bby64vp4wwnj-nixpkgs-21.11pre294098.4df31757808/nixpkgs/pkgs/build-support/fetchurl/default.nix:124:3:
attribute 'lib' missing, at /nix/store/8qsbrv8y6ifw1icmr9gv723m8g5krygi-default.nix:42:10
At work we are using mirrors for both central and clojars, it would be nice if the property :mvn/repos
was taken into account and overriding all the repos defined. Alternatively (second best) if you could provide a repo or a list of repos via the CLI clj2nix to affect this variable.
Hopefuly this config inside deps.edn
:
{:mvn/repos {"central" {:url "https://artifactory.domain/artifactory/v-maven-releases"}
"clojars" {:url "https://artifactory.domain/artifactory/v-maven-releases"}}
...
Would result in this:
let repos = [ "https://artifactory.domain/artifactory/v-maven-releases" ];
Issue output:
trying https://repo.clojars.org/joda-time/joda-time/2.9.7/joda-time-2.9.7-.jar
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (22) The requested URL returned error: 404 Not Found
error: cannot download joda-time_joda-time-2.9.7.jar from any mirror
It looks like dependencies using :git/url
just pull the git repository directly into the classpath, rather than the source-paths inside that repository. For example, a dependency of:
borkdude/rewrite-edn {:git/url "https://github.com/borkdude/rewrite-edn"
:sha "a0f6b2aa9087b1dbed0ecc71ea48c0dbaa60d91b"}
becomes:
{
name = "borkdude/rewrite-edn";
path = pkgs.fetchgit {
name = "rewrite-edn";
url = "https://github.com/borkdude/rewrite-edn";
rev = "a0f6b2aa9087b1dbed0ecc71ea48c0dbaa60d91b";
sha256 = "17pn1iaib909s1l0idmg6pvpy4xi6s7jdlv1cf915ixx34a62dhi";
};
}
in the resulting deps.nix
, when in actuality it should be something like
{
name = "borkdude/rewrite-edn";
path = "${pkgs.fetchgit {
name = "rewrite-edn";
url = "https://github.com/borkdude/rewrite-edn";
rev = "a0f6b2aa9087b1dbed0ecc71ea48c0dbaa60d91b";
sha256 = "17pn1iaib909s1l0idmg6pvpy4xi6s7jdlv1cf915ixx34a62dhi";
}}/src";
}
Why not add this package to https://github.com/NixOS/nixpkgs ?
On MacOS this is generally not available, so adding a note describing the installation of these would help.
nix-shell -p coreutils nix-prefetch-git
helps until this is fixed.
It is generally not allowed to use pkgs as an input in nixpkgs with a few small exceptions. It would be nice if you could use lib, fetchMavenArtifact
instead.
I stumbled upon https://clojars.org/kitchen-async/versions/0.1.0-SNAPSHOT
Which will generate:
{
name = "kitchen-async";
path = pkgs.fetchMavenArtifact {
inherit repos;
artifactId = "kitchen-async";
groupId = "kitchen-async";
sha512 = "0d6f8ce7b94b538e00e4a6719362dfe121b0db303906f46b638943c087ac1861442ea4896211110a06a01ecd5fab44dc7deb3b26d918c263be18751ff783492c";
version = "0.1.0-SNAPSHOT";
};
}
This will look for:
https://repo.clojars.org/kitchen-async/kitchen-async/0.1.0-SNAPSHOT/kitchen-async-0.1.0-SNAPSHOT.jar
However, the resulting artifact won't exist:
https://repo.clojars.org/kitchen-async/kitchen-async/0.1.0-SNAPSHOT/
Seems if you provide the url attribute to the artifact it will work.
I'm seeing this when running clj2nix on clojure 1.10.1.727, which was introduced by this commit: NixOS/nixpkgs@43776fb
WARNING: When invoking clojure.main, use -M
I'll make a PR to condition the invocation based on the clojure version
I'd love to install this using a Nix flake rather than manually specifying the build!
It would be nice if :extra-paths
could be read and populated the extraClasspaths
by default. Right now you have to manually keep those two in sync.
If I pass in extraClasspaths
I would like that to be combined with the :extra-paths
from the aliases.
If I have multiple aliases with :extra-paths
and use several of these aliases together with the clj2nix
command I would also expect all of them to be added.
What do you think?
Is it possible that this application doesn't include :mvn/repos in its operations? I have a few dependencies that are not hosted on maven central, so I add this line to my deps.edn:
:mvn/repos {"ias-releases" {:url "https://maven.mangoautomation.net/repository/ias-release/"}}
This works doing REPL or other normal operations, but clj2nix says that it can't find these dependencies.
I'm using this to build rep
with GraalVM's native-image. It's working for that part, but I want to . run tests after, and this has a :test
alias that needs to be merged in. Is this a good idea?
EDIT: To be clear, this is in a release.nix
, so it is a separate package that needs more dependencies, even though it uses the same src
attribute.
The path name 'org_openjfx_javafx-base$mac-14.jar' is invalid: the '$' character is invalid. Path names are alphanumeric and can include the symbols +-._?= and must not begin with a period. Note: If 'org_openjfx_javafx-base$mac-14.jar' is a source file and you cannot rename it on disk, builtins.path { name = ... } can be used to give it an alternative name.
CLJFX = (import ~/cljfx/deps.nix { inherit pkgs; }).makeClasspaths {};
install CLJFX~ I can't.
deps.edn is
https://github.com/cljfx/cljfx
When I checked the .m2 folder, the received file name is like this.
org.openjfx/javafx-base-14-mac.jar
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.