From e216ce46cf2fa48e60d01deb872829572d18f60f Mon Sep 17 00:00:00 2001 From: Matthias Ahouansou Date: Thu, 15 Jan 2026 15:27:19 +0000 Subject: [PATCH] add flake --- .envrc | 1 + .gitignore | 4 +- flake.lock | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 54 ++++++++++++++++++++++++ 4 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 6c2e250..5e9961e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ /target **/*.rs.bk -.vscode \ No newline at end of file +.vscode + +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ecebe8d --- /dev/null +++ b/flake.lock @@ -0,0 +1,122 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "naersk", + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1752475459, + "narHash": "sha256-z6QEu4ZFuHiqdOPbYss4/Q8B0BFhacR8ts6jO/F/aOU=", + "owner": "nix-community", + "repo": "fenix", + "rev": "bf0d6f70f4c9a9cf8845f992105652173f4b617f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "naersk": { + "inputs": { + "fenix": "fenix", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1763384566, + "narHash": "sha256-r+wgI+WvNaSdxQmqaM58lVNvJYJ16zoq+tKN20cLst4=", + "owner": "nix-community", + "repo": "naersk", + "rev": "d4155d6ebb70fbe2314959842f744aa7cabbbf6a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1768364046, + "narHash": "sha256-PDFfpswLiuG/DcadTBb7dEfO3jX1fcGlCD4ZKSkC0M8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "ea30586ee015f37f38783006a9bc9e4aa64d7d61", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "naersk": "naersk", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1752428706, + "narHash": "sha256-EJcdxw3aXfP8Ex1Nm3s0awyH9egQvB2Gu+QEnJn2Sfg=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "591e3b7624be97e4443ea7b5542c191311aa141d", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6d9b542 --- /dev/null +++ b/flake.nix @@ -0,0 +1,54 @@ +{ + description = "MPRIS music scrobbler daemon"; + + inputs = { + # For packages we pull. + nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable"; + # So we don't have to manually definite things for each os/arch combination. + flake-utils.url = "github:numtide/flake-utils"; + # To cache rust crates. + naersk = { + url = "github:nix-community/naersk"; + # Use the same nixpkgs that we've defined above. + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { + self, + nixpkgs, + flake-utils, + naersk, + }: + flake-utils.lib.eachDefaultSystem ( + system: let + pkgs = nixpkgs.legacyPackages.${system}; + naerskLib = pkgs.callPackage naersk {}; + systemDeps = with pkgs; [openssl_3 dbus]; + in { + packages.default = naerskLib.buildPackage { + src = ./.; + buildInputs = systemDeps; + nativeBuildInputs = [pkgs.pkg-config]; + }; + + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; + [ + cargo + rustc + rustfmt + clippy + rust-analyzer + ] + ++ systemDeps; + + # Used for finding system dependencies. + nativeBuildInputs = [pkgs.pkg-config]; + + # Needed so programs like rust-analyzer can find the rust source code. + env.RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + }; + } + ); +}