From 1d0a930d27477fc396eea709736fcfdfe0b317d5 Mon Sep 17 00:00:00 2001
From: Neil Mayhew <neil_mayhew@users.sourceforge.net>
Date: Sat, 27 Jun 2020 17:45:28 -0600
Subject: [PATCH] file-rename: Fix an incorrect platform test that
 misidentifies Darwin as Windows

This causes the script to be installed as `file-rename` instead of `rename` like
it is on other Unix systems. This in turn causes `wrapProgram` to fail when
building because it expects the wrapped program to be called `rename`.
---
 pkgs/tools/filesystems/file-rename/default.nix | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pkgs/tools/filesystems/file-rename/default.nix b/pkgs/tools/filesystems/file-rename/default.nix
index f9b6a941f68f..588295f77912 100644
--- a/pkgs/tools/filesystems/file-rename/default.nix
+++ b/pkgs/tools/filesystems/file-rename/default.nix
@@ -11,6 +11,12 @@ perlPackages.buildPerlPackage {
 
   nativeBuildInputs = [ makeWrapper ];
 
+  # Fix an incorrect platform test that misidentifies Darwin as Windows
+  postPatch = ''
+    substituteInPlace Makefile.PL \
+      --replace '/win/i' '/MSWin32/'
+  '';
+
   postInstall = ''
     wrapProgram $out/bin/rename \
       --prefix PERL5LIB : $out/${perlPackages.perl.libPrefix}