hercules-ci / gitignore.nix

Nix functions for filtering local git sources
The Unlicense
243 stars 20 forks source link

Remove cleanSourceWith from features list #14

Closed lukateras closed 5 years ago

lukateras commented 5 years ago

gitignoreSource does not compose with cleanSourceWith as of 6e7569637d699facfdcde91ab5c94bac06d39edc.

See discussion in #11. Another way to resolve this is to make cleanSourceWith compose one way only, with gitignoreSource always having to be the final filter (based on @yorickVP's workaround):

{ lib ? import <nixpkgs/lib> }:
let
  find-files = import ./find-files.nix { inherit lib; };

  constantSource = path:
    if path ? _isLibCleanSourceWith
    then builtins.path {
      name = "source";
      inherit (path) filter;
      path = path.origSrc;
    }
    else builtins.path {
      name = "source";
      inherit path;
    };
in
{
  inherit (find-files) gitignoreFilter;

  gitignoreSource = path:
    constantSource (lib.cleanSourceWith {
      filter = find-files.gitignoreFilter path;
      src = path;
    });
}

The problem with this is that it's not intuitive and still results in API breakage, while there are other ways to compose filters that are more explicit and work with deterministic source names.

roberth commented 5 years ago

Thanks! I've merged it to reflect the current situation. I'm confident that this can be fixed properly, see https://github.com/hercules-ci/gitignore/issues/15

lukateras commented 5 years ago

Sounds great! I assume the general idea is to make sure that cleanSourceWith produces deterministic store paths or works with builtins.path in its src. Looking forward to #15 :3