jefdaj / bigtrees

Performant hash trees to dedup large collections of files.
GNU Affero General Public License v3.0
0 stars 0 forks source link

flake.nix devShell fails due to nixpkgs overlay bug #4

Open jefdaj opened 4 months ago

jefdaj commented 4 months ago

I have a static build working with a new flake.nix based on my old gander one, but when I add any package to devShell it fails with a message about Docopt being broken:

...
        devShell = project (executableSystemDepends ++ [
          # TODO *any* package here evaluates the broken docopt? weird
          hello
        ]);
...
...
       error: Package ‘docopt-0.7.0.8’ in /nix/store/z71lmgd0ydfnax1b13zbrls5idf1y7ak-source/pkgs/development/haskell-modules/hackage-packages.nix:92335 is marked as broken, refusing to evaluate.

       a) To temporarily allow broken packages, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_BROKEN=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowBroken = true; }
       in configuration.nix to override this.

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowBroken = true; }
       to ~/.config/nixpkgs/config.nix.

I think this is a manifestation of nixpkgs issue #235960: somehow the non-overridden docopt with broken = true is leaking into the final package set. And maybe also being evaluated when it shouldn't be? Will need to do some more detailed investigation.

jefdaj commented 4 months ago

One thing that appears to help is to rename the final package set as suggested here. I did a few layers of my* variables so I can be sure to get all the lib functions from them too:

...
        # This overlay is weird because it needs to work around a nixpkgs haskell bug:
        # https://github.com/NixOS/nixpkgs/issues/235960
        # The fix is to expose all new attributes "my*" for now.
        # This post pointed me in the right direction:
        # https://discourse.nixos.org/t/working-with-haskell-broken-packages/30126/5
        haskellOverlay = (final: prev: {
          myHaskell = final.lib.recursiveUpdate prev.haskell {
            myPackages = final.lib.recursiveUpdate prev.haskell.packages {
              myGhc = prev.haskell.packages.${myGhcVersion}.override {
                overrides = hFinal: hPrev: {
                  directory-tree = hFinal.callCabal2nix "directory-tree" directory-tree {}; 
                  docopt = prev.haskell.lib.markUnbroken hPrev.docopt;
                };
              };
            };
          };
        });
...
        in myHaskell.myPackages.myGhc.developPackage {
...
          modifier = (lib.trivial.flip lib.trivial.pipe) [
            addBuildTools
            myHaskell.lib.dontHaddock
            myHaskell.lib.enableStaticLibraries
            myHaskell.lib.justStaticExecutables
            myHaskell.lib.disableLibraryProfiling
            myHaskell.lib.disableExecutableProfiling
            confirmStaticBinaries
          ];
        };
...

So that's good progress!