From 6b20d38e0126b5fbc95fb34b9d7c9006e415cf2d Mon Sep 17 00:00:00 2001 From: Philip Taron Date: Wed, 29 Nov 2023 22:46:08 -0800 Subject: [PATCH 1/3] qrtool: 0.8.4 -> 0.8.5 I added `asciidoctor` to the nativeBuildInputs as I saw warnings that it wasn't found as I built the tool. I also stopped using `rec` syntax as the nixpkgs manual recommends [against it](https://nixos.org/manual/nixpkgs/unstable/#mkderivation-recursive-attributes). However, `rustPlatform.buildRustPackage` doesn't allow the use of `mkDerivation (finalAttrs: {` form, so it's just a simple `let` binding here. --- pkgs/by-name/qr/qrtool/package.nix | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/pkgs/by-name/qr/qrtool/package.nix b/pkgs/by-name/qr/qrtool/package.nix index 32cf7960825b..182bd1a4ea57 100644 --- a/pkgs/by-name/qr/qrtool/package.nix +++ b/pkgs/by-name/qr/qrtool/package.nix @@ -2,27 +2,31 @@ , stdenv , fetchFromGitHub , rustPlatform -}: - -rustPlatform.buildRustPackage rec { - pname = "qrtool"; - version = "0.8.4"; +, asciidoctor +}: let + name = "qrtool"; + version = "0.8.5"; +in rustPlatform.buildRustPackage { + pname = name; + inherit version; src = fetchFromGitHub { owner = "sorairolake"; - repo = "qrtool"; + repo = name; rev = "v${version}"; - sha256 = "sha256-FoWUGhNfVILpYxmsnSzRIM1+R9/xFxCF7W1sdiHaAiA="; + sha256 = "sha256-jrvNZGO1VIDo6Mz3NKda1C7qZUtF9T00CAFK8yoGWjc="; }; - cargoSha256 = "sha256-mtejnHCkN2krgFAneyyBpvbv5PZO3GigM2DJqrbHim4="; + cargoSha256 = "sha256-JOnvlabCr3fZsIIRc2qTjf50Ga83zL8Aoo2sqzMBs7g="; + + nativeBuildInputs = [ asciidoctor ]; meta = with lib; { maintainers = with maintainers; [ philiptaron ]; description = "An utility for encoding or decoding QR code"; license = licenses.asl20; - homepage = "https://sorairolake.github.io/qrtool/book/index.html"; - changelog = "https://sorairolake.github.io/qrtool/book/changelog.html"; - mainProgram = "qrtool"; + homepage = "https://sorairolake.github.io/${name}/book/index.html"; + changelog = "https://sorairolake.github.io/${name}/book/changelog.html"; + mainProgram = name; }; } From 3da9fa3ad3bdb6b7b3f4917b9bc0d47001de9e12 Mon Sep 17 00:00:00 2001 From: Philip Taron Date: Thu, 30 Nov 2023 09:11:31 -0800 Subject: [PATCH 2/3] qrtool: add shell completions and man pages --- pkgs/by-name/qr/qrtool/package.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/qr/qrtool/package.nix b/pkgs/by-name/qr/qrtool/package.nix index 182bd1a4ea57..31bc57b89ee3 100644 --- a/pkgs/by-name/qr/qrtool/package.nix +++ b/pkgs/by-name/qr/qrtool/package.nix @@ -3,6 +3,7 @@ , fetchFromGitHub , rustPlatform , asciidoctor +, installShellFiles }: let name = "qrtool"; version = "0.8.5"; @@ -19,7 +20,17 @@ in rustPlatform.buildRustPackage { cargoSha256 = "sha256-JOnvlabCr3fZsIIRc2qTjf50Ga83zL8Aoo2sqzMBs7g="; - nativeBuildInputs = [ asciidoctor ]; + nativeBuildInputs = [ asciidoctor installShellFiles ]; + + postInstall = '' + # Built by ./build.rs using `asciidoctor` + installManPage ./target/*/release/build/${name}*/out/*.? + + installShellCompletion --cmd ${name} \ + --bash <($out/bin/${name} --generate-completion bash) \ + --fish <($out/bin/${name} --generate-completion fish) \ + --zsh <($out/bin/${name} --generate-completion zsh) + ''; meta = with lib; { maintainers = with maintainers; [ philiptaron ]; From f5100278dfdce0dfa95f23513e6ff300a832125c Mon Sep 17 00:00:00 2001 From: Philip Taron Date: Thu, 30 Nov 2023 13:51:05 -0800 Subject: [PATCH 3/3] qrtool: use `rustPlatform.buildRustPackage rec {` Rather than `let ... in` syntax per feedback from @atalii --- pkgs/by-name/qr/qrtool/package.nix | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/pkgs/by-name/qr/qrtool/package.nix b/pkgs/by-name/qr/qrtool/package.nix index 31bc57b89ee3..6c9bd6982fd4 100644 --- a/pkgs/by-name/qr/qrtool/package.nix +++ b/pkgs/by-name/qr/qrtool/package.nix @@ -4,16 +4,15 @@ , rustPlatform , asciidoctor , installShellFiles -}: let - name = "qrtool"; +}: + +rustPlatform.buildRustPackage rec { + pname = "qrtool"; version = "0.8.5"; -in rustPlatform.buildRustPackage { - pname = name; - inherit version; src = fetchFromGitHub { owner = "sorairolake"; - repo = name; + repo = "qrtool"; rev = "v${version}"; sha256 = "sha256-jrvNZGO1VIDo6Mz3NKda1C7qZUtF9T00CAFK8yoGWjc="; }; @@ -24,20 +23,20 @@ in rustPlatform.buildRustPackage { postInstall = '' # Built by ./build.rs using `asciidoctor` - installManPage ./target/*/release/build/${name}*/out/*.? + installManPage ./target/*/release/build/qrtool*/out/*.? - installShellCompletion --cmd ${name} \ - --bash <($out/bin/${name} --generate-completion bash) \ - --fish <($out/bin/${name} --generate-completion fish) \ - --zsh <($out/bin/${name} --generate-completion zsh) + installShellCompletion --cmd qrtool \ + --bash <($out/bin/qrtool --generate-completion bash) \ + --fish <($out/bin/qrtool --generate-completion fish) \ + --zsh <($out/bin/qrtool --generate-completion zsh) ''; meta = with lib; { maintainers = with maintainers; [ philiptaron ]; - description = "An utility for encoding or decoding QR code"; + description = "A utility for encoding and decoding QR code images"; license = licenses.asl20; - homepage = "https://sorairolake.github.io/${name}/book/index.html"; - changelog = "https://sorairolake.github.io/${name}/book/changelog.html"; - mainProgram = name; + homepage = "https://sorairolake.github.io/qrtool/book/index.html"; + changelog = "https://sorairolake.github.io/qrtool/book/changelog.html"; + mainProgram = "qrtool"; }; }