Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to correctly resolve mill dependencies in develop shells? #83

Open
CSharperMantle opened this issue Feb 26, 2025 · 2 comments

Comments

@CSharperMantle
Copy link

Background

I am trying to get familiar with chisel-nix, and utilize it to spin up my next project. I have created a project with the chisel-nix template with its content left unmodified.

Problem

The template GCD code is building correctly. However, when I start a develop shell with nix develop ".#gcd.gcd-compiled", mill can't find the pulled Chisel dependency. Are there any points in initialization that I am missing?

Project creation:

mkdir test-chisel-nix
cd test-chisel-nix
git init
nix flake init -t github:chipsalliance/chisel-nix#chisel

Building:

$ nix build ".#gcd.rtl"

$ ls -la result/
total 960
dr-xr-xr-x    2 root root     4096 Jan  1  1970 .
drwxrwxr-t 1355 root nixbld 962560 Feb 26 10:46 ..
-r--r--r--    1 root root       22 Jan  1  1970 filelist.f
-r--r--r--    1 root root     3437 Jan  1  1970 GCD.sv
-r--r--r--    1 root root       48 Jan  1  1970 ref_GCD.sv

Develop shell: (Not working)

$ nix develop ".#gcd.gcd-compiled"

$ mill -i gcd.ivyDepsTree
[build.mill-64/68] compile
[build.mill-64] [info] compiling 2 Scala sources to /home/nixos/workspace/test-chisel-nix/out/mill-build/compile.dest/classes ...
[build.mill-64] [info] done compiling
[13/13] ============================== gcd.ivyDepsTree ============================== 10s
1 tasks failed
gcd.ivyDepsTree
Resolution failed for 1 modules:
--------------------------------------------
  org.chipsalliance:chisel_2.13:0.0.0+0-no-vcs-SNAPSHOT
        not found: /home/nixos/.ivy2/local/org.chipsalliance/chisel_2.13/0.0.0+0-no-vcs-SNAPSHOT/ivys/ivy.xml
        not found: https://repo1.maven.org/maven2/org/chipsalliance/chisel_2.13/0.0.0+0-no-vcs-SNAPSHOT/chisel_2.13-0.0.0+0-no-vcs-SNAPSHOT.pom

--------------------------------------------

For additional information on library dependencies, see the docs at
https://mill-build.org/mill/Library_Dependencies.html

$ mill -i __.assembly
[138/138] ============================== __.assembly ============================== 4s
8 tasks failed
gcd.resolvedIvyDeps
Resolution failed for 1 modules:
--------------------------------------------
  org.chipsalliance:chisel_2.13:0.0.0+0-no-vcs-SNAPSHOT
        not found: /home/nixos/.ivy2/local/org.chipsalliance/chisel_2.13/0.0.0+0-no-vcs-SNAPSHOT/ivys/ivy.xml
        not found: https://repo1.maven.org/maven2/org/chipsalliance/chisel_2.13/0.0.0+0-no-vcs-SNAPSHOT/chisel_2.13-0.0.0+0-no-vcs-SNAPSHOT.pom

--------------------------------------------

For additional information on library dependencies, see the docs at
https://mill-build.org/mill/Library_Dependencies.html

gcd.enablePluginScalacOptions.super.ScalaModule
Resolution failed for 1 modules:
--------------------------------------------
  org.chipsalliance:chisel-plugin_2.13.15:0.0.0+0-no-vcs-SNAPSHOT
        not found: /home/nixos/.ivy2/local/org.chipsalliance/chisel-plugin_2.13.15/0.0.0+0-no-vcs-SNAPSHOT/ivys/ivy.xml
        not found: https://repo1.maven.org/maven2/org/chipsalliance/chisel-plugin_2.13.15/0.0.0+0-no-vcs-SNAPSHOT/chisel-plugin_2.13.15-0.0.0+0-no-vcs-SNAPSHOT.pom

--------------------------------------------

For additional information on library dependencies, see the docs at
https://mill-build.org/mill/Library_Dependencies.html

gcd.scalacPluginClasspath.super.ScalaModule
Resolution failed for 1 modules:
--------------------------------------------
  org.chipsalliance:chisel-plugin_2.13.15:0.0.0+0-no-vcs-SNAPSHOT
        not found: /home/nixos/.ivy2/local/org.chipsalliance/chisel-plugin_2.13.15/0.0.0+0-no-vcs-SNAPSHOT/ivys/ivy.xml
        not found: https://repo1.maven.org/maven2/org/chipsalliance/chisel-plugin_2.13.15/0.0.0+0-no-vcs-SNAPSHOT/chisel-plugin_2.13.15-0.0.0+0-no-vcs-SNAPSHOT.pom

--------------------------------------------

For additional information on library dependencies, see the docs at
https://mill-build.org/mill/Library_Dependencies.html

elaborator.resolvedIvyDeps
Resolution failed for 1 modules:
--------------------------------------------
  org.chipsalliance:chisel_2.13:0.0.0+0-no-vcs-SNAPSHOT
        not found: /home/nixos/.ivy2/local/org.chipsalliance/chisel_2.13/0.0.0+0-no-vcs-SNAPSHOT/ivys/ivy.xml
        not found: https://repo1.maven.org/maven2/org/chipsalliance/chisel_2.13/0.0.0+0-no-vcs-SNAPSHOT/chisel_2.13-0.0.0+0-no-vcs-SNAPSHOT.pom

--------------------------------------------

For additional information on library dependencies, see the docs at
https://mill-build.org/mill/Library_Dependencies.html

