srid / haskell-flake

A `flake-parts` Nix module for Haskell development
https://community.flake.parts/haskell-flake
MIT License
153 stars 19 forks source link

Support `nix flake show --option allow-import-from-derivation false` #95

Open roberth opened 1 year ago

roberth commented 1 year ago

This will allow inclusion of haskell-flake based projects into the NixOS flakes search.

I believe it can be done, but we'll have to make the set of attributes less dynamic, in particular we have to predict outputs, the names of the outputs.

lib.lazyDerivation https://github.com/NixOS/nixpkgs/commit/fce8b018f06431e7684b725a520416ff3862db9f produces an attrset that is a valid "derivation attrset" but only needs to evaluate the argument derivation for attributes that really need it, like drvPath, outPath, etc.

Our package definitions would have to look somewhat like

fix (pkg:
  lazyDerivation {
    derivation = callCabal2nix ...;
    meta = ... hardcoded or perhaps some `readFile` on `.cabal` sources if we dare ...;
    passthru = {
      inherit (pkg)
        overrideCabal
        overrideAttrs
        # ... any useful unconditional attributes
        ;
    };
  }
)

I can add multi-output support to lazyDerivation.

srid commented 1 year ago

This would be good to have (though nix flake show would still not work if systems has other platforms).

I can add multi-output support to lazyDerivation.

Not sure what this means?

roberth commented 1 year ago

though nix flake show would still not work if systems has other platforms

Why wouldn't it? The goal is to remove IFD from the attribute paths queried by that command. That should be sufficient to make it work for any system.

I can add multi-output support to lazyDerivation.

It doesn't handle derivations with multiple outputs correctly. Haskell packages do use multiple outputs by default, so I guess this issue is blocked on this.