nmattia / niv

Easy dependency management for Nix projects

Home Page:https://github.com/nmattia/niv

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Package ghc-8.10.4 not supported on aarch64-darwin

Anton-4 opened this issue · comments

Trying to install master with:

nix-env -iA niv -f https://github.com/nmattia/niv/tarball/master \
    --substituters https://niv.cachix.org \
    --trusted-public-keys niv.cachix.org-1:X32PCg2e/zAm3/uD1ScqW2z/K0LtDyNV7RdaxIuLgQM=

Results in:

unpacking 'https://github.com/nmattia/niv/tarball/master'...
installing 'niv-0.2.19'
error: Package ‘ghc-8.10.4’ in /nix/store/4kf9qcy2g5zyzd9yxp7g1qpvn5i47kfb-nixpkgs-src/pkgs/development/compilers/ghc/8.10.4.nix:254 is not supported on ‘aarch64-darwin’, refusing to evaluate.

Updating to at least ghc-8.10.6 should fix this issue.
I did not see a ghc version defined in the code anywhere, so I was unable to fix the issue myself.

After further investigation, it looks like this would require unstable nix packages.

See also the discussion here, looks like there are some issues still: #332

My colleague @BrianHicks found the following workaround:

diff --git a/shell.nix b/shell.nix
--- a/shell.nix
+++ b/shell.nix
 
 let
   sources = import nix/sources.nix { };
-  pkgs = import sources.nixpkgs { };
+  pkgs = import sources.nixpkgs {
+    system = if builtins.currentSystem == "aarch64-darwin" then
+      "x86_64-darwin"
+    else
+      builtins.currentSystem;
+  };
 

  inputs = with pkgs; [
     # meta-tools
-    (import sources.niv { }).niv
+    (pkgs.callPackage sources.niv { }).niv
  ];

This is not an airtight solution and may introduce some other problems, but I'm posting it here in case it can help anyone.

Ah, looks like you're piggy backing on rosetta then? Arguably the shell.nix isn't great; you shouldn't have to tweak it to specify the system. It would be great to have system as an argument of default.nix and shell.nix. PR welcome!

I'd like to, but I am both a nix beginner and short on spare time.

Regarding potential problems using the workaround, this fixed it for me:

  • add extra-platforms = x86_64-darwin to /etc/nix/nix.conf (create the file if it does not exist)
  • install Rosetta 2: softwareupdate --install-rosetta
  • reboot

For any future readers; I ran into more problems with this approach down the road, so instead I forked niv to make it use unstable packages, which fixed my issues.

Thanks! I've created a PR to bump nixpkgs to the latest master. Would you mind giving it a try?

Fixed in #339

Thanks @nmattia ❤️