Nixpkgs: Best way to install old versions of GHC?

Created on 7 Oct 2019  路  2Comments  路  Source: NixOS/nixpkgs

Issue description

I need to install GHC 8.0.2. I found this NUR repo that contains all GHC versions. (I was alternatively told to pin an old version of nixpkgs and get it from there--is there a good reason to chose option one over the other?)

I've tried to make an overlay that adds ghc802 to the haskell.compiler set like so:

  nixpkgs = {
    config = {
      allowUnfree = true;
    };
    overlays = [
      (self: super: {
        haskell.compiler = super.haskell.compiler // { ghc802 = self.nur.repos.mpickering.ghc.ghc802; } ;
        nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
          inherit pkgs;
        };
      })
    ];
  };

Unfortunately, nixos-rebuild switch --show-trace then yields this error:

[~]$ sudo nixos-rebuild switch  --show-trace                                                                        
[sudo] password for zfnmxt: 
building Nix...
building the system configuration...
error: while evaluating the attribute 'config.system.build.toplevel' at /home/zfnmxt/repos/nixpkgs/nixos/modules/system/activation/top-level.nix:274:5:
while evaluating 'foldr' at /home/zfnmxt/repos/nixpkgs/lib/lists.nix:52:20, called from /home/zfnmxt/repos/nixpkgs/nixos/modules/system/activation/top-level.nix:138:12:
while evaluating 'fold'' at /home/zfnmxt/repos/nixpkgs/lib/lists.nix:55:15, called from /home/zfnmxt/repos/nixpkgs/lib/lists.nix:59:8:
while evaluating 'showWarnings' at /home/zfnmxt/repos/nixpkgs/lib/trivial.nix:265:28, called from /home/zfnmxt/repos/nixpkgs/nixos/modules/system/activation/top-level.nix:135:10:
while evaluating 'foldr' at /home/zfnmxt/repos/nixpkgs/lib/lists.nix:52:20, called from /home/zfnmxt/repos/nixpkgs/lib/trivial.nix:265:33:
while evaluating 'fold'' at /home/zfnmxt/repos/nixpkgs/lib/lists.nix:55:15, called from /home/zfnmxt/repos/nixpkgs/lib/lists.nix:59:8:
while evaluating the attribute 'warnings' at undefined position:
while evaluating anonymous function at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:75:45, called from undefined position:
while evaluating the attribute 'value' at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:336:9:
while evaluating the option `warnings':
while evaluating the attribute 'isDefined' at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:373:5:
while evaluating the attribute 'values' at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:362:9:
while evaluating the attribute 'values' at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:456:7:
while evaluating anonymous function at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:348:28, called from /home/zfnmxt/repos/nixpkgs/lib/modules.nix:348:17:
while evaluating 'dischargeProperties' at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:415:25, called from /home/zfnmxt/repos/nixpkgs/lib/modules.nix:349:62:
while evaluating the attribute 'value' at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:234:44:
while evaluating anonymous function at /home/zfnmxt/repos/nixpkgs/lib/attrsets.nix:234:10, called from undefined position:
while evaluating anonymous function at /home/zfnmxt/repos/nixpkgs/nixos/modules/system/boot/systemd.nix:775:51, called from /home/zfnmxt/repos/nixpkgs/lib/attrsets.nix:234:16:
while evaluating 'optional' at /home/zfnmxt/repos/nixpkgs/lib/lists.nix:254:20, called from /home/zfnmxt/repos/nixpkgs/nixos/modules/system/boot/systemd.nix:776:7:
while evaluating the attribute 'serviceConfig.Type' at undefined position:
while evaluating anonymous function at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:75:45, called from undefined position:
while evaluating the attribute 'value' at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:336:9:
while evaluating the option `systemd.services.tlp.serviceConfig':
while evaluating the attribute 'mergedValue' at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:368:5:
while evaluating anonymous function at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:368:32, called from /home/zfnmxt/repos/nixpkgs/lib/modules.nix:368:19:
while evaluating 'merge' at /home/zfnmxt/repos/nixpkgs/lib/types.nix:283:20, called from /home/zfnmxt/repos/nixpkgs/lib/modules.nix:371:8:
while evaluating 'filterAttrs' at /home/zfnmxt/repos/nixpkgs/lib/attrsets.nix:124:23, called from /home/zfnmxt/repos/nixpkgs/lib/types.nix:284:35:
while evaluating anonymous function at /home/zfnmxt/repos/nixpkgs/lib/attrsets.nix:125:29, called from /home/zfnmxt/repos/nixpkgs/lib/attrsets.nix:125:18:
while evaluating anonymous function at /home/zfnmxt/repos/nixpkgs/lib/types.nix:284:51, called from /home/zfnmxt/repos/nixpkgs/lib/attrsets.nix:125:62:
while evaluating the attribute 'ExecStart' at /home/zfnmxt/repos/nixpkgs/lib/attrsets.nix:344:7:
while evaluating anonymous function at /home/zfnmxt/repos/nixpkgs/lib/types.nix:284:86, called from /home/zfnmxt/repos/nixpkgs/lib/attrsets.nix:344:15:
while evaluating the attribute 'optionalValue' at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:375:5:
while evaluating the attribute 'values' at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:362:9:
while evaluating the attribute 'values' at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:456:7:
while evaluating anonymous function at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:348:28, called from /home/zfnmxt/repos/nixpkgs/lib/modules.nix:348:17:
while evaluating 'dischargeProperties' at /home/zfnmxt/repos/nixpkgs/lib/modules.nix:415:25, called from /home/zfnmxt/repos/nixpkgs/lib/modules.nix:349:62:
while evaluating the attribute 'value' at /home/zfnmxt/repos/nixpkgs/lib/types.nix:288:60:
while evaluating the attribute 'nativeBuildInputs' of the derivation 'tlp-1.2.2' at /home/zfnmxt/repos/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:191:11:
while evaluating 'getOutput' at /home/zfnmxt/repos/nixpkgs/lib/attrsets.nix:464:23, called from undefined position:
attribute 'lib' missing, at /home/zfnmxt/repos/nixpkgs/pkgs/top-level/all-packages.nix:10079:16

