gytis-ivaskevicius/flake-utils-plus

channels.<nixpkgs>.overlaysBuilder doesn't work if supportedSystems contains more than one architecture

willruggiano opened this issue · 5 comments

Similar to #96, so feel free to close this if you feel it is a duplicate.

I have been trying to move my macOS system to nix-darwin, starting with home-manager for dotfiles and ran into a similar problem as the aforementioned issue when adding a package (which does not export an overlay);

channels.nixpkgs.overlaysBuilder = channels: [
  (final: prev: {
    emanote = inputs.emanote.defaultPackage.${prev.system};
  })
  ...
];

See here for full context.

This results in the same error as #96;

$ nix flake show     
...
error: a 'x86_64-darwin' with features {} is required to build '/nix/store/path/to/some.drv', but I am a 'x86_64-linux' with features {benchmark, big-parallel, kvm, nixos-test}

The error occurs regardless of the current platform, e.g. "x86_64-linux ... but I am a x86_64-darwin" if on macOS

I assume that I am just misusing overlaysBuilder and that there is a better way to accomplish what I am doing. I will add that I am fairly new to nix and very new to your library... so "user error" is highly likely :)

You seem to be using it as expected, BUT by the looks of things, the last nix update has caused similar issues. Have not looked into it yet

Oh right, for time being you can set supportedSystems to single architecture

Yeah, that is indeed what I have done to remediate the problem. Thanks for the quick reply!

Solution:

diff --git a/flake.lock b/flake.lock
index fb6dd9c..f273f6e 100644
--- a/flake.lock
+++ b/flake.lock
@@ -330,17 +330,17 @@
         "flake-utils": "flake-utils_3"
       },
       "locked": {
-        "lastModified": 1632420560,
-        "narHash": "sha256-8Tsa4Hp/CHCA6J8/E7EODhp75z5N1NBhFiOb3lBv/tI=",
+        "lastModified": 1636207264,
+        "narHash": "sha256-irsZoK5GERTMWgPzy3p1tAFc4JS+ktasvlWTK79Ixjc=",
         "owner": "gytis-ivaskevicius",
         "repo": "flake-utils-plus",
-        "rev": "4b1bcafcfcd78bd36ceabfe3872822ba5c7fcbe8",
+        "rev": "9651c19f895382702a6257c4da08d14a66488782",
         "type": "github"
       },
       "original": {
         "owner": "gytis-ivaskevicius",
-        "ref": "v1.3.0",
         "repo": "flake-utils-plus",
+        "rev": "9651c19f895382702a6257c4da08d14a66488782",
         "type": "github"
       }
     },
diff --git a/flake.nix b/flake.nix
index 5a960c6..6790046 100644
--- a/flake.nix
+++ b/flake.nix
@@ -3,7 +3,7 @@

   inputs = {
     nixpkgs.url = github:nixos/nixpkgs/nixpkgs-unstable;
-    utils.url = github:gytis-ivaskevicius/flake-utils-plus/v1.3.0;
+    utils.url = github:gytis-ivaskevicius/flake-utils-plus/9651c19f895382702a6257c4da08d14a66488782; # not yet merged version of fup

     nix.url = github:nixos/nix/master;
     nixos-hardware.url = github:nixos/nixos-hardware;
@@ -32,11 +32,13 @@
             inherit (lib') makeHome mapFilterAttrs mapModules reduceModules mapModulesRec reduceModulesRec;
           });

-        supportedSystems = [ "x86_64-linux" ];
+        supportedSystems = [ "x86_64-darwin" "x86_64-linux" ];
         channelsConfig.allowUnfree = true;

         channels.nixpkgs.overlaysBuilder = channels: [
-          (final: prev: {
+          #(final: prev: nixpkgs.lib.optionalAttrs (prev.system == "x86_64-darwin") {
+          # or
+          (final: prev: nixpkgs.lib.optionalAttrs (!prev.isFakePkgs or false) {
             emanote = inputs.emanote.defaultPackage.${prev.system};
           })
           self.overlay
           

Will close this issue since I don't think that anything else can be done here. Reopen in case you think I'm wrong