[buoh] Use .gitignore to filter Nix source
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [buoh] Use .gitignore to filter Nix source
- Date: Wed, 4 May 2022 03:41:35 +0000 (UTC)
commit 1bacc1ba64d2b383f5b5398a7e341119d73a3739
Author: Jan Tojnar <jtojnar gmail com>
Date: Wed May 4 03:09:49 2022 +0200
Use .gitignore to filter Nix source
.gitignore | 7 +++++++
default.nix | 13 ++++++++-----
nix/sources.json | 12 ++++++++++++
3 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2e08368
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+# Meson files
+/_build
+/build
+
+# Nix files
+/result*
+/.direnv
diff --git a/default.nix b/default.nix
index 532f3f0..1d9ebc8 100644
--- a/default.nix
+++ b/default.nix
@@ -48,17 +48,20 @@ Or to speed up the build by not running the test suite:
let
inherit (pkgs) lib;
+
+ gitignore_nix = import sources."gitignore.nix" {
+ inherit lib;
+ };
+ inherit (gitignore_nix) gitignoreFilter;
+
in (if shell then pkgs.mkShell else pkgs.stdenv.mkDerivation) rec {
name = "buoh";
src =
let
- # Do not copy to the store:
- # - build directory, since Meson will want to use it
- # - .git directory, since it would unnecessarily bloat the source
- cleanSource = path: _: !lib.elem (builtins.baseNameOf path) [ "build" ".git" ];
+ sourcePath = ./.;
in
- if shell then null else builtins.filterSource cleanSource ./.;
+ if shell then null else builtins.filterSource (gitignoreFilter sourcePath) sourcePath;
# Dependencies for build platform
nativeBuildInputs = with pkgs; [
diff --git a/nix/sources.json b/nix/sources.json
index 023b88d..a846955 100644
--- a/nix/sources.json
+++ b/nix/sources.json
@@ -1,4 +1,16 @@
{
+ "gitignore.nix": {
+ "branch": "master",
+ "description": "Nix functions for filtering local git sources",
+ "homepage": "",
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "rev": "bff2832ec341cf30acb3a4d3e2e7f1f7b590116a",
+ "sha256": "0va0janxvmilm67nbl81gdbpppal4aprxzb25gp9pqvf76ahxsci",
+ "type": "tarball",
+ "url":
"https://github.com/hercules-ci/gitignore.nix/archive/bff2832ec341cf30acb3a4d3e2e7f1f7b590116a.tar.gz",
+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
+ },
"niv": {
"branch": "master",
"description": "Easy dependency management for Nix projects",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]