summaryrefslogtreecommitdiffstats
path: root/pkgs
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@gmail.com>2024-06-02 22:24:34 +0200
committerGitHub <noreply@github.com>2024-06-02 22:24:34 +0200
commit4dd2b5f31c58533e1dd7755ef0967111cc36ef6b (patch)
treecbbe02ee131749085f2b3a9f341def692fd58978 /pkgs
parent095f1acb70302bd74cd5f3ab02a64bdfac36daa8 (diff)
parent453aff31c66ef414c7a6b82511bd79f648d76386 (diff)
Merge pull request #293032 from afh/update-refactor-dockutil
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/os-specific/darwin/dockutil/default.nix116
-rw-r--r--pkgs/os-specific/darwin/dockutil/generated/default.nix7
-rw-r--r--pkgs/os-specific/darwin/dockutil/generated/workspace-state.json25
3 files changed, 121 insertions, 27 deletions
diff --git a/pkgs/os-specific/darwin/dockutil/default.nix b/pkgs/os-specific/darwin/dockutil/default.nix
index 5e4187f07280..64a8a9844388 100644
--- a/pkgs/os-specific/darwin/dockutil/default.nix
+++ b/pkgs/os-specific/darwin/dockutil/default.nix
@@ -1,37 +1,99 @@
-{ lib, stdenv, fetchurl, libarchive, p7zip }:
-stdenv.mkDerivation rec {
- pname = "dockutil";
- version = "3.0.2";
-
- src = fetchurl {
- url =
- "https://github.com/kcrawford/dockutil/releases/download/${version}/dockutil-${version}.pkg";
- sha256 = "175137ea747e83ed221d60b18b712b256ed31531534cde84f679487d337668fd";
- };
-
- dontBuild = true;
-
- nativeBuildInputs = [ libarchive p7zip ];
+{ lib
+, stdenv
+, stdenvNoCC
+, fetchFromGitHub
+, fetchurl
+, swift
+, swiftpm
+, swiftpm2nix
+, swiftPackages
+, darwin
+, libarchive
+, p7zip
+# Building from source on x86_64 fails (among other things) due to:
+# error: cannot load underlying module for 'Darwin'
+, fromSource ? (stdenv.system != "x86_64-darwin")
+}:
- unpackPhase = ''
- 7z x $src
- bsdtar -xf Payload~
- '';
+let
+ generated = swiftpm2nix.helpers ./generated;
- installPhase = ''
- runHook preInstall
- mkdir -p $out/bin
- mkdir -p $out/usr/local/bin
- install -Dm755 usr/local/bin/dockutil -t $out/usr/local/bin
- ln -rs $out/usr/local/bin/dockutil $out/bin/dockutil
- runHook postInstall
- '';
+ pname = "dockutil";
+ version = "3.1.3";
meta = with lib; {
description = "Tool for managing dock items";
homepage = "https://github.com/kcrawford/dockutil";
license = licenses.asl20;
maintainers = with maintainers; [ tboerger ];
+ mainProgram = "dockutil";
platforms = platforms.darwin;
};
-}
+
+ buildFromSource = swiftPackages.stdenv.mkDerivation (finalAttrs: {
+ inherit pname version meta;
+
+ src = fetchFromGitHub {
+ owner = "kcrawford";
+ repo = "dockutil";
+ rev = finalAttrs.version;
+ hash = "sha256-mmk4vVZhq4kt05nI/dDM1676FDWyf4wTSwY2YzqKsLU=";
+ };
+
+ postPatch = ''
+ # Patch sources so that they build with Swift CoreFoundation
+ # which differs ever so slightly from Apple's implementation.
+ substituteInPlace Sources/DockUtil/DockUtil.swift \
+ --replace-fail "URL(filePath:" \
+ "URL(fileURLWithPath:" \
+ --replace-fail "path(percentEncoded: false)" \
+ "path"
+ '';
+
+ nativeBuildInputs = [ swift swiftpm ];
+
+ buildInputs = with darwin.apple_sdk.frameworks; [ Cocoa ];
+
+ configurePhase = generated.configure;
+
+ installPhase = ''
+ runHook preInstall
+ install -Dm755 .build/${stdenv.hostPlatform.darwinArch}-apple-macosx/release/dockutil -t $out/bin
+ runHook postInstall
+ '';
+ });
+
+ installBinary = stdenvNoCC.mkDerivation (finalAttrs: {
+ inherit pname version;
+
+ src = fetchurl {
+ url = "https://github.com/kcrawford/dockutil/releases/download/${finalAttrs.version}/dockutil-${finalAttrs.version}.pkg";
+ hash = "sha256-9g24Jz/oDXxIJFiL7bU4pTh2dcORftsAENq59S0/JYI=";
+ };
+
+ dontPatch = true;
+ dontConfigure = true;
+ dontBuild = true;
+
+ nativeBuildInputs = [ libarchive p7zip ];
+
+ unpackPhase = ''
+ 7z x $src
+ bsdtar -xf Payload~
+ '';
+
+ installPhase = ''
+ runHook preInstall
+ mkdir -p $out/bin
+ install -Dm755 usr/local/bin/dockutil -t $out/bin
+ runHook postInstall
+ '';
+
+ meta = meta // {
+ sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
+ };
+ });
+in
+if fromSource
+ then buildFromSource
+ else installBinary
diff --git a/pkgs/os-specific/darwin/dockutil/generated/default.nix b/pkgs/os-specific/darwin/dockutil/generated/default.nix
new file mode 100644
index 000000000000..32ffc68e4d2c
--- /dev/null
+++ b/pkgs/os-specific/darwin/dockutil/generated/default.nix
@@ -0,0 +1,7 @@
+# This file was generated by swiftpm2nix.
+{
+ workspaceStateFile = ./workspace-state.json;
+ hashes = {
+ "swift-argument-parser" = "1fpdgivmwdszggvx0ligs3vidv9kpp9777v649hs8w7vpcifc2ji";
+ };
+}
diff --git a/pkgs/os-specific/darwin/dockutil/generated/workspace-state.json b/pkgs/os-specific/darwin/dockutil/generated/workspace-state.json
new file mode 100644
index 000000000000..e24a74517af0
--- /dev/null
+++ b/pkgs/os-specific/darwin/dockutil/generated/workspace-state.json
@@ -0,0 +1,25 @@
+{
+ "object": {
+ "artifacts": [],
+ "dependencies": [
+ {
+ "basedOn": null,
+ "packageRef": {
+ "identity": "swift-argument-parser",
+ "kind": "remoteSourceControl",
+ "location": "https://github.com/apple/swift-argument-parser.git",
+ "name": "swift-argument-parser"
+ },
+ "state": {
+ "checkoutState": {
+ "revision": "82905286cc3f0fa8adc4674bf49437cab65a8373",
+ "version": "1.1.1"
+ },
+ "name": "sourceControlCheckout"
+ },
+ "subpath": "swift-argument-parser"
+ }
+ ]
+ },
+ "version": 6
+}