nixpkgs/pkgs/by-name/in/incus/unwrapped.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

122 lines
2.5 KiB
Nix
Raw Normal View History

2024-02-01 04:09:57 +00:00
{
lts ? false,
2024-02-01 04:09:57 +00:00
lib,
buildGoModule,
fetchFromGitHub,
writeShellScript,
2024-02-01 04:09:57 +00:00
acl,
cowsql,
hwdata,
libcap,
lxc,
pkg-config,
sqlite,
udev,
installShellFiles,
nixosTests,
2023-08-29 15:51:14 +01:00
}:
let
releaseFile = if lts then ./lts.nix else ./latest.nix;
inherit (import releaseFile) version hash vendorHash;
name = "incus${lib.optionalString lts "-lts"}";
in
2023-08-29 15:51:14 +01:00
buildGoModule rec {
pname = "${name}-unwrapped";
inherit vendorHash version;
2023-08-29 15:51:14 +01:00
src = fetchFromGitHub {
owner = "lxc";
repo = "incus";
rev = "v${version}";
inherit hash;
2023-08-29 15:51:14 +01:00
};
postPatch = ''
substituteInPlace internal/usbid/load.go \
--replace "/usr/share/misc/usb.ids" "${hwdata}/share/hwdata/usb.ids"
'';
excludedPackages = [
# statically compile these
2023-08-29 15:51:14 +01:00
"cmd/incus-agent"
"cmd/incus-migrate"
# oidc test requires network
2023-11-27 13:26:13 +00:00
"test/mini-oidc"
2023-08-29 15:51:14 +01:00
];
nativeBuildInputs = [
installShellFiles
pkg-config
];
buildInputs = [
lxc
acl
libcap
cowsql.dev
sqlite
udev.dev
];
2024-02-01 04:09:57 +00:00
ldflags = [
"-s"
"-w"
];
2023-08-29 15:51:14 +01:00
tags = [ "libsqlite3" ];
2023-10-28 04:20:40 +01:00
# required for go-cowsql.
CGO_LDFLAGS_ALLOW = "(-Wl,-wrap,pthread_create)|(-Wl,-z,now)";
2023-08-29 15:51:14 +01:00
postBuild = ''
make incus-agent incus-migrate
'';
preCheck =
2024-02-01 04:09:57 +00:00
let
skippedTests = [
"TestValidateConfig"
"TestConvertNetworkConfig"
"TestConvertStorageConfig"
"TestSnapshotCommon"
"TestContainerTestSuite"
];
in
2023-08-29 15:51:14 +01:00
''
# Disable tests requiring local operations
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
'';
postInstall = ''
2024-01-03 13:46:27 +00:00
# use custom bash completion as it has extra logic for e.g. instance names
2023-08-29 15:51:14 +01:00
installShellCompletion --bash --name incus ./scripts/bash/incus
2024-01-03 13:46:27 +00:00
installShellCompletion --cmd incus \
--fish <($out/bin/incus completion fish) \
--zsh <($out/bin/incus completion zsh)
2023-08-29 15:51:14 +01:00
'';
passthru = {
2023-10-20 05:10:59 +01:00
tests.incus = nixosTests.incus;
updateScript = writeShellScript "update-incus" ''
nix-update ${name}.unwrapped -vr 'v(.*)' --override-filename pkgs/by-name/in/incus/${
if lts then "lts" else "latest"
}.nix
'';
2023-08-29 15:51:14 +01:00
};
meta = {
description = "Powerful system container and virtual machine manager";
homepage = "https://linuxcontainers.org/incus";
2024-01-29 22:01:20 +00:00
changelog = "https://github.com/lxc/incus/releases/tag/v${version}";
2023-08-29 15:51:14 +01:00
license = lib.licenses.asl20;
maintainers = lib.teams.lxc.members;
2023-08-29 15:51:14 +01:00
platforms = lib.platforms.linux;
};
}