From 1361757956ac49b89ec2027a2922f2c7f777efe6 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Sun, 21 Apr 2024 06:27:34 +0800 Subject: [PATCH 1/5] argc: format Nix expression with nixfmt (Nix RFC 166) --- pkgs/development/tools/argc/default.nix | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkgs/development/tools/argc/default.nix b/pkgs/development/tools/argc/default.nix index 89ee93b1c5d86..0a3a1f393db51 100644 --- a/pkgs/development/tools/argc/default.nix +++ b/pkgs/development/tools/argc/default.nix @@ -1,7 +1,8 @@ -{ lib -, rustPlatform -, fetchFromGitHub -, installShellFiles +{ + lib, + rustPlatform, + fetchFromGitHub, + installShellFiles, }: rustPlatform.buildRustPackage rec { @@ -31,7 +32,11 @@ rustPlatform.buildRustPackage rec { mainProgram = "argc"; homepage = "https://github.com/sigoden/argc"; changelog = "https://github.com/sigoden/argc/releases/tag/v${version}"; - license = with licenses; [ mit /* or */ asl20 ]; + license = with licenses; [ + mit + # or + asl20 + ]; maintainers = with maintainers; [ figsoda ]; }; } From c00d9adbaf767943d41b7b1471fbf1f1962b283b Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Sun, 21 Apr 2024 20:36:56 +0800 Subject: [PATCH 2/5] argc: move to pkgs/by-name --- .../tools/argc/default.nix => by-name/ar/argc/package.nix} | 0 pkgs/top-level/all-packages.nix | 2 -- 2 files changed, 2 deletions(-) rename pkgs/{development/tools/argc/default.nix => by-name/ar/argc/package.nix} (100%) diff --git a/pkgs/development/tools/argc/default.nix b/pkgs/by-name/ar/argc/package.nix similarity index 100% rename from pkgs/development/tools/argc/default.nix rename to pkgs/by-name/ar/argc/package.nix diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5f7d1fa296bbe..e228a607cb50e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4183,8 +4183,6 @@ with pkgs; aptdec = callPackage ../development/libraries/aptdec { }; - argc = callPackage ../development/tools/argc { }; - aria2 = callPackage ../tools/networking/aria2 { inherit (darwin.apple_sdk.frameworks) Security; }; From 0a58c62f7d5bdb61ad8f6903ec3ea3c44a384d8c Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Sat, 4 May 2024 03:08:39 +0800 Subject: [PATCH 3/5] argc: small refactorings Co-authored-by: Sandro --- pkgs/by-name/ar/argc/package.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/ar/argc/package.nix b/pkgs/by-name/ar/argc/package.nix index 0a3a1f393db51..6f62160048b9d 100644 --- a/pkgs/by-name/ar/argc/package.nix +++ b/pkgs/by-name/ar/argc/package.nix @@ -11,7 +11,7 @@ rustPlatform.buildRustPackage rec { src = fetchFromGitHub { owner = "sigoden"; - repo = pname; + repo = "argc"; rev = "v${version}"; hash = "sha256-Li/K5/SLG6JuoRJDz2DQoj1Oi9LQgZWHNvtZ1HVbj88="; }; @@ -28,7 +28,7 @@ rustPlatform.buildRustPackage rec { ''; meta = with lib; { - description = "A command-line options, arguments and sub-commands parser for bash"; + description = "Command-line options, arguments and sub-commands parser for bash"; mainProgram = "argc"; homepage = "https://github.com/sigoden/argc"; changelog = "https://github.com/sigoden/argc/releases/tag/v${version}"; From 60949c89cd88cc104a794e6a39dd89ff8593d8c5 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Sun, 21 Apr 2024 05:00:56 +0800 Subject: [PATCH 4/5] argc: support cross-compilation Use native argc to generate shell completion files when "$out/bin/argc" cannot be executed on the build platform. --- pkgs/by-name/ar/argc/package.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/ar/argc/package.nix b/pkgs/by-name/ar/argc/package.nix index 6f62160048b9d..dc7d565d93e16 100644 --- a/pkgs/by-name/ar/argc/package.nix +++ b/pkgs/by-name/ar/argc/package.nix @@ -1,10 +1,15 @@ { lib, + buildPackages, rustPlatform, + stdenv, fetchFromGitHub, installShellFiles, }: +let + canExecuteHost = stdenv.buildPlatform.canExecute stdenv.hostPlatform; +in rustPlatform.buildRustPackage rec { pname = "argc"; version = "1.14.0"; @@ -18,15 +23,19 @@ rustPlatform.buildRustPackage rec { cargoHash = "sha256-D1T9FWTvwKtAYoqFlR2OmLRLGWhPJ9D8J7lq/QKcBoM="; - nativeBuildInputs = [ installShellFiles ]; + nativeBuildInputs = [ installShellFiles ] ++ lib.optional (!canExecuteHost) buildPackages.argc; postInstall = '' + ARGC=${if canExecuteHost then ''''${!outputBin}/bin/argc'' else "argc"} + installShellCompletion --cmd argc \ - --bash <($out/bin/argc --argc-completions bash) \ - --fish <($out/bin/argc --argc-completions fish) \ - --zsh <($out/bin/argc --argc-completions zsh) + --bash <("$ARGC" --argc-completions bash) \ + --fish <("$ARGC" --argc-completions fish) \ + --zsh <("$ARGC" --argc-completions zsh) ''; + disallowedReferences = lib.optional (!canExecuteHost) buildPackages.argc; + meta = with lib; { description = "Command-line options, arguments and sub-commands parser for bash"; mainProgram = "argc"; From c0eb246672df563360e8b5b5c1c506639e165367 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Sun, 21 Apr 2024 20:33:26 +0800 Subject: [PATCH 5/5] argc: add passthru.tests.cross --- pkgs/by-name/ar/argc/package.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkgs/by-name/ar/argc/package.nix b/pkgs/by-name/ar/argc/package.nix index dc7d565d93e16..8c286ebff9e67 100644 --- a/pkgs/by-name/ar/argc/package.nix +++ b/pkgs/by-name/ar/argc/package.nix @@ -1,6 +1,7 @@ { lib, buildPackages, + pkgsCross, rustPlatform, stdenv, fetchFromGitHub, @@ -36,6 +37,20 @@ rustPlatform.buildRustPackage rec { disallowedReferences = lib.optional (!canExecuteHost) buildPackages.argc; + passthru = { + tests = { + cross = + ( + if stdenv.hostPlatform.isDarwin then + if stdenv.hostPlatform.isAarch64 then pkgsCross.x86_64-darwin else pkgsCross.aarch64-darwin + else if stdenv.hostPlatform.isAarch64 then + pkgsCross.gnu64 + else + pkgsCross.aarch64-multiplatform + ).argc; + }; + }; + meta = with lib; { description = "Command-line options, arguments and sub-commands parser for bash"; mainProgram = "argc";