e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
74 lines
1.9 KiB
Nix
74 lines
1.9 KiB
Nix
{ lib
|
|
, stdenv
|
|
, darwin
|
|
, buildGoModule
|
|
, fetchFromGitHub
|
|
, installShellFiles
|
|
, lima
|
|
, lima-bin
|
|
, makeWrapper
|
|
, qemu
|
|
, testers
|
|
, colima
|
|
# use lima-bin on darwin to support native macOS virtualization
|
|
# https://github.com/NixOS/nixpkgs/pull/209171
|
|
, lima-drv ? if stdenv.hostPlatform.isDarwin then lima-bin else lima
|
|
}:
|
|
|
|
buildGoModule rec {
|
|
pname = "colima";
|
|
version = "0.7.5";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "abiosoft";
|
|
repo = pname;
|
|
rev = "v${version}";
|
|
hash = "sha256-WInmoTUaEm2kQ7esZgPj3YIHmHbBrlBTWcLPC9/2MdY=";
|
|
# We need the git revision
|
|
leaveDotGit = true;
|
|
postFetch = ''
|
|
git -C $out rev-parse --short HEAD > $out/.git-revision
|
|
rm -rf $out/.git
|
|
'';
|
|
};
|
|
|
|
nativeBuildInputs = [ installShellFiles makeWrapper ]
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ];
|
|
|
|
vendorHash = "sha256-niuBo2YUUYKH0eSApOByNLrcHqr9m5VKGoiGp1fKklg=";
|
|
|
|
# disable flaky Test_extractZones
|
|
# https://hydra.nixos.org/build/212378003/log
|
|
excludedPackages = "gvproxy";
|
|
|
|
CGO_ENABLED = 1;
|
|
|
|
preConfigure = ''
|
|
ldflags="-s -w -X github.com/abiosoft/colima/config.appVersion=${version} \
|
|
-X github.com/abiosoft/colima/config.revision=$(cat .git-revision)"
|
|
'';
|
|
|
|
postInstall = ''
|
|
wrapProgram $out/bin/colima \
|
|
--prefix PATH : ${lib.makeBinPath [ lima-drv qemu ]}
|
|
|
|
installShellCompletion --cmd colima \
|
|
--bash <($out/bin/colima completion bash) \
|
|
--fish <($out/bin/colima completion fish) \
|
|
--zsh <($out/bin/colima completion zsh)
|
|
'';
|
|
|
|
passthru.tests.version = testers.testVersion {
|
|
package = colima;
|
|
command = "HOME=$(mktemp -d) colima version";
|
|
};
|
|
|
|
meta = with lib; {
|
|
description = "Container runtimes with minimal setup";
|
|
homepage = "https://github.com/abiosoft/colima";
|
|
license = licenses.mit;
|
|
maintainers = with maintainers; [ aaschmid tricktron ];
|
|
mainProgram = "colima";
|
|
};
|
|
}
|