where /home/zfnmxt/repos/nixpkgs/pkgs/top-level/all-packages.nix:10079:

  shellcheck = haskell.lib.justStaticExecutables haskellPackages.ShellCheck;

It seems like somehow I've overwritten the haskell attribute set or something. What am I doing wrong? Is there a better way?

Thanks a lot!

Technical details

Please run nix run nixpkgs.nix-info -c nix-info -m and paste the result.

[~]$ nix run nixpkgs.nix-info -c nix-info -m                                                   
 - system: `"x86_64-linux"`
 - host os: `Linux 4.19.76, NixOS, 20.03.git.441638e (Markhor)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3`
 - channels(zfnmxt): `""`
 - channels(root): `"nixos-19.09pre183392.83ba5afcc96, nixos-hardware"`
 - nixpkgs: `/home/zfnmxt/repos/nixpkgs`
question haskell

All 2 comments

@zfnmxt

It seems like somehow I've overwritten the haskell attribute set or something. What am I doing wrong? Is there a better way?

I think this is the problem you're seeing.

There is a section in the nixpkgs manual about this:

https://nixos.org/nixpkgs/manual/#how-to-override-package-versions-in-a-compiler-specific-package-set

The part that starts with "This code is a little crazy" is an explanation of the problem you're seeing.

I need to install GHC 8.0.2. I found this NUR repo that contains all GHC versions. (I was alternatively told to pin an old version of nixpkgs and get it from there--is there a good reason to chose option one over the other?)

It really depends. If you need a whole Haskell package set, you need to get it from an old nixpkgs. However, if all you want is the compiler, you can get it from old-ghc-nix or from old nixpkgs.

I don't know if there is really a good reason to pick one over the other.

old-ghc-nix:

  • Solely maintained by @mpickering, who is a respected member of the Haskell community and GHC contributor.
  • GHC is not built from source.
  • There isn't really a cache (but it doesn't matter because the GHCs are not built from source).
  • Not so many users? (More likely for there to be bugs????)
  • Only goes back to ghc-8.0.

old nixpkgs:

  • Sometimes no longer maintained. Old versions don't get updates for the most part. For instance, https://howoldis.herokuapp.com/ suggests that the nixos-18.09 channel hasn't updated for the past 5 months or so. However, it does look like there have been commits to the release-18.09 branch recently. Old releases are disabled on Hydra after a while. For example, Hydra doesn't even build nixos-17.09 anymore.
  • GHC is built from source.
  • There is sometimes a cache, but I don't know what would happen if you went back to really old versions of nixpkgs. I just randomly checked ghc-7.6.3 from nixpkgs-17.09, and it does still appear to be in the cache.
  • Lots of users (although old versions of nixpkgs probably don't have many users anymore).
  • Goes back really far with lots of GHC versions. For instance, I randomly checked nixpkgs-17.09, and it has back to ghc-7.0.4.

@cdepillabout Thank you very much for your informative reply!

My issue was indeed the bit described in the manual section you linked. This modified overlay worked:

(self: super: {
        haskell = super.haskell // {
          compiler = super.haskell.compiler // {
            ghc802 = self.nur.repos.mpickering.ghc.ghc802;
          };
        };
        nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
          inherit pkgs;
        };
      });

And thanks for your nice comparison of old-ghc-nix and old nixpkgs. I'm using the older GHC version for a stack project, so I only need the compiler and am going to stick with old-ghc-nix for now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomberek picture tomberek  路  3Comments

teto picture teto  路  3Comments

grahamc picture grahamc  路  3Comments

copumpkin picture copumpkin  路  3Comments

domenkozar picture domenkozar  路  3Comments