default.nix (2669B)
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}.1679936560.tar.gz"; 9 hash = "sha256-WpDR71QwMVi5ztJ0t+2lv3nPdpsrrAZunBNgSUtHags="; 10 }; 11 "aarch64-darwin" = fetchurl { 12 url = "https://deps.runfinch.com/${lib.replaceStrings [ "_" ] [ "-" ] arch}/lima-and-qemu.macos-${arch}.1679936560.tar.gz"; 13 hash = "sha256-WpDR71QwMVi5ztJ0t+2lv3nPdpsrrAZunBNgSUtHags="; 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/37/Cloud/${arch}/images/Fedora-Cloud-Base-37-1.7.${arch}.qcow2"; 20 hash = "sha256-tbm+yR7uZUiaV0X27mIFc7IzN8ux60UBziALFXoB86A="; 21 }; 22 "aarch64-darwin" = fetchurl { 23 url = "https://dl.fedoraproject.org/pub/fedora/linux/releases/37/Cloud/${arch}/images/Fedora-Cloud-Base-37-1.7.${arch}.qcow2"; 24 hash = "sha256-zIsPSbxgh1oW7vZa0T4OhrpQK6NYXMURRvEfQYKmKMA="; 25 }; 26 }.${stdenv.hostPlatform.system}; 27 in 28 buildGoModule rec { 29 pname = "finch"; 30 version = "0.6.2"; 31 32 src = fetchFromGitHub { 33 owner = "runfinch"; 34 repo = "finch"; 35 rev = "v${version}"; 36 hash = "sha256-hffcBp67SdUaXjhFUYkhAWBJavzhC+pVspW0bPx/3RY="; 37 fetchSubmodules = true; 38 }; 39 40 vendorHash = "sha256-/hLXY2UYr0N6wiu2UP0Cr6B9sd2JrAS1AVNA/RHy4t8="; 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 "<finch_image_location>" "$out/Applications/Finch/os/${os.name}" \ 67 --replace "<finch_image_arch>" "${arch}" \ 68 --replace "<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 }