claymager / idris2-pkgs

An unofficial Idris2 package repository for Nix
MIT License
45 stars 12 forks source link

Depending on locally defined packages #9

Closed bobbbay closed 2 years ago

bobbbay commented 3 years ago

Since buildIdris is now exposed to consumer flakes, it must be possible to add custom packages to a project (via an overlay (?)), that are then callable in a TOML file. To be completely honest, I'm not exactly certain the steps to do so, but here's exactly what I'd like to do:

# myproject/other-packages/some-package.toml
name = "some-package"
[ source ]
# etc...
# myproject/myproject.toml
[ depends ]
idrisLibs = [ "some-package" ]
# myproject/flake.nix
# ???

Am I overthinking this?

bobbbay commented 3 years ago

On a relatively different vein, I just noticed that an idrisPackages set exists on nixpkgs, which contains (one of) the packages I want to depend on (effects). However, it doesn't work when I add it to my TOML depends.idrisLibs. Out of sheer interest, why doesn't idris2-pkgs channel from these derivations as well?

EDIT: Oops, seems like that's only for Idris 1 :). Are there plans to get all of the derivations in idris2-pkgs into an official attribute set on nixpkgs? Would be pretty cool, in my opinion.

bobbbay commented 3 years ago

I have figured out to use callNix on an attrset containing the package. I cannot used callTOML because, well, it's not exposed :). So... I'm stuck on two points:

# myproject/myproject.toml
[ depends ]
idrisLibs = [ "some-package" ] # err: some-package doesn't exist

I have tried adding some-package to my pkgs.idrisPackages via an overlay, but that doesn't help the situation. Thoughts?

bobbbay commented 3 years ago

As an update, I managed to create an overlay that adds some-package to pkgs.idris2.packages, but it seems the call is internal to idris2-pkgs, because this doesn't help, either. Thoughts @claymager?

claymager commented 3 years ago

callTOML and idris2.packages (or ipkgs, as it is/was called in utils/callToml.nix) are mutually dependent. There's currently no way to inject new packages, short of just using callNix.

I've started sketching in my callToml-tweaks branch, but haven't had the chance to do more than basic tests with it yet.

bobbbay commented 3 years ago

callToml-tweaks looks really good! My only issue is that local doesn't work, pointing to the utils source directory instead of the project directory. Apart from that, thank you for the time you put in for this!

claymager commented 2 years ago

This feature is built into the new idrisPackage.