about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2022-05-01 11:48:57 +0200
committersternenseemann <sternenseemann@systemli.org>2022-05-01 11:48:57 +0200
commitbf3167a5371bcb9d527907a9d3ef0e31677b3f68 (patch)
tree965207625776328acb3dc888a67e52f73346a869
parent74de4dbbc455a06b6c44da7521ef5cbf11bafcbf (diff)
chore: move package definition into an overlay
This makes it easier to handle multiple packages in the repository so
that independent Nix expressions can all use them without a lot of ugly
passing `pkgs` around. By joining the nixpkgs fixpoint we can also
experiment with `pkgsStatic` etc. later.

BREAKING CHANGE:

default.nix now expects the path to nixpkgs as `nixpkgsSrc` instead of a
`pkgs` argument.
-rw-r--r--default.nix29
-rw-r--r--overlay.nix31
2 files changed, 36 insertions, 24 deletions
diff --git a/default.nix b/default.nix
index 6959e74..a991e4a 100644
--- a/default.nix
+++ b/default.nix
@@ -1,28 +1,9 @@
-{ pkgs ? import <nixpkgs> { } }:
-
-assert pkgs.lib.versionAtLeast pkgs.libschrift.version "0.10.1";
+{ nixpkgsSrc ? <nixpkgs> }:
 
 let
-  gi = pkgs.nix-gitignore;
-
-  buchstabensuppe = { stdenv, utf8proc, harfbuzz, libschrift, redo-c }:
-    stdenv.mkDerivation rec {
-      pname = "buchstabensuppe";
-      version = "unstable";
-
-      src = builtins.path {
-        path = ./.;
-        name = "buchstabensuppe-src";
-        filter = gi.gitignoreFilter (builtins.readFile ./.gitignore) ./.;
-      };
-
-      makeFlags = [ "PREFIX=${placeholder "out"}" ];
-
-      nativeBuildInputs = [ redo-c ];
-      buildInputs = [ utf8proc harfbuzz libschrift ];
-
-      doCheck = true;
-    };
+  pkgs = import nixpkgsSrc {
+    overlays = [ (import ./overlay.nix) ];
+  };
 in
 
-pkgs.callPackage buchstabensuppe { }
+pkgs.buchstabensuppe
diff --git a/overlay.nix b/overlay.nix
new file mode 100644
index 0000000..d516527
--- /dev/null
+++ b/overlay.nix
@@ -0,0 +1,31 @@
+self: super:
+
+let
+  gi = self.nix-gitignore;
+
+  buchstabensuppe = { stdenv, utf8proc, harfbuzz, libschrift, redo-c }:
+    stdenv.mkDerivation rec {
+      pname = "buchstabensuppe";
+      version = "unstable";
+
+      src = gi.gitignoreSource [
+        "default.nix"
+        "overlay.nix"
+        "bindings/"   # bindings we don't need for compilation
+      ] ./.;
+
+      makeFlags = [ "PREFIX=${placeholder "out"}" ];
+
+      nativeBuildInputs = [ redo-c ];
+      buildInputs = [ utf8proc harfbuzz libschrift ];
+
+      doCheck = true;
+    };
+
+in
+
+{
+  buchstabensuppe =
+    assert self.lib.versionAtLeast self.libschrift.version "0.10.1";
+    self.callPackage buchstabensuppe { };
+}