From eeb00de3bb5e510117da64e0fbbc2b93da0d3df7 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Sun, 9 Mar 2025 18:28:33 +0100 Subject: [PATCH] pdisk: Modernise - Switch to finalAttrs - Don't use pname in src args - src.rev -> src.tag - Use --replace-fail - Enable strictDeps - Drop meta-wide "with lib" - Add meta.mainProgram - Migrate to pkgs/by-name --- .../pd/pdisk/package.nix} | 41 +++++++++---------- pkgs/top-level/all-packages.nix | 4 -- 2 files changed, 19 insertions(+), 26 deletions(-) rename pkgs/{tools/system/pdisk/default.nix => by-name/pd/pdisk/package.nix} (76%) diff --git a/pkgs/tools/system/pdisk/default.nix b/pkgs/by-name/pd/pdisk/package.nix similarity index 76% rename from pkgs/tools/system/pdisk/default.nix rename to pkgs/by-name/pd/pdisk/package.nix index 43e2ef61d70d..faf97b83f5d0 100644 --- a/pkgs/tools/system/pdisk/default.nix +++ b/pkgs/by-name/pd/pdisk/package.nix @@ -5,18 +5,16 @@ fetchpatch, installShellFiles, libbsd, - CoreFoundation, - IOKit, }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "pdisk"; version = "0.9"; src = fetchFromGitHub { owner = "apple-oss-distributions"; - repo = pname; - rev = "${pname}-${lib.versions.minor version}"; + repo = "pdisk"; + tag = "pdisk-${lib.versions.minor finalAttrs.version}"; hash = "sha256-+gBgnk/1juEHE0nXaz7laUaH7sxrX5SzsLGr0PHsdHs="; }; @@ -46,25 +44,22 @@ stdenv.mkDerivation rec { postPatch = '' substituteInPlace makefile \ - --replace 'cc' '${stdenv.cc.targetPrefix}cc' + --replace-fail 'cc' '${stdenv.cc.targetPrefix}cc' '' + lib.optionalString stdenv.hostPlatform.isDarwin '' substituteInPlace makefile \ - --replace '-lbsd' '-framework CoreFoundation -framework IOKit' + --replace-fail '-lbsd' '-framework CoreFoundation -framework IOKit' ''; + strictDeps = true; + nativeBuildInputs = [ installShellFiles ]; - buildInputs = - lib.optionals (!stdenv.hostPlatform.isDarwin) [ - libbsd - ] - ++ lib.optionals (stdenv.hostPlatform.isDarwin) [ - CoreFoundation - IOKit - ]; + buildInputs = lib.optionals (!stdenv.hostPlatform.isDarwin) [ + libbsd + ]; env.NIX_CFLAGS_COMPILE = "-D_GNU_SOURCE"; @@ -73,8 +68,9 @@ stdenv.mkDerivation rec { installPhase = '' runHook preInstall - install -Dm755 cvt_pt $out/bin/cvt_pt - install -Dm755 pdisk $out/bin/pdisk + for exe in pdisk cvt_pt; do + install -Dm755 -t $out/bin $exe + done installManPage pdisk.8 install -Dm644 pdisk.html $out/share/doc/pdisk/pdisk.html @@ -82,14 +78,15 @@ stdenv.mkDerivation rec { runHook postInstall ''; - meta = with lib; { + meta = { description = "Low-level Apple partition table editor for Linux, OSS Apple version"; homepage = "https://github.com/apple-oss-distributions/pdisk"; - license = with licenses; [ + license = with lib.licenses; [ hpnd # original license statements seems to match this (in files that are shared with mac-fdisk) apple-psl10 # new files ]; - maintainers = with maintainers; [ OPNA2608 ]; - platforms = platforms.unix; + mainProgram = "pdisk"; + maintainers = with lib.maintainers; [ OPNA2608 ]; + platforms = lib.platforms.unix; }; -} +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 94c4bb31d57c..b45ebfd14f5f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3574,10 +3574,6 @@ with pkgs; gzip = callPackage ../tools/compression/gzip { }; - pdisk = callPackage ../tools/system/pdisk { - inherit (darwin.apple_sdk.frameworks) CoreFoundation IOKit; - }; - plplot = callPackage ../development/libraries/plplot { inherit (darwin.apple_sdk.frameworks) Cocoa; };