From a09de6a90256438bbe75297a46f0784b03c49b1a Mon Sep 17 00:00:00 2001 From: Matteo Pacini Date: Fri, 28 Feb 2025 21:00:16 +0000 Subject: [PATCH] dedup-darwin: init at 0.0.6 --- .../de/dedup-darwin/build-date-fix.patch | 13 ++++++ .../by-name/de/dedup-darwin/no-codesign.patch | 18 ++++++++ pkgs/by-name/de/dedup-darwin/package.nix | 42 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 pkgs/by-name/de/dedup-darwin/build-date-fix.patch create mode 100644 pkgs/by-name/de/dedup-darwin/no-codesign.patch create mode 100644 pkgs/by-name/de/dedup-darwin/package.nix diff --git a/pkgs/by-name/de/dedup-darwin/build-date-fix.patch b/pkgs/by-name/de/dedup-darwin/build-date-fix.patch new file mode 100644 index 000000000000..0e70af1976bb --- /dev/null +++ b/pkgs/by-name/de/dedup-darwin/build-date-fix.patch @@ -0,0 +1,13 @@ +diff --git a/Makefile b/Makefile +index c9c56ec..75654f7 100644 +--- a/Makefile ++++ b/Makefile +@@ -29,7 +29,7 @@ CFLAGS += \ + -mtune=generic \ + -O \ + '-DVERSION="$(VERSION)"' \ +- '-DBUILD_DATE="$(shell date '+%Y%m%d')"' ++ '-DBUILD_DATE="19700101"' + + ENTITLEMENT_FLAGS = + diff --git a/pkgs/by-name/de/dedup-darwin/no-codesign.patch b/pkgs/by-name/de/dedup-darwin/no-codesign.patch new file mode 100644 index 000000000000..fd432bd33dbd --- /dev/null +++ b/pkgs/by-name/de/dedup-darwin/no-codesign.patch @@ -0,0 +1,18 @@ +Entitlements & code signature are only needed +for ASAN and other debugging tools. +See official README for more details. + +diff --git a/Makefile b/Makefile +index c9c56ec..36b81e0 100644 +--- a/Makefile ++++ b/Makefile +@@ -63,9 +63,6 @@ dedup.x86_64: CFLAGS += -target x86_64-apple-macos11 + + dedup dedup.arm dedup.x86_64: $(OBJECTS) + $(CC) $(CFLAGS) -o $@ $^ +- mv $@ $@.unsigned +- codesign -s - -v -f $(ENTITLEMENT_FLAGS) $@.unsigned +- mv $@.unsigned $@ + + dedup.universal: + rm -f *.o diff --git a/pkgs/by-name/de/dedup-darwin/package.nix b/pkgs/by-name/de/dedup-darwin/package.nix new file mode 100644 index 000000000000..9f177323afb5 --- /dev/null +++ b/pkgs/by-name/de/dedup-darwin/package.nix @@ -0,0 +1,42 @@ +{ + stdenv, + lib, + fetchFromGitHub, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "dedup-darwin"; + version = "0.0.6"; + + src = fetchFromGitHub { + owner = "ttkb-oss"; + repo = "dedup"; + tag = "release-${finalAttrs.version}"; + hash = "sha256-/qVrZVSVJPANMuKphbekB4p4ehjrOg6097yvjdIdl7I="; + }; + + patches = [ + ./build-date-fix.patch + ./no-codesign.patch + ]; + + postPatch = '' + # Fix the prefix + substituteInPlace Makefile --replace-fail \ + "PREFIX ?= /usr/local" "PREFIX ?= ${placeholder "out"}" + ''; + + preInstall = '' + # Install complains of missing directories, hence this fix. + mkdir -p $out/{bin,share/man/man1} + ''; + + meta = { + description = "Darwin utility to replace duplicate file data with a copy-on-write clone"; + homepage = "https://github.com/ttkb-oss/dedup"; + license = lib.licenses.bsd2; + maintainers = [ lib.maintainers.matteopacini ]; + platforms = lib.platforms.darwin; + mainProgram = "dedup"; + }; +})