13 # Building from source on x86_64 fails (among other things) due to:
14 # error: cannot load underlying module for 'Darwin'
15 , fromSource ? (stdenv.system != "x86_64-darwin")
19 generated = swiftpm2nix.helpers ./generated;
25 description = "Tool for managing dock items";
26 homepage = "https://github.com/kcrawford/dockutil";
27 license = licenses.asl20;
28 maintainers = with maintainers; [ tboerger ];
29 mainProgram = "dockutil";
30 platforms = platforms.darwin;
33 buildFromSource = swiftPackages.stdenv.mkDerivation (finalAttrs: {
34 inherit pname version meta;
36 src = fetchFromGitHub {
39 rev = finalAttrs.version;
40 hash = "sha256-mmk4vVZhq4kt05nI/dDM1676FDWyf4wTSwY2YzqKsLU=";
44 # Patch sources so that they build with Swift CoreFoundation
45 # which differs ever so slightly from Apple's implementation.
46 substituteInPlace Sources/DockUtil/DockUtil.swift \
47 --replace-fail "URL(filePath:" \
48 "URL(fileURLWithPath:" \
49 --replace-fail "path(percentEncoded: false)" \
53 nativeBuildInputs = [ swift swiftpm ];
55 buildInputs = with darwin.apple_sdk.frameworks; [ Cocoa ];
57 configurePhase = generated.configure;
61 install -Dm755 .build/${stdenv.hostPlatform.darwinArch}-apple-macosx/release/dockutil -t $out/bin
66 installBinary = stdenvNoCC.mkDerivation (finalAttrs: {
67 inherit pname version;
70 url = "https://github.com/kcrawford/dockutil/releases/download/${finalAttrs.version}/dockutil-${finalAttrs.version}.pkg";
71 hash = "sha256-9g24Jz/oDXxIJFiL7bU4pTh2dcORftsAENq59S0/JYI=";
78 nativeBuildInputs = [ libarchive p7zip ];
88 install -Dm755 usr/local/bin/dockutil -t $out/bin
93 sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];