Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a file back after using gitIgnoreSource/cleanSourceWith #45

Open
codygman opened this issue Jun 9, 2020 · 3 comments
Open

Add a file back after using gitIgnoreSource/cleanSourceWith #45

codygman opened this issue Jun 9, 2020 · 3 comments

Comments

@codygman
Copy link

codygman commented Jun 9, 2020

I have the following:

    root = pkgs.lib.cleanSourceWith
      { filter = (path: type:
          ! (builtins.any
            (r: (builtins.match r (builtins.baseNameOf path)) != null)
            [
              "README.md"
              "notes"
              "ops"
              "tf"
              ".ghcid"
              ".dir-locals.el"
              ".semaphore"
            ])
        );
        src = gitignoreSource ./. ++ [];
      } ;

This worked alright until in lorri/issues#415 it was recommended that I make generating hpack part of my build process. So I did that like this:

        preConfigure = ''
          echo "generating cabal file from package.yaml..."
          hpack
           '';

But now I need to unignore the cabal file so that lorri will watch changes to it. Is there a way to do this? Can I compose a function to add a filepath back after cleanSourceWith?

@roberth
Copy link
Member

roberth commented Jun 10, 2020

You can achieve this by using gitignoreFilter directly.

Since you're using hpack, you might be interested in pre-commit-hooks.nix, which had hpack support merged recently.

@CMCDragonkai
Copy link

Can you provide an example in gitignoreFilter how to apply a list of files/paths you want to ignore on top of whatever gitignoreSource does? I'm trying to replicate the old nix-gitignore.gitignoreSource:

  src = nix-gitignore.gitignoreSource [
    ".git" 
    "/*.nix" 
    ".*"
  ] ./.;

@roberth
Copy link
Member

roberth commented Jul 1, 2022

You can modify the filter expression at the nix level with gitignoreFilter, but currently there's no interface for inserting extra rules, or for working off manually provided rules only. These features can be added of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants