From 31453d3f16cb1fcdbf60d934c19c9300ffdd37b8 Mon Sep 17 00:00:00 2001 From: zowoq <59103226+zowoq@users.noreply.github.com> Date: Fri, 18 Oct 2024 17:26:37 +1000 Subject: [PATCH] vfkit: build from source Co-authored-by: Mario Rodas (cherry picked from commit cd1ee59b419b8c962fbc29150737f890420d9e64) --- pkgs/by-name/vf/vfkit/package.nix | 49 +++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/pkgs/by-name/vf/vfkit/package.nix b/pkgs/by-name/vf/vfkit/package.nix index f51995d02c59..eae906003eee 100644 --- a/pkgs/by-name/vf/vfkit/package.nix +++ b/pkgs/by-name/vf/vfkit/package.nix @@ -1,31 +1,50 @@ { lib, - fetchurl, - stdenvNoCC, + apple-sdk_14, + buildGoModule, + darwin, + darwinMinVersionHook, + fetchFromGitHub, testers, + vfkit, }: -stdenvNoCC.mkDerivation (finalAttrs: { +buildGoModule rec { pname = "vfkit"; version = "0.5.1"; - src = fetchurl { - url = "https://github.com/crc-org/vfkit/releases/download/v${finalAttrs.version}/vfkit"; - hash = "sha256-at+KsvsKO359d4VUvcSuio2ej5hM6//U4Mj/jqXwhEc="; + src = fetchFromGitHub { + owner = "crc-org"; + repo = "vfkit"; + rev = "v${version}"; + hash = "sha256-9iPr9VhN60B6kBikdEIFAs5mMH+VcmnjGhLuIa3A2JU="; }; - dontUnpack = true; + vendorHash = "sha256-6O1T9aOCymYXGAIR/DQBWfjc2sCyU/nZu9b1bIuXEps="; - installPhase = '' - runHook preInstall + subPackages = [ "cmd/vfkit" ]; - install -Dm755 $src $out/bin/vfkit + ldflags = [ + "-s" + "-w" + "-X github.com/crc-org/vfkit/pkg/cmdline.gitVersion=${src.rev}" + ]; - runHook postInstall + nativeBuildInputs = [ + darwin.sigtool + ]; + + buildInputs = [ + apple-sdk_14 + (darwinMinVersionHook "11") + ]; + + postFixup = '' + codesign --entitlements vf.entitlements -f -s - $out/bin/vfkit ''; passthru.tests = { - version = testers.testVersion { package = finalAttrs.finalPackage; }; + version = testers.testVersion { package = vfkit; }; }; meta = { @@ -34,9 +53,7 @@ stdenvNoCC.mkDerivation (finalAttrs: { license = lib.licenses.asl20; maintainers = with lib.maintainers; [ sarcasticadmin ]; platforms = lib.platforms.darwin; - # Source build will be possible after darwin SDK 12.0 bump - # https://github.com/NixOS/nixpkgs/pull/229210 - sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; + sourceProvenance = [ lib.sourceTypes.fromSource ]; mainProgram = "vfkit"; }; -}) +}