From f93da5b9ec80b0b58eea1a63198ab582bc4750d4 Mon Sep 17 00:00:00 2001 From: szymon Date: Wed, 30 Sep 2026 20:18:55 +0200 Subject: [PATCH] chore: add nix derivation --- README.md | 18 ++++++++++++++++ flake.lock | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 31 ++++++++++++++++++++++++++++ package.nix | 27 ++++++++++++++++++++++++ 4 files changed, 135 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 package.nix diff --git a/README.md b/README.md index 12fed61..cd809ee 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ - [Structure](#structure) - [Documentation](#documentation) - [Add to project](#add-to-project) + - [Nix flake](#nix-flake) - [Dependencies](#dependencies) - [Examples](#examples) - [Why?](#why) @@ -36,6 +37,23 @@ Type in: cargo add --git "https://github.com/szymon-jozef/libnotify-rs" ``` +### Nix flake +For nix users, there is also a flake inside. If you want to use it add this to your flake: + +```nix +inputs = { + libnotify-rs.url = "github:szymon-jozef/libnotify-rs"; +}; +``` + +And then to your derivation/devshell/wherever: + +```Nix +packages = [ + inputs.libnotify-rs.packages.${stdenv.system}.default +]; +``` + ## Dependencies To use this crate you need to have installed: - [libnotify](https://gitlab.gnome.org/GNOME/libnotify), duh (version 0.8.8 >= is supported) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6039de6 --- /dev/null +++ b/flake.lock @@ -0,0 +1,59 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1788450739, + "narHash": "sha256-glZLQlzIn1fXH6PazR2iUmTo7kzzyYSshrWhLS9TqCU=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "31729ca8cbdb4fa927b34e5f4353e6a83f39e993", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1790689126, + "narHash": "sha256-VyUI5WA3WdOB9kjb04A0pxE6XTWC6cG95ZkoPSv58F0=", + "rev": "b4fd65b198c599cbe814fcb9f42d25d021595ec9", + "type": "tarball", + "url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1082427.b4fd65b198c5/nixexprs.tar.zst" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1788057806, + "narHash": "sha256-DTQSMxzDWmT0zhguthvegnVkn7CFqGCv4IHCzk5ZUpM=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "596e2e3940e09b2abbeb03f75fa1828c57fcd72c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d07cb52 --- /dev/null +++ b/flake.nix @@ -0,0 +1,31 @@ +{ + description = "Rust bindings for libnotify"; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + }; + + outputs = + inputs@{ flake-parts, ... }: + # https://flake.parts/module-arguments.html + flake-parts.lib.mkFlake { inherit inputs; } ({ + flake = { + # Put your original flake attributes here. + }; + + systems = [ + "x86_64-linux" + ]; + + perSystem = { config, pkgs, ... }: { + # Recommended: move all package definitions here. + # e.g. (assuming you have a nixpkgs input) + # packages.foo = pkgs.callPackage ./foo/package.nix { }; + # packages.bar = pkgs.callPackage ./bar/package.nix { + # foo = config.packages.foo; + # }; + packages.default = pkgs.callPackage ./package.nix { }; + }; + }); +} diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..80f02d7 --- /dev/null +++ b/package.nix @@ -0,0 +1,27 @@ +{ + pkgs, + lib, +}: + +let + cargo = (fromTOML (builtins.readFile ./Cargo.toml)); +in + +pkgs.rustPlatform.buildRustPackage { + pname = cargo.package.name; + version = cargo.package.version; + + src = lib.cleanSource ./.; + + cargoLock.lockFile = ./Cargo.lock; + + nativeBuildInputs = with pkgs; [ + clang + pkg-config + rustPlatform.bindgenHook + ]; + + buildInputs = with pkgs; [ + libnotify.dev + ]; +}