elaborator.enablePluginScalacOptions.super.ScalaModule
Resolution failed for 1 modules:
--------------------------------------------
  org.chipsalliance:chisel-plugin_2.13.15:0.0.0+0-no-vcs-SNAPSHOT
        not found: /home/nixos/.ivy2/local/org.chipsalliance/chisel-plugin_2.13.15/0.0.0+0-no-vcs-SNAPSHOT/ivys/ivy.xml
        not found: https://repo1.maven.org/maven2/org/chipsalliance/chisel-plugin_2.13.15/0.0.0+0-no-vcs-SNAPSHOT/chisel-plugin_2.13.15-0.0.0+0-no-vcs-SNAPSHOT.pom

--------------------------------------------

For additional information on library dependencies, see the docs at
https://mill-build.org/mill/Library_Dependencies.html

elaborator.scalacPluginClasspath.super.ScalaModule
Resolution failed for 1 modules:
--------------------------------------------
  org.chipsalliance:chisel-plugin_2.13.15:0.0.0+0-no-vcs-SNAPSHOT
        not found: /home/nixos/.ivy2/local/org.chipsalliance/chisel-plugin_2.13.15/0.0.0+0-no-vcs-SNAPSHOT/ivys/ivy.xml
        not found: https://repo1.maven.org/maven2/org/chipsalliance/chisel-plugin_2.13.15/0.0.0+0-no-vcs-SNAPSHOT/chisel-plugin_2.13.15-0.0.0+0-no-vcs-SNAPSHOT.pom

--------------------------------------------

For additional information on library dependencies, see the docs at
https://mill-build.org/mill/Library_Dependencies.html

elaborator.resolvedRunIvyDeps
Resolution failed for 1 modules:
--------------------------------------------
  org.chipsalliance:chisel_2.13:0.0.0+0-no-vcs-SNAPSHOT
        not found: /home/nixos/.ivy2/local/org.chipsalliance/chisel_2.13/0.0.0+0-no-vcs-SNAPSHOT/ivys/ivy.xml
        not found: https://repo1.maven.org/maven2/org/chipsalliance/chisel_2.13/0.0.0+0-no-vcs-SNAPSHOT/chisel_2.13-0.0.0+0-no-vcs-SNAPSHOT.pom

--------------------------------------------

For additional information on library dependencies, see the docs at
https://mill-build.org/mill/Library_Dependencies.html

gcd.resolvedRunIvyDeps
Resolution failed for 1 modules:
--------------------------------------------
  org.chipsalliance:chisel_2.13:0.0.0+0-no-vcs-SNAPSHOT
        not found: /home/nixos/.ivy2/local/org.chipsalliance/chisel_2.13/0.0.0+0-no-vcs-SNAPSHOT/ivys/ivy.xml
        not found: https://repo1.maven.org/maven2/org/chipsalliance/chisel_2.13/0.0.0+0-no-vcs-SNAPSHOT/chisel_2.13-0.0.0+0-no-vcs-SNAPSHOT.pom

--------------------------------------------

For additional information on library dependencies, see the docs at
https://mill-build.org/mill/Library_Dependencies.html

Extra information

If I softlink ~/.ivy2 to a Nix artifact store (in this case, ln -d -s /nix/store/pw42h0wlzmdh5lw70zn3xvfwvjgghcji-chisel-mill-local-ivy/.ivy2/ ./.ivy2), then mill works fine, but this solution is neither elegant nor robust.

I have also tried to use nix-direnv to setup a VSCode remote environment, but it seems to suffer from the same problem. My current .envrc is as follows:

use flake

I am rather new to Nix, so feel free to point out if my question is silly or wrong. Any suggestions is welcome. Many thanks in advance. 😉

@Avimitin
Copy link
Contributor

We are now making efforts to make the mill dependencies resolve process much reproducible(see https://github.com/Avimitin/mill-ivy-fetcher and chipsalliance/t1#969), please wait until the workflow migrated to chisel-nix. This issue should be fixed after this workflow integrated into chisel-nix project. Currently I suggest checkout to revision 6a8222a.

CC @unlsycn.

@unlsycn
Copy link
Contributor

unlsycn commented Feb 26, 2025

As a workaround you can automatically link the .ivy2 directory in devShell:

diff --git a/templates/chisel/flake.nix b/templates/chisel/flake.nix
index fe19ac7..4091a61 100644
--- a/templates/chisel/flake.nix
+++ b/templates/chisel/flake.nix
@@ -28,6 +28,8 @@
         legacyPackages = pkgs;
         devShells.default = mkShell ({
           inputsFrom = [ gcd.gcd-compiled gcd.tb-dpi-lib ];
+          nativeBuildInputs = [ pkgs.xorg.lndir ];
+          shellHook = "lndir ${mill-dependencies.chisel}/.ivy2 ~/.ivy2";
           packages = [ cargo rustfmt rust-analyzer nixd nvfetcher ];
           RUST_SRC_PATH =
             "${rust.packages.stable.rustPlatform.rustLibSrc}";

CSharperMantle added a commit to CSharperMantle/chisel-nix-template-ivyfixed that referenced this issue Feb 27, 2025
Apply recommended workaround described in chipsalliance/chisel-nix#83 before an official fix is implemented.
CSharperMantle added a commit to CSharperMantle/chisel-nix-template-ivyfixed that referenced this issue Feb 27, 2025
Apply recommended workaround described in chipsalliance/chisel-nix#83 before an official fix is implemented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants