summary refs log tree commit diff
path: root/default.nix
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2024-08-19 21:41:48 +0300
committerVika <vika@fireburn.ru>2024-08-19 21:41:48 +0300
commit2b25e0454c60bb30b9a531b94836ca0d64e6c5e1 (patch)
treee62661a0d36ac32413dfa651dfe4ff85882accfb /default.nix
Initial Nix & Cargo boilerplate for a Relm4 project
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix44
1 files changed, 44 insertions, 0 deletions
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..24c43eb
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,44 @@
+{ craneLib, lib
+, pkg-config
+, gtk4, libadwaita, libpanel
+}:
+
+let
+  src = let
+    suffixes = [ ];
+    suffixFilter = name: type: let
+      base = baseNameOf (toString name);
+    in type == "directory" || lib.any (ext: lib.hasSuffix ext base) suffixes;
+
+  in lib.cleanSourceWith {
+    src = ./.; # The original, unfiltered source
+    filter = path: type: (suffixFilter path type) || (craneLib.filterCargoSources path type);
+    name = "source"; # Be reproducible, regardless of the directory name
+  };
+
+  args = {
+    # pname and version are read from Cargo.toml
+    inherit src;
+    strictDeps = true;
+
+    # cargoExtraArgs can be used to inject features
+
+    buildInputs = [ gtk4 libadwaita libpanel ];
+    nativeBuildInputs = [ pkg-config ];
+
+    meta = with lib.meta; {
+      maintainers = with lib.maintainers; [ vikanezrimaya ];
+      platforms = ["aarch64-linux" "x86_64-linux"];
+      mainProgram = "bowl";
+    };
+  };
+
+  cargoArtifacts = craneLib.buildDepsOnly args;
+  args' = args // { inherit cargoArtifacts; };
+
+in craneLib.buildPackage (args' // {
+  passthru = {
+    inherit cargoArtifacts;
+    clippy = craneLib.cargoClippy args';
+  };
+})