From e05a981d057a66b0e5885ac496039ebd4d6ca70d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Tue, 12 Sep 2023 16:32:10 +0200 Subject: [PATCH] xxd: reduce closure size by splitting it into it's own output --- .../manual/release-notes/rl-2405.section.md | 2 ++ pkgs/applications/editors/vim/common.nix | 24 ++++++++++++++----- pkgs/applications/editors/vim/default.nix | 2 +- pkgs/applications/editors/vim/full.nix | 4 ++-- pkgs/top-level/unixtools.nix | 4 ++-- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2405.section.md b/nixos/doc/manual/release-notes/rl-2405.section.md index 766a4ea2d99b..828c6a45b8ca 100644 --- a/nixos/doc/manual/release-notes/rl-2405.section.md +++ b/nixos/doc/manual/release-notes/rl-2405.section.md @@ -75,6 +75,8 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m - `services.resolved.fallbackDns` can now be used to disable the upstream fallback servers entirely by setting it to an empty list. To get the previous behaviour of the upstream defaults set it to null, the new default, instead. +- `xxd` has been moved from `vim` default output to its own output to reduce closure size. The canonical way to reference it across all platforms is `unixtools.xxd`. + - `services.avahi.nssmdns` got split into `services.avahi.nssmdns4` and `services.avahi.nssmdns6` which enable the mDNS NSS switch for IPv4 and IPv6 respectively. Since most mDNS responders only register IPv4 addresses, most users want to keep the IPv6 support disabled to avoid long timeouts. diff --git a/pkgs/applications/editors/vim/common.nix b/pkgs/applications/editors/vim/common.nix index b392cc0aa565..5ee964adbc09 100644 --- a/pkgs/applications/editors/vim/common.nix +++ b/pkgs/applications/editors/vim/common.nix @@ -2,6 +2,8 @@ rec { version = "9.0.2116"; + outputs = [ "out" "xxd" ]; + src = fetchFromGitHub { owner = "vim"; repo = "vim"; @@ -14,12 +16,21 @@ rec { hardeningDisable = [ "fortify" ]; - postPatch = - # Use man from $PATH; escape sequences are still problematic. - '' - substituteInPlace runtime/ftplugin/man.vim \ - --replace "/usr/bin/man " "man " - ''; + # Use man from $PATH; escape sequences are still problematic. + postPatch = '' + substituteInPlace runtime/ftplugin/man.vim \ + --replace "/usr/bin/man " "man " + ''; + + # man page moving is done in postFixup instead of postInstall otherwise fixupPhase moves it right back where it was + postFixup = '' + moveToOutput bin/xxd "$xxd" + moveToOutput share/man/man1/xxd.1.gz "$xxd" + for manFile in $out/share/man/*/man1/xxd.1*; do + # moveToOutput does not take full paths or wildcards... + moveToOutput "share/man/$(basename "$(dirname "$(dirname "$manFile")")")/man1/xxd.1.gz" "$xxd" + done + ''; meta = with lib; { description = "The most popular clone of the VI editor"; @@ -28,5 +39,6 @@ rec { maintainers = with maintainers; [ das_j equirosa ]; platforms = platforms.unix; mainProgram = "vim"; + outputsToInstall = [ "out" "xxd" ]; }; } diff --git a/pkgs/applications/editors/vim/default.nix b/pkgs/applications/editors/vim/default.nix index 6430e2275599..d04fa241ba73 100644 --- a/pkgs/applications/editors/vim/default.nix +++ b/pkgs/applications/editors/vim/default.nix @@ -15,7 +15,7 @@ in stdenv.mkDerivation { pname = "vim"; - inherit (common) version src postPatch hardeningDisable enableParallelBuilding enableParallelInstalling meta; + inherit (common) version outputs src postPatch hardeningDisable enableParallelBuilding enableParallelInstalling postFixup meta; nativeBuildInputs = [ gettext pkg-config ]; buildInputs = [ ncurses bash gawk ] diff --git a/pkgs/applications/editors/vim/full.nix b/pkgs/applications/editors/vim/full.nix index cfb8b84560cb..263f8d2984d0 100644 --- a/pkgs/applications/editors/vim/full.nix +++ b/pkgs/applications/editors/vim/full.nix @@ -66,7 +66,7 @@ in stdenv.mkDerivation { pname = "vim-full"; - inherit (common) version postPatch hardeningDisable enableParallelBuilding meta; + inherit (common) version outputs postPatch hardeningDisable enableParallelBuilding meta; src = builtins.getAttr source { default = common.src; # latest release @@ -181,7 +181,7 @@ in stdenv.mkDerivation { ln -sfn '${nixosRuntimepath}' "$out"/share/vim/vimrc ''; - postFixup = lib.optionalString wrapPythonDrv '' + postFixup = common.postFixup + lib.optionalString wrapPythonDrv '' wrapProgram "$out/bin/vim" --prefix PATH : "${python3}/bin" \ --set NIX_PYTHONPATH "${python3}/${python3.sitePackages}" ''; diff --git a/pkgs/top-level/unixtools.nix b/pkgs/top-level/unixtools.nix index 40faa7642129..bcbbd6799d88 100644 --- a/pkgs/top-level/unixtools.nix +++ b/pkgs/top-level/unixtools.nix @@ -174,8 +174,8 @@ let darwin = pkgs.darwin.basic_cmds; }; xxd = { - linux = pkgs.vim; - darwin = pkgs.vim; + linux = pkgs.vim.xxd; + darwin = pkgs.vim.xxd; }; };