From c642e25256d5ed976e932f136db98090b61db99d Mon Sep 17 00:00:00 2001 From: Skye Date: Thu, 14 Nov 2024 16:53:43 -0500 Subject: [PATCH] Read nix package name and version from `Cargo.toml` --- flake.nix | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/flake.nix b/flake.nix index ee9feee..c3702d6 100644 --- a/flake.nix +++ b/flake.nix @@ -11,24 +11,26 @@ devShells."${system}".default = pkgs.mkShell { packages = [ pkgs.mkvtoolnix-cli ]; }; - overlays.default = final: prev: { - subtitle-merge = final.rustPlatform.buildRustPackage { - name = "subtitle-merge"; - version = "0.1"; - src = ./.; - cargoLock.lockFile = ./Cargo.lock; - buildInputs = builtins.attrValues { - inherit (final) installShellFiles mkvtoolnix-cli; - }; + overlays.default = final: prev: + let cargo-toml = builtins.fromTOML (builtins.readFile ./Cargo.toml); + in { + subtitle-merge = final.rustPlatform.buildRustPackage { + pname = cargo-toml.package.name; + version = cargo-toml.package.version; + src = ./.; + cargoLock.lockFile = ./Cargo.lock; + buildInputs = builtins.attrValues { + inherit (final) installShellFiles mkvtoolnix-cli; + }; - postInstall = '' - installShellCompletion --cmd subtitle-merge \ - --bash ./target/release-tmp/build/*/out/subtitle-merge.bash \ - --fish ./target/release-tmp/build/*/out/subtitle-merge.fish \ - --zsh ./target/release-tmp/build/*/out/_subtitle-merge - ''; + postInstall = '' + installShellCompletion --cmd subtitle-merge \ + --bash ./target/release-tmp/build/*/out/subtitle-merge.bash \ + --fish ./target/release-tmp/build/*/out/subtitle-merge.fish \ + --zsh ./target/release-tmp/build/*/out/_subtitle-merge + ''; + }; }; - }; packages."${system}" = rec { inherit (overlays.default pkgs pkgs) subtitle-merge;