From ddeae20607fa53a95e309ec9719b120d3444974c Mon Sep 17 00:00:00 2001 From: SandaruKasa Date: Tue, 5 May 2026 00:56:04 +0300 Subject: [PATCH] yadm: allow omitting some dependencies --- pkgs/by-name/ya/yadm/package.nix | 49 +++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/pkgs/by-name/ya/yadm/package.nix b/pkgs/by-name/ya/yadm/package.nix index cac71480a38b..a3423c51e99b 100644 --- a/pkgs/by-name/ya/yadm/package.nix +++ b/pkgs/by-name/ya/yadm/package.nix @@ -26,8 +26,19 @@ installShellFiles, runCommand, yadm, -}: + # Templates: + withAwk ? true, + withEsh ? true, + withJ2 ? true, + + # Encryption: + withGpg ? true, + withOpenssl ? true, +}: +let + withTar = withGpg || withOpenssl; +in resholve.mkDerivation (finalAttrs: { pname = "yadm"; version = "3.5.0"; @@ -62,32 +73,32 @@ resholve.mkDerivation (finalAttrs: { scripts = [ "bin/yadm" ]; interpreter = "${bash}/bin/sh"; inputs = [ + bash + coreutils git - gnupg - openssl - gawk # see head comment # git-crypt # transcrypt - j2cli - esh - bash - coreutils - gnutar - ]; + ] + ++ lib.optional withGpg gnupg + ++ lib.optional withOpenssl openssl + ++ lib.optional withAwk gawk + ++ lib.optional withJ2 j2cli + ++ lib.optional withEsh esh + ++ lib.optional withTar gnutar; fake = { - external = if stdenv.hostPlatform.isCygwin then [ ] else [ "cygpath" ]; + external = lib.optional (!stdenv.hostPlatform.isCygwin) "cygpath" ++ lib.optional (!withTar) "tar"; }; fix = { - "$GPG_PROGRAM" = [ "gpg" ]; - "$OPENSSL_PROGRAM" = [ "openssl" ]; "$GIT_PROGRAM" = [ "git" ]; - "$AWK_PROGRAM" = [ "awk" ]; + "$GPG_PROGRAM" = lib.optional withGpg "gpg"; + "$OPENSSL_PROGRAM" = lib.optional withOpenssl "openssl"; + "$AWK_PROGRAM" = lib.optional withAwk "awk"; # see head comment # "$GIT_CRYPT_PROGRAM" = [ "git-crypt" ]; # "$TRANSCRYPT_PROGRAM" = [ "transcrypt" ]; - "$J2CLI_PROGRAM" = [ "j2" ]; - "$ESH_PROGRAM" = [ "esh" ]; + "$J2CLI_PROGRAM" = lib.optional withJ2 "j2"; + "$ESH_PROGRAM" = lib.optional withEsh "esh"; # not in nixpkgs (yet) # "$ENVTPL_PROGRAM" = [ "envtpl" ]; # "$LSB_RELEASE_PROGRAM" = [ "lsb_release" ]; @@ -100,6 +111,12 @@ resholve.mkDerivation (finalAttrs: { "$hook_command" = true; # ~git hooks? "exec" = [ "$YADM_BOOTSTRAP" ]; # yadm bootstrap script + "$GPG_PROGRAM" = !withGpg; + "$OPENSSL_PROGRAM" = !withOpenssl; + "$AWK_PROGRAM" = !withAwk; + "$J2CLI_PROGRAM" = !withJ2; + "$ESH_PROGRAM" = !withEsh; + # not in nixpkgs "$ENVTPL_PROGRAM" = true; "$LSB_RELEASE_PROGRAM" = true;