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

callCabal2nix: take "name" parameter as a function argument #22469

Merged
merged 1 commit into from Feb 6, 2017

Conversation

peti
Copy link
Member

@peti peti commented Feb 5, 2017

The callCabal2nix function cannot reliably determine the appropriate "name" for
the package it's processing. Attempts to derive this information have led to
plenty of evaluation errors, and so I'd like to go for the obvious and reliable
solution now and let the caller specify that bit of information.

Here is an example that demonstrates how to use callCabal2nix.

let
  pkgs = import <nixpkgs> {};
  src = pkgs.fetchFromGitHub {
    owner = "gtk2hs";
    repo = "gtk2hs";
    rev = "eee61d84edf1dd44f8d380d7d7cae2405de50124";
    sha256 = "12i53grimni0dyjqjydl120z5amcn668w4pfhl8dxscjh4a0l5nb";
  };
in
  pkgs.haskellPackages.callCabal2nix "gtkhs-tools" "${src}/tools" {}

The callCabal2nix function cannot reliably determine the appropriate "name" for
the package it's processing. Attempts to derive this information have led to
plenty of evaluation errors, and so I'd like to go for the obvious and reliable
solution now and let the caller specify that bit of information.

Here is an example that demonstrates how to use callCabal2nix.

    let
      pkgs = import <nixpkgs> {};
      src = pkgs.fetchFromGitHub {
        owner = "gtk2hs";
        repo = "gtk2hs";
        rev = "eee61d84edf1dd44f8d380d7d7cae2405de50124";
        sha256 = "12i53grimni0dyjqjydl120z5amcn668w4pfhl8dxscjh4a0l5nb";
      };
    in
      pkgs.haskellPackages.callCabal2nix "gtkhs-tools" "${src}/tools" {}
@k0001
Copy link
Contributor

k0001 commented Feb 5, 2017

@peti another alternative here is just hardcoding the name to be "src" or something like it. I don't think the name is particularly important, since this is not the final Haskell package name anyway. This would keep the call to callCabal2nix straightforward.

Also, on a related note, I was about to send this a pull-request with this commit, which solves this issue and does some other things as well. What do you think? k0001@aaca094

@peti
Copy link
Member Author

peti commented Feb 5, 2017

Another alternative here is just hardcoding the name to be "src".

I have mixed feelings about that. One one hand, I realize that the name is probably not very meaningful and that we can use any random string and it would make no difference for 99% of all cases.

On the other hand, I am unhappy about using a generic, non-descript name for many store paths generated by that function, because there may be occasions where this limitation will cause headaches for people who have such a store path and want to figure out what it is and where it comes from (i.e. because they're debugging a broken store or they're looking at the contents of a closure or whatever other use-case that I can't think of right now). To me, it feels wrong to call these things "src". I can't quite pin-point why that is. The extra effort of specifying the derivation name explicitly seems well worth it if I get accurately named store paths out it. I also feel like there's a nice symmetry in the APIs

callCabal2nix "foobar" "/bla/bla/foobar.cabal" {}

and

callHackage "foobar" "1.2.4" {}

There's something that looks consistent about that API.

@k0001
Copy link
Contributor

k0001 commented Feb 5, 2017

@peti ok, sounds good, I agree with this. The similarity between callHackage and callCabal2nix convinces me.

@3noch
Copy link
Contributor

3noch commented Feb 6, 2017

Go for it.

@peti peti merged commit 3346575 into NixOS:master Feb 6, 2017
@peti peti deleted the fix-callCabal2nix branch February 6, 2017 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants