From 9f51e9102db8af97b0d7cb030000df35db52be62 Mon Sep 17 00:00:00 2001 From: Alex James Date: Sat, 22 Jun 2024 15:01:29 -0500 Subject: [PATCH] convmv: add Darwin support, reformat & migrate to pkgs/by-name Add support for Darwin to convmv. This required disabling the tests as APFS requires filenames to be valid UTF-8[^1]. This will also affect Linux if a filesystem that enforces valid UTF-8 is used (such as ZFS with `utf8only=on`). While we're here, make some changes to clean up the derivation: - Replace use of `rec` with `finalAttrs` pattern - Replace `fetchurl` with `fetchzip` - Added separate `man` output - Replace `preBuild` hook with explicit `makeFlags` initialization - Replace explicit `patchPhase` override with `prePatch` hook - Enable `strictDeps` - Disable redundant `patchShebangs` call (already done in `prePatch` hook) - Address lints from `nixpkgs-hammer` - Reformat with `nixfmt-rfc-style` - Migrate to pkgs/by-name [^1]: https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html --- pkgs/by-name/co/convmv/package.nix | 60 ++++++++++++++++++++++++++++++ pkgs/tools/misc/convmv/default.nix | 33 ---------------- pkgs/top-level/all-packages.nix | 2 - 3 files changed, 60 insertions(+), 35 deletions(-) create mode 100644 pkgs/by-name/co/convmv/package.nix delete mode 100644 pkgs/tools/misc/convmv/default.nix diff --git a/pkgs/by-name/co/convmv/package.nix b/pkgs/by-name/co/convmv/package.nix new file mode 100644 index 000000000000..b82edc118c77 --- /dev/null +++ b/pkgs/by-name/co/convmv/package.nix @@ -0,0 +1,60 @@ +{ + lib, + stdenv, + fetchzip, + perl, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "convmv"; + version = "2.05"; + + outputs = [ + "out" + "man" + ]; + + src = fetchzip { + url = "https://www.j3e.de/linux/convmv/convmv-${finalAttrs.version}.tar.gz"; + hash = "sha256-ts9xAPRGUoS0XBRTmpb+BlGW1hmGyUs+rQLyUEgiZ54="; + }; + + strictDeps = true; + + nativeBuildInputs = [ perl ]; + + buildInputs = [ perl ]; + + makeFlags = [ + "PREFIX=${placeholder "out"}" + "MANDIR=${placeholder "man"}/share/man" + ]; + + checkTarget = "test"; + + # testsuite.tar contains filenames that aren't valid UTF-8. Extraction of + # testsuite.tar will fail as APFS enforces that filenames are valid UTF-8. + doCheck = !stdenv.isDarwin; + + prePatch = + lib.optionalString finalAttrs.doCheck '' + tar -xf testsuite.tar + '' + + '' + patchShebangs --host . + ''; + + dontPatchShebangs = true; + + meta = with lib; { + description = "Converts filenames from one encoding to another"; + downloadPage = "https://www.j3e.de/linux/convmv/"; + license = with licenses; [ + gpl2Only + gpl3Only + ]; + maintainers = with maintainers; [ ]; + mainProgram = "convmv"; + platforms = platforms.unix; + }; +}) diff --git a/pkgs/tools/misc/convmv/default.nix b/pkgs/tools/misc/convmv/default.nix deleted file mode 100644 index 8d392f78f47f..000000000000 --- a/pkgs/tools/misc/convmv/default.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ lib, stdenv, fetchurl, perl }: - -stdenv.mkDerivation rec { - pname = "convmv"; - version = "2.05"; - - src = fetchurl { - url = "https://www.j3e.de/linux/convmv/convmv-${version}.tar.gz"; - sha256 = "19hwv197p7c23f43vvav5bs19z9b72jzca2npkjsxgprwj5ardjk"; - }; - - preBuild='' - makeFlags="PREFIX=$out" - ''; - - patchPhase='' - tar -xf testsuite.tar - patchShebangs . - ''; - - doCheck = true; - checkTarget = "test"; - - buildInputs = [ perl ]; - - meta = with lib; { - description = "Converts filenames from one encoding to another"; - platforms = platforms.linux ++ platforms.freebsd ++ platforms.cygwin; - maintainers = [ ]; - license = licenses.gpl2Plus; - mainProgram = "convmv"; - }; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 28f987a534bc..44a7ab0b03ba 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6988,8 +6988,6 @@ with pkgs; convfont = callPackage ../tools/misc/convfont { }; - convmv = callPackage ../tools/misc/convmv { }; - cpcfs = callPackage ../tools/filesystems/cpcfs { }; coreutils = callPackage ../tools/misc/coreutils { };