idris-lang / Idris2

A purely functional programming language with first class types
https://idris-lang.org/
Other
2.53k stars 375 forks source link

How to get a multipackage environment with nix. #1307

Open locallycompact opened 3 years ago

locallycompact commented 3 years ago

Hi. I've asked this on nixpkgs (https://github.com/NixOS/nixpkgs/issues/119175) but I imagine I'd find more answers here. I'm looking to get the idris.with-packages behaviour that I'm used to in nix.

I was able to build the pkg flake in this repository by instantiating it as a template, but not the pkgWithDep flake. I wanted to modify the pkgWithDep flake to just accept dependencies via fetchFromGitHub, but I don't see a mechanism to build those and install them to the correct directory, since everything on nixpkgs seems still specific to idris 1.

What is the right way to do this?

claymager commented 3 years ago

There isn't really a right way, yet. I'm working on it here (warning: unstable), but I'm holding off on adding it to nixpkgs until we get the next release. It requires some path changes that were made after v0.3.0.

locallycompact commented 3 years ago

Thank you very much. How do I call it?

claymager commented 3 years ago
# flake.nix
{
  inputs.userpkgs.url = github:claymager/nixpkgs/idris2;
  inputs.flake-utils.url = github:numtide/flake-utils;
  outputs = { self, userpkgs, flake-utils } :
    flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
      let pkgs = import userpkgs {inherit system; };
      in {
        devShell = pkgs.mkShell {
          buildInputs = [
            (pkgs.idris2.withPkgs (ps: [ ps.comonad ]) )
          ];
        };
      }
    );
}

I use something like that. As I said, unstable. and there's a few local paths in the branch atm for testing, but nix develop with that flake will grant you a shell with idris2-comonad.

You'll still need to explicitly call idris2 -p comonad in order to import Control.Comonad, if you're not using an ipkg file.

stefan-hoeck commented 3 years ago

Thanks, claymager, for your work on this nix-related stuff! I'm really looking forward to the day when we can use nix as a fully operating development environment for Idris2.

mokshasoft commented 12 months ago

Is there any change in Nix support for Idris2 yet?