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

Initializing a project from flake template fails #116

Open
eureka-cpu opened this issue Mar 10, 2025 · 4 comments
Open

Initializing a project from flake template fails #116

eureka-cpu opened this issue Mar 10, 2025 · 4 comments

Comments

@eureka-cpu
Copy link

Describe the bug
A clear and concise description of what the bug is.

I just wanted to start a new ocaml project but following the guide in the readme throws an error.

To Reproduce
Steps to reproduce the behavior.

nix flake init -t github:tweag/opam-nix
git init .
git add -A
nix develop
error:
       … while evaluating the attribute 'legacyPackages.aarch64-linux.ocaml-test'
         at /nix/store/01x5k4nlxcpyd85nnr0b9gm89rm8ff4x-source/lib.nix:44:11:
           43|         ${key} = (attrs.${key} or { }) // {
           44|           ${system} = ret.${key};
             |           ^
           45|         };while evaluating the attribute 'legacyPackages'
         at /nix/store/jfa59xcdf7fjyijd4q166qdikishkc0y-source/flake.nix:29:9:
           28|       {
           29|         legacyPackages = scope.overrideScope overlay;
             |         ^
           30|

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: attribute 'ocaml-test' missing
       at /nix/store/n4ch79chp544barfjwxmnyq1b9397sxy-source/src/opam.nix:759:16:
          758|       latestVersions = mapAttrs (_: last) (listRepo repo);
          759|       pkgdef = repo.passthru.pkgdefs.${name}.${latestVersions.${name}};
             |                ^
          760|

Expected behavior
A clear and concise description of what you expected to happen.

Expected to enter a devShell as stated in the article in the readme for getting started

Environment

  • OS name + version: aarch64-linux
  • Version of the code:

Additional context
Add any other context about the problem here.

@balsoft
Copy link
Collaborator

balsoft commented Mar 10, 2025

You also need to have an actual OCaml project in that directory as well, so that opam-nix has something to build. If you don't have any yet and want to initialize one, try:

nix-shell -p dune_3 --run "dune init proj ocaml_test ."

But be aware that for now (due to #115) you also have to disable subst:

echo "(subst disabled)" >> dune-project

@eureka-cpu
Copy link
Author

eureka-cpu commented Mar 10, 2025

It would be nice if there was a default where if a project doesn't yet exist you still get a devShell with the tools to create a project, similar to crane. Perhaps I should reference this in a new issue, though.

@balsoft
Copy link
Collaborator

balsoft commented Mar 12, 2025

I think it would be better addressed in documentation. You don't need much tooling besides some version of dune, and it doesn't make sense (at least to me) for opam-nix to explicitly provide it, especially given how it doesn't even save much typing (nix-shell -p dune_3 vs nix develop). I'll keep this issue open until I can update the documentation to reflect this.

@eureka-cpu
Copy link
Author

I think my only argument would be discover-ability, but documented is better than not 🙂

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

2 participants