Giter VIP home page Giter VIP logo

gitignore's Introduction

Make Nix precisely emulate gitignore

This goal of this project lets you include local sources in your Nix projects, while taking gitignore files into account.

Note that although this project does a good job at emulating git's behavior, it is not the same implementation!

Installation

Recommended with Niv

nix-env -iA niv -f https://github.com/nmattia/niv/tarball/master
niv init
niv add hercules-ci/gitignore

Plain Nix way

let
  gitignoreSrc = pkgs.fetchFromGitHub { 
    owner = "hercules-ci";
    repo = "gitignore";
    # put the latest commit sha of gitignore Nix library here:
    rev = "";
    # use what nix suggests in the mismatch message here:
    sha256 = "sha256:0000000000000000000000000000000000000000000000000000";
  };
  inherit (import gitignoreSrc { inherit (pkgs) lib; }) gitignoreSource;
in
  <your nix expression>

Usage

mkDerivation {
  name = "hello";
  src = gitignoreSource ./vendored/hello;
}

Features

  • Reads parent gitignores even if only pointed at a subdirectory
  • Source hashes only change when output changes
  • Not impacted by large or inaccessible ignored directories
  • Composes with cleanSourceWith
  • Reads user git configuration; no need to bother your team with your tool config.
  • Also works with restrict-eval enabled (if avoiding fetchFromGitHub)
  • No import from derivation ("IFD")

Comparison

Feature \ Implementation cleanSource siers siers recursive icetan Profpatsch numtide this project
Ignores .git ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
No special Nix configuration ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
No import from derivation ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Uses subdirectory gitignores ✔️ ✔️ ✔️
Uses parent gitignores ✔️ ? ✔️
Uses user gitignores ✔️ ✔️
Has a test suite ✔️ ✔️ ✔️ ? ✔️
Works with restrict-eval / Hydra ✔️ ✔️ ✔️ ✔️ ✔️
Descends into submodule correctly ? ? ? ? ✔️ ? ? #8
Included in nixpkgs ✔️ ✔️ ✔️
Legend
✔️ Supported
✔️ ? Probably supported
Not supported
? Probably not supported
- Not applicable or depends

Please open a PR if you've found another feature, determined any of the '?' or found an inaccuracy!

Contributing

This project isn't perfect (yet) so please submit test cases and fixes as pull requests. Before doing anything drastic, it's a good idea to open an issue first to discuss and optimize the approach.

Thanks

A great shoutout to @siers for writing the intial test suite and rule translation code!

gitignore's People

Contributors

roberth avatar domenkozar avatar siers avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.