nmattia / niv

Easy dependency management for Nix projects
https://github.com/nmattia/niv
MIT License
1.58k stars 77 forks source link

Package ghc-8.10.4 not supported on aarch64-darwin #336

Closed Anton-4 closed 2 years ago

Anton-4 commented 2 years ago

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.

Anton-4 commented 2 years ago

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

nmattia commented 2 years ago

See also the discussion here, looks like there are some issues still: https://github.com/nmattia/niv/issues/332

Anton-4 commented 2 years ago

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.

nmattia commented 2 years ago

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!

Anton-4 commented 2 years ago

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

Anton-4 commented 2 years ago

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

Anton-4 commented 2 years ago

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.

nmattia commented 2 years ago

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

nmattia commented 2 years ago

Fixed in #339

Anton-4 commented 2 years ago

Thanks @nmattia :heart: