default.nix (2684B)
1 { lib, stdenv, buildGoModule, fetchFromGitHub, fetchurl }: 2 3 let 4 arch = lib.head (lib.splitString "-" stdenv.hostPlatform.system); 5 # Check LIMA_URL in Makefile 6 lima = { 7 "x86_64-darwin" = fetchurl { 8 url = "https://deps.runfinch.com/${lib.replaceStrings [ "_" ] [ "-" ] arch}/lima-and-qemu.macos-${arch}.1701821611.tar.gz"; 9 hash = "sha256-mXBQLptj7hpPWGZXMnxDORVq3Zti/yYyW+Udm/FF9UQ="; 10 }; 11 "aarch64-darwin" = fetchurl { 12 url = "https://deps.runfinch.com/${lib.replaceStrings [ "_" ] [ "-" ] arch}/lima-and-qemu.macos-${arch}.1701821611.tar.gz"; 13 hash = "sha256-6Ll2CUwGJKUl8vxgdDx4Xm6O2WMYGJxMX6mLHJSvtT8="; 14 }; 15 }.${stdenv.hostPlatform.system}; 16 # Check FINCH_OS_BASENAME in Makefile 17 os = { 18 "x86_64-darwin" = fetchurl { 19 url = "https://dl.fedoraproject.org/pub/fedora/linux/releases/38/Cloud/${arch}/images/Fedora-Cloud-Base-38-1.6.${arch}.qcow2"; 20 hash = "sha256-0zRnBAH/PVtBKfzGYs9k9ablaCKK9ZB2zESaSUUxhII="; 21 }; 22 "aarch64-darwin" = fetchurl { 23 url = "https://dl.fedoraproject.org/pub/fedora/linux/releases/38/Cloud/${arch}/images/Fedora-Cloud-Base-38-1.6.${arch}.qcow2"; 24 hash = "sha256-0zRnBAH/PVtBKfzGYs9k9ablaCKK9ZB2zESaSUUxhII="; 25 }; 26 }.${stdenv.hostPlatform.system}; 27 in 28 buildGoModule rec { 29 pname = "finch"; 30 version = "1.1.2"; 31 32 src = fetchFromGitHub { 33 owner = "runfinch"; 34 repo = "finch"; 35 rev = "v${version}"; 36 hash = "sha256-Pjuzwzo+nihAJ8Z6d3nqg7V1PyS4n61L8MhXOUAkMNc="; 37 fetchSubmodules = true; 38 }; 39 40 vendorHash = "sha256-AwTcjCTZZ9qF2yGmoBJrOiDUN0Gpw/fa2wGTiOZQAKc="; 41 42 subPackages = [ "cmd/finch" ]; 43 44 ldflags = [ 45 "-X github.com/runfinch/finch/pkg/version.Version=${version}" 46 ]; 47 48 doCheck = false; 49 50 preCheck = '' 51 export HOME=$TMPDIR 52 ''; 53 54 postInstall = '' 55 mkdir -p $out/Applications/Finch/{bin,lima,os} 56 mv $out/bin/finch $out/Applications/Finch/bin 57 ln -s $out/Applications/Finch/bin/finch $out/bin/finch 58 59 tar -xvf ${lima} -C $out/Applications/Finch/lima 60 cp ${os} $out/Applications/Finch/os/${os.name} 61 62 cp config.yaml $out/Applications/Finch 63 cp finch.yaml $out/Applications/Finch/os 64 65 substituteInPlace $out/Applications/Finch/os/finch.yaml \ 66 --replace-fail "<finch_image_location>" "$out/Applications/Finch/os/${os.name}" \ 67 --replace-fail "<finch_image_arch>" "${arch}" \ 68 --replace-fail "<finch_image_digest>" "sha256:$(sha256sum ${os} | cut -d' ' -f1)" 69 ''; 70 71 meta = with lib; { 72 description = "Client for container development"; 73 inherit (src.meta) homepage; 74 license = licenses.asl20; 75 maintainers = [ maintainers.sikmir ]; 76 platforms = platforms.darwin; 77 skip.ci = true; 78 }; 79 }