Skip to content

flakes: respect .ignore when excluding files copied to nix store #9996

Open

Description

@colemickens

Is your feature request related to a problem? Please describe.

Hi,

I'm switching to jj from git as my primary way of interacting with upstream git repos. (It's really good, i can't praise it enough). However, this causes some issues when I don't use a co-located git repo.

Nix decides that it's not a git repo (fair), and then proceeds to copy everything into the store, including otherwise .gitignore or .ignored files (unfortunate).

Besides this being bloaty/wasteful, this includes things like postgres state files, which are not able to be copied to the store.

Describe the solution you'd like

If a .ignore is present (maybe symlinked to .gitignore), nix will use that as an exclude filter when copying to the store.

Describe alternatives you've considered

Not much, I assume there's .hgignore support, or whatnot, this feels like an easy/safe win at first glance.

Additional context
n/a

Priorities

Add 👍 to issues you find important.

Activity

  1. added
    feature
    on Feb 12, 2024
  2. colemickens commented on Feb 12, 2024

    @colemickens
    MemberAuthor

    I suppose an alternative approach would be to support jj natively, and call upon it to pack the repo for import. Not sure what's the best way to approach this.

  3. colemickens commented on Feb 12, 2024

    @colemickens
    MemberAuthor

    I guess I'm a bit befuddled, what are other people doing that use flakes without git?

  4. edolstra commented on Feb 14, 2024

    @edolstra
    Member

    For non-Git/Mercurial flakes, there is no filtering mechanism right now.

    I wonder if we can use libgit2 for this, so we don't have to reimplement .gitignore parsing. git_ignore_path_is_ignored() almost does what we need but it requires a repository. We could create a temporary empty repo and copy the ignore file over...

    Alternatively, for jj repos that use the git storage backend, it shouldn't be too hard to get libgit2 to handle them (since it's really just a Git worktree with the .git directory in a weird place).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions