jlesquembre / clj-nix

Nix helpers for Clojure projects
https://jlesquembre.github.io/clj-nix/
Eclipse Public License 2.0
146 stars 22 forks source link

Tutorial: Steps from README break at custom jdk #5

Closed bennyandresen closed 2 years ago

bennyandresen commented 2 years ago

Cool project! Very excited about marrying both Clojure and nix.

However following the tutorial I'm not able to create a custom jdk.

Steps to reproduce

$ git clone https://github.com/jlesquembre/clj-demo-project.git
$ cd clj-demo-project
$ nix run github:jlesquembre/clj-nix#deps-lock
$ git add deps-lock.json

^^^ output omitted

$ nix run .#clj-tuto
Hello from CLOJURE!!!
$ nix build .#jdk-tuto
error: builder for '/nix/store/bq7b5ikv82ay09f970qpsfcgzi5fd5fr-customJDK.drv' failed with exit code 2;
       last 9 log lines:
       > patching sources
       > configuring
       > no configure script, doing nothing
       > building
       > no Makefile, doing nothing
       > installing
       > Error: invalid argument: Missing dependencies: classes not found from the module path and classpath. To suppress this error, use --ignore-missing-deps to continue. clj-tuto-1.0.jar demo.core -> clojure.lang.IFn not found demo.core -> clojure.lang.ISeq not found demo.core -> clojure.lang.RT not found demo.core -> clojure.lang.Util not found demo.core -> clojure.lang.Var not found demo.core$_main -> clojure.lang.IFn not found demo.core$_main -> clojure.lang.ISeq not found demo.core$_main -> clojure.lang.RT not found demo.core$_main -> clojure.lang.RestFn not found demo.core$_main -> clojure.lang.Var not found demo.core$fn__142 -> clojure.lang.AFn not found demo.core$fn__142 -> clojure.lang.AFunction not found demo.core$fn__142 -> clojure.lang.IFn not found demo.core$fn__142 -> clojure.lang.RT not found demo.core$fn__142 -> clojure.lang.Symbol not found demo.core$fn__142 -> clojure.lang.Var not found demo.core$loading__6789__auto____140 -> clojure.lang.AFn not found demo.core$loading__6789__auto____140 -> clojure.lang.AFunction not found demo.core$loading__6789__auto____140 -> clojure.lang.Associative not found demo.core$loading__6789__auto____140 -> clojure.lang.Compiler not found demo.core$loading__6789__auto____140 -> clojure.lang.IFn not found demo.core$loading__6789__auto____140 -> clojure.lang.IPersistentMap not found demo.core$loading__6789__auto____140 -> clojure.lang.IPersistentVector not found demo.core$loading__6789__auto____140 -> clojure.lang.Keyword not found demo.core$loading__6789__auto____140 -> clojure.lang.RT not found demo.core$loading__6789__auto____140 -> clojure.lang.Symbol not found demo.core$loading__6789__auto____140 -> clojure.lang.Tuple not found demo.core$loading__6789__auto____140 -> clojure.lang.Var not found demo.core__init -> clojure.lang.AFn not found demo.core__init -> clojure.lang.Compiler not found demo.core__init -> clojure.lang.IFn not found demo.core__init -> clojure.lang.IPersistentList not found demo.core__init -> clojure.lang.IPersistentMap not found demo.core__init -> clojure.lang.IPersistentVector not found demo.core__init -> clojure.lang.Keyword not found demo.core__init -> clojure.lang.LockingTransaction not found demo.core__init -> clojure.lang.PersistentList not found demo.core__init -> clojure.lang.RT not found demo.core__init -> clojure.lang.Symbol not found demo.core__init -> clojure.lang.Tuple not found demo.core__init -> clojure.lang.Var not found,jdk.localedata --include-locales en,es --compress 2 --output /nix/store/s36sckx4q11nd8jh36s2krvk4g30i8jd-customJDK-jdk
       > Usage: jlink <options> --module-path <modulepath> --add-modules <module>[,<module>...]
       > Use --help for a list of possible options
       For full logs, run 'nix log /nix/store/bq7b5ikv82ay09f970qpsfcgzi5fd5fr-customJDK.drv'.
$ tree
.
├── deps-lock.json
├── deps.edn
├── extra-pkgs
│  ├── babashka
│  │  └── deps-lock.json
│  └── clj-kondo
│     └── deps-lock.json
├── flake.lock
├── flake.nix
├── LICENSE
├── README.md
└── src
   └── demo
      └── core.clj
jlesquembre commented 2 years ago

Thanks for the kind words :)

Interesting, so far I was not able to reproduce it. Two questions:

In theory the lock file should be exactly the same

bennyandresen commented 2 years ago

The deps-lock.json is identical.

I'm not a mac user, NixOS Linux x86_64. I'm however on 21.11 and not unstable, which may be relevant. (It often is, I forgot.)

jlesquembre commented 2 years ago

With flakes, your nixpkgs version should not matter. But maybe it does, not sure. I'll try to reproduce it using a different version.

jlesquembre commented 2 years ago

What is your nix version? (nix --version)

bennyandresen commented 2 years ago

I've also tried to edit the flake.nix nixpkgs.url = "github:NixOS/nixpkgs/release-21.11"; but that didn't help either.

$ nix --version
nix (Nix) 2.4

because 21.11 doesn't normally have enabled nix flakes my nixos/configuration.nix has the following entries

# enable flakes
nix.package = pkgs.nixFlakes;
nix.extraOptions = ''experimental-features = nix-command flakes'';
jlesquembre commented 2 years ago

I'm on 2.6 and nixpkgs unstable and I also have are those nix.extraOptions values. I'm playing a bit with different version', let's see if I find something

jlesquembre commented 2 years ago

I was able to reproduce the error with nix 2.4

Could you try:

nix shell github:NixOS/nixpkgs/nixos-unstable#nix
nix build .#clj-tuto
nix build .#jdk-tuto

That fixed it for me, but not sure what's the reason, looking into the nix release notes

bennyandresen commented 2 years ago

That also fixed it for me. Thanks! I can deal with this until the next NixOS release that includes a higher nix version.