Merge pull request #53 from doronbehar/flake

Add a flake.nix
This commit is contained in:
Robert Hensing 2021-09-30 12:06:06 +02:00 committed by GitHub
commit 80463148cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 0 deletions

View file

@ -15,6 +15,30 @@ niv init
niv add hercules-ci/gitignore.nix
```
## With Flakes
Although Flakes usually process sources within the flake using the git fetcher, which takes care of ignoring in its own peculiar way, you can use gitignore.nix to filter sources outside of a flake. You can load flake-based expressions via `builtins.getFlake (toString ./.)` for example or via [`flake-compat`](https://github.com/edolstra/flake-compat).
```nix
# // flake.nix
{
inputs.gitignore = {
url = "github:hercules-ci/gitignore.nix";
# Use the same nixpkgs
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, /* other, inputs, */ gitignore }:
let
inherit (gitignore.lib) gitignoreSource;
in {
packages.x86_64.hello = mkDerivation {
name = "hello";
src = gitignoreSource ./vendored/hello;
};
};
}
```
## Plain Nix way
```nix

25
flake.lock generated Normal file
View file

@ -0,0 +1,25 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1632846328,
"narHash": "sha256-sFi6YtlGK30TBB9o6CW7LG9mYHkgtKeWbSLAjjrNTX0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2b71ddd869ad592510553d09fe89c9709fa26b2b",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

9
flake.nix Normal file
View file

@ -0,0 +1,9 @@
{
description = "Nix functions for filtering local git sources";
outputs = { self, nixpkgs }: {
lib = import ./default.nix {
inherit (nixpkgs) lib;
};
};
}