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

Overlay example #58

Closed
rsoeldner opened this issue Aug 1, 2018 · 11 comments
Closed

Overlay example #58

rsoeldner opened this issue Aug 1, 2018 · 11 comments

Comments

@rsoeldner
Copy link

Hey,

this is my first try using overlays, according to #53 this is the recommended way now.

It looks like nix is not able to find my app package,

nix-build release.nix 
error: attribute 'app' missing, at /Users/rsoeldner/work/haskell-nix-overlay/release.nix:11:12
(use '--show-trace' to show detailed location information)

do I still need to override haskell.packages ?
The default.nix was generated by cabal2nix . > default.nix

{ compiler ? "ghc802" }:

let
  a = self: super:
      {   
        app = super.callPackage ./default.nix;
      };  

  overlays = [a];
  pkgs = import <nixpkgs> { inherit overlays; };
in { app = pkgs.haskell.packages.${compiler}.app; }
@PierreR
Copy link

PierreR commented Aug 1, 2018

@rsoeldner You need to do something alike:

  a = self: super:
    {
        haskellPackages = super.haskellPackages.override {
          overrides = hself: hsuper:  {
             app = super.callPackage ./default.nix;
          };
      };
    }


@rsoeldner
Copy link
Author

@PierreR thank you, from what I understood from https://nbp.github.io/slides/NixCon/2017.NixpkgsOverlays/?full#p1-prior-overlays this all overrides will be replaced by overlays.

I struggle understanding what pieces fit together, Is there a documentation about overrides accepting a function with two arguments returning a set ?

In my shell.nix I want to add the same GHC version with hoogle enabled, there should be an easy way adding all packages to the hoogle search ?

@PierreR
Copy link

PierreR commented Aug 1, 2018

@rsoeldner The overlays is replacing the packageOverrides idioms, so this part:

config = {
    packageOverrides = pkgs: rec {

I doesn't replace the override attribute.

You can see this by yourself on the third slide ;-)

Some explanation about the override attribute can be found here.

@rsoeldner
Copy link
Author

@PierreR Thank you, this makes sense.

Currently I'm at:

release.nix

compiler ? "ghc822" }:

 let 
  overlays = [(import ./custom-overlay.nix)];
  pkgs = import <nixpkgs> 
  {
    inherit overlays;
  };  
in
  { app = pkgs.haskellPackages.app;
  }

with the custom-overlay.nix

  self: super:
  {
    haskellPackages = super.haskellPackages.override  {
      overrides = hself: hsuper:
      {   
        app = super.callPackage ./default.nix;
      };  
    };  
  }

and the shell.nix

(import ./release.nix {}).app.env

But entering the nix-shell yields

nix-shell 
error: value is a function while a set was expected, at /Users/rsoeldner/work/haskell-nix-overlay/shell.nix:1:1
(use '--show-trace' to show detailed location information)

Is this the right approach ?
And inside the custom-overlay.nix shouldn't it be a hsuper.callPackage ??? ?

@PierreR
Copy link

PierreR commented Aug 1, 2018

@rsoeldner yes it should be hsuper.callPackage. I made that mistake why trying to mimic your code sample.

@sboosali
Copy link

sboosali commented Aug 1, 2018 via email

@Gabriella439
Copy link
Owner

Yeah, custom-overlay.nix should be:

  self: super:
  {
    haskellPackages = super.haskellPackages.override  {
      overrides = hself: hsuper:
      {   
        app = hself.callPackage ./default.nix;
      };  
    };  
  }

If you use hsuper.callPackage then app won't pick up any overrides you make to its dependencies

@rsoeldner
Copy link
Author

@Gabriel439 this makes sense too.

nix-shell --show-trace
error: while evaluating the attribute 'app.env' at /Users/rsoeldner/work/haskell-nix-overlay/release.nix:10:5:
value is a function while a set was expected, at /Users/rsoeldner/work/haskell-nix-overlay/shell.nix:1:1

is there a need to pass hself to the app derivation like

app = hself.callPackage ./default.nix (inherit hself);

@sboosali
Copy link

sboosali commented Aug 2, 2018 via email

@rsoeldner
Copy link
Author

@sboosali right, default.nix was created by cabal2nix.
I don't get the problem entering the shell

@Gabriella439
Copy link
Owner

@rsoeldner: It's because callPackage needs an extra {} argument, so the correct override section is actually:

  self: super:
  {
    haskellPackages = super.haskellPackages.override  {
      overrides = hself: hsuper:
      {   
        app = hself.callPackage ./default.nix {}; # ← Note the `{}`
      };  
    };  
  }

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

4 participants