mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-17 06:06:13 +03:00
Merge pull request #285858 from adamcstephens/incus/refactor
incus: fix lxd-to-incus, add static client, support multi-version
This commit is contained in:
commit
af25a022c6
@ -18,8 +18,6 @@ import ../make-test-python.nix (
|
|||||||
nodes.machine =
|
nodes.machine =
|
||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
{
|
{
|
||||||
environment.systemPackages = [ pkgs.lxd-to-incus ];
|
|
||||||
|
|
||||||
virtualisation = {
|
virtualisation = {
|
||||||
diskSize = 6144;
|
diskSize = 6144;
|
||||||
cores = 2;
|
cores = 2;
|
||||||
|
53
pkgs/by-name/in/incus/client.nix
Normal file
53
pkgs/by-name/in/incus/client.nix
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
lts ? false,
|
||||||
|
|
||||||
|
lib,
|
||||||
|
buildGoModule,
|
||||||
|
fetchFromGitHub,
|
||||||
|
installShellFiles,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
releaseFile = if lts then ./lts.nix else ./latest.nix;
|
||||||
|
inherit (import releaseFile) version hash vendorHash;
|
||||||
|
in
|
||||||
|
|
||||||
|
buildGoModule rec {
|
||||||
|
pname = "incus-client";
|
||||||
|
|
||||||
|
inherit vendorHash version;
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "lxc";
|
||||||
|
repo = "incus";
|
||||||
|
rev = "refs/tags/v${version}";
|
||||||
|
inherit hash;
|
||||||
|
};
|
||||||
|
|
||||||
|
CGO_ENABLED = 0;
|
||||||
|
|
||||||
|
nativeBuildInputs = [ installShellFiles ];
|
||||||
|
|
||||||
|
subPackages = [ "cmd/incus" ];
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
# use custom bash completion as it has extra logic for e.g. instance names
|
||||||
|
installShellCompletion --bash --name incus ./scripts/bash/incus
|
||||||
|
|
||||||
|
installShellCompletion --cmd incus \
|
||||||
|
--fish <($out/bin/incus completion fish) \
|
||||||
|
--zsh <($out/bin/incus completion zsh)
|
||||||
|
'';
|
||||||
|
|
||||||
|
# don't run the full incus test suite
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "Powerful system container and virtual machine manager";
|
||||||
|
homepage = "https://linuxcontainers.org/incus";
|
||||||
|
changelog = "https://github.com/lxc/incus/releases/tag/v${version}";
|
||||||
|
license = lib.licenses.asl20;
|
||||||
|
maintainers = lib.teams.lxc.members;
|
||||||
|
platforms = lib.platforms.unix;
|
||||||
|
mainProgram = "incus";
|
||||||
|
};
|
||||||
|
}
|
5
pkgs/by-name/in/incus/latest.nix
Normal file
5
pkgs/by-name/in/incus/latest.nix
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
hash = "sha256-3eWkQT2P69ZfN62H9B4WLnmlUOGkpzRR0rctgchP+6A=";
|
||||||
|
version = "0.5.1";
|
||||||
|
vendorHash = "sha256-2ZJU7WshN4UIbJv55bFeo9qiAQ/wxu182mnz7pE60xA=";
|
||||||
|
}
|
3
pkgs/by-name/in/incus/lts.nix
Normal file
3
pkgs/by-name/in/incus/lts.nix
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# this release doesn't exist yet, but satisfay the by-name checks
|
||||||
|
# will be added as incus-lts in all-packages.nix once ready
|
||||||
|
{ }
|
@ -1,42 +1,49 @@
|
|||||||
{ lib
|
{
|
||||||
, incus-unwrapped
|
lts ? false,
|
||||||
, linkFarm
|
|
||||||
, makeWrapper
|
lib,
|
||||||
, stdenv
|
callPackage,
|
||||||
, symlinkJoin
|
linkFarm,
|
||||||
, writeShellScriptBin
|
makeWrapper,
|
||||||
, acl
|
stdenv,
|
||||||
, apparmor-parser
|
symlinkJoin,
|
||||||
, apparmor-profiles
|
writeShellScriptBin,
|
||||||
, attr
|
acl,
|
||||||
, bash
|
apparmor-parser,
|
||||||
, btrfs-progs
|
apparmor-profiles,
|
||||||
, cdrkit
|
attr,
|
||||||
, criu
|
bash,
|
||||||
, dnsmasq
|
btrfs-progs,
|
||||||
, e2fsprogs
|
cdrkit,
|
||||||
, getent
|
criu,
|
||||||
, gnutar
|
dnsmasq,
|
||||||
, gptfdisk
|
e2fsprogs,
|
||||||
, gzip
|
getent,
|
||||||
, iproute2
|
gnutar,
|
||||||
, iptables
|
gptfdisk,
|
||||||
, kmod
|
gzip,
|
||||||
, lvm2
|
iproute2,
|
||||||
, minio
|
iptables,
|
||||||
, nftables
|
kmod,
|
||||||
, OVMF
|
lvm2,
|
||||||
, qemu_kvm
|
minio,
|
||||||
, qemu-utils
|
nftables,
|
||||||
, rsync
|
OVMF,
|
||||||
, spice-gtk
|
qemu_kvm,
|
||||||
, squashfsTools
|
qemu-utils,
|
||||||
, thin-provisioning-tools
|
rsync,
|
||||||
, util-linux
|
spice-gtk,
|
||||||
, virtiofsd
|
squashfsTools,
|
||||||
, xz
|
thin-provisioning-tools,
|
||||||
|
util-linux,
|
||||||
|
virtiofsd,
|
||||||
|
xz,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
unwrapped = callPackage ./unwrapped.nix { inherit lts; };
|
||||||
|
client = callPackage ./client.nix { inherit lts; };
|
||||||
|
name = "incus${lib.optionalString lts "-lts"}";
|
||||||
|
|
||||||
binPath = lib.makeBinPath [
|
binPath = lib.makeBinPath [
|
||||||
acl
|
acl
|
||||||
attr
|
attr
|
||||||
@ -70,9 +77,7 @@ let
|
|||||||
'')
|
'')
|
||||||
];
|
];
|
||||||
|
|
||||||
clientBinPath = [
|
clientBinPath = [ spice-gtk ];
|
||||||
spice-gtk
|
|
||||||
];
|
|
||||||
|
|
||||||
ovmf-2mb = OVMF.override {
|
ovmf-2mb = OVMF.override {
|
||||||
secureBoot = true;
|
secureBoot = true;
|
||||||
@ -98,24 +103,57 @@ let
|
|||||||
# mimic ovmf from https://github.com/canonical/incus-pkg-snap/blob/3abebe1dfeb20f9b7729556960c7e9fe6ad5e17c/snapcraft.yaml#L378
|
# mimic ovmf from https://github.com/canonical/incus-pkg-snap/blob/3abebe1dfeb20f9b7729556960c7e9fe6ad5e17c/snapcraft.yaml#L378
|
||||||
# also found in /snap/incus/current/share/qemu/ on a snap install
|
# also found in /snap/incus/current/share/qemu/ on a snap install
|
||||||
ovmf = linkFarm "incus-ovmf" [
|
ovmf = linkFarm "incus-ovmf" [
|
||||||
{ name = "OVMF_CODE.2MB.fd"; path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_CODE.fd"; }
|
{
|
||||||
{ name = "OVMF_CODE.4MB.CSM.fd"; path = "${ovmf-4mb-csm.fd}/FV/${ovmf-prefix}_CODE.fd"; }
|
name = "OVMF_CODE.2MB.fd";
|
||||||
{ name = "OVMF_CODE.4MB.fd"; path = "${ovmf-4mb.fd}/FV/${ovmf-prefix}_CODE.fd"; }
|
path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_CODE.fd";
|
||||||
{ name = "OVMF_CODE.fd"; path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_CODE.fd"; }
|
}
|
||||||
|
{
|
||||||
|
name = "OVMF_CODE.4MB.CSM.fd";
|
||||||
|
path = "${ovmf-4mb-csm.fd}/FV/${ovmf-prefix}_CODE.fd";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "OVMF_CODE.4MB.fd";
|
||||||
|
path = "${ovmf-4mb.fd}/FV/${ovmf-prefix}_CODE.fd";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "OVMF_CODE.fd";
|
||||||
|
path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_CODE.fd";
|
||||||
|
}
|
||||||
|
|
||||||
{ name = "OVMF_VARS.2MB.fd"; path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_VARS.fd"; }
|
{
|
||||||
{ name = "OVMF_VARS.2MB.ms.fd"; path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_VARS.fd"; }
|
name = "OVMF_VARS.2MB.fd";
|
||||||
{ name = "OVMF_VARS.4MB.CSM.fd"; path = "${ovmf-4mb-csm.fd}/FV/${ovmf-prefix}_VARS.fd"; }
|
path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_VARS.fd";
|
||||||
{ name = "OVMF_VARS.4MB.fd"; path = "${ovmf-4mb.fd}/FV/${ovmf-prefix}_VARS.fd"; }
|
}
|
||||||
{ name = "OVMF_VARS.4MB.ms.fd"; path = "${ovmf-4mb.fd}/FV/${ovmf-prefix}_VARS.fd"; }
|
{
|
||||||
{ name = "OVMF_VARS.fd"; path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_VARS.fd"; }
|
name = "OVMF_VARS.2MB.ms.fd";
|
||||||
{ name = "OVMF_VARS.ms.fd"; path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_VARS.fd"; }
|
path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_VARS.fd";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "OVMF_VARS.4MB.CSM.fd";
|
||||||
|
path = "${ovmf-4mb-csm.fd}/FV/${ovmf-prefix}_VARS.fd";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "OVMF_VARS.4MB.fd";
|
||||||
|
path = "${ovmf-4mb.fd}/FV/${ovmf-prefix}_VARS.fd";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "OVMF_VARS.4MB.ms.fd";
|
||||||
|
path = "${ovmf-4mb.fd}/FV/${ovmf-prefix}_VARS.fd";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "OVMF_VARS.fd";
|
||||||
|
path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_VARS.fd";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "OVMF_VARS.ms.fd";
|
||||||
|
path = "${ovmf-2mb.fd}/FV/${ovmf-prefix}_VARS.fd";
|
||||||
|
}
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
symlinkJoin {
|
symlinkJoin {
|
||||||
name = "incus-${incus-unwrapped.version}";
|
name = "${name}-${unwrapped.version}";
|
||||||
|
|
||||||
paths = [ incus-unwrapped ];
|
paths = [ unwrapped ];
|
||||||
|
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
|
|
||||||
@ -126,8 +164,10 @@ symlinkJoin {
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit (incus-unwrapped) tests;
|
inherit client unwrapped;
|
||||||
|
|
||||||
|
inherit (unwrapped) tests;
|
||||||
};
|
};
|
||||||
|
|
||||||
inherit (incus-unwrapped) meta pname version;
|
inherit (unwrapped) meta pname version;
|
||||||
}
|
}
|
||||||
|
@ -1,41 +1,51 @@
|
|||||||
{ lib
|
{
|
||||||
, buildGoModule
|
lts ? false,
|
||||||
, fetchFromGitHub
|
|
||||||
, acl
|
lib,
|
||||||
, cowsql
|
buildGoModule,
|
||||||
, hwdata
|
fetchFromGitHub,
|
||||||
, libcap
|
writeShellScript,
|
||||||
, lxc
|
acl,
|
||||||
, pkg-config
|
cowsql,
|
||||||
, sqlite
|
hwdata,
|
||||||
, udev
|
libcap,
|
||||||
, installShellFiles
|
lxc,
|
||||||
, nix-update-script
|
pkg-config,
|
||||||
, nixosTests
|
sqlite,
|
||||||
|
udev,
|
||||||
|
installShellFiles,
|
||||||
|
nixosTests,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
releaseFile = if lts then ./lts.nix else ./latest.nix;
|
||||||
|
inherit (import releaseFile) version hash vendorHash;
|
||||||
|
name = "incus${lib.optionalString lts "-lts"}";
|
||||||
|
in
|
||||||
|
|
||||||
buildGoModule rec {
|
buildGoModule rec {
|
||||||
pname = "incus-unwrapped";
|
pname = "${name}-unwrapped";
|
||||||
version = "0.5.1";
|
|
||||||
|
inherit vendorHash version;
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "lxc";
|
owner = "lxc";
|
||||||
repo = "incus";
|
repo = "incus";
|
||||||
rev = "refs/tags/v${version}";
|
rev = "v${version}";
|
||||||
hash = "sha256-3eWkQT2P69ZfN62H9B4WLnmlUOGkpzRR0rctgchP+6A=";
|
inherit hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
vendorHash = "sha256-2ZJU7WshN4UIbJv55bFeo9qiAQ/wxu182mnz7pE60xA=";
|
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
substituteInPlace internal/usbid/load.go \
|
substituteInPlace internal/usbid/load.go \
|
||||||
--replace "/usr/share/misc/usb.ids" "${hwdata}/share/hwdata/usb.ids"
|
--replace "/usr/share/misc/usb.ids" "${hwdata}/share/hwdata/usb.ids"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
excludedPackages = [
|
excludedPackages = [
|
||||||
|
# statically compile these
|
||||||
"cmd/incus-agent"
|
"cmd/incus-agent"
|
||||||
"cmd/incus-migrate"
|
"cmd/incus-migrate"
|
||||||
"cmd/lxd-to-incus"
|
|
||||||
|
# oidc test requires network
|
||||||
"test/mini-oidc"
|
"test/mini-oidc"
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -53,7 +63,10 @@ buildGoModule rec {
|
|||||||
udev.dev
|
udev.dev
|
||||||
];
|
];
|
||||||
|
|
||||||
ldflags = [ "-s" "-w" ];
|
ldflags = [
|
||||||
|
"-s"
|
||||||
|
"-w"
|
||||||
|
];
|
||||||
tags = [ "libsqlite3" ];
|
tags = [ "libsqlite3" ];
|
||||||
|
|
||||||
# required for go-cowsql.
|
# required for go-cowsql.
|
||||||
@ -64,13 +77,15 @@ buildGoModule rec {
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
preCheck =
|
preCheck =
|
||||||
let skippedTests = [
|
let
|
||||||
|
skippedTests = [
|
||||||
"TestValidateConfig"
|
"TestValidateConfig"
|
||||||
"TestConvertNetworkConfig"
|
"TestConvertNetworkConfig"
|
||||||
"TestConvertStorageConfig"
|
"TestConvertStorageConfig"
|
||||||
"TestSnapshotCommon"
|
"TestSnapshotCommon"
|
||||||
"TestContainerTestSuite"
|
"TestContainerTestSuite"
|
||||||
]; in
|
];
|
||||||
|
in
|
||||||
''
|
''
|
||||||
# Disable tests requiring local operations
|
# Disable tests requiring local operations
|
||||||
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
|
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
|
||||||
@ -85,15 +100,14 @@ buildGoModule rec {
|
|||||||
--zsh <($out/bin/incus completion zsh)
|
--zsh <($out/bin/incus completion zsh)
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
tests.incus = nixosTests.incus;
|
tests.incus = nixosTests.incus;
|
||||||
|
|
||||||
updateScript = nix-update-script {
|
updateScript = writeShellScript "update-incus" ''
|
||||||
extraArgs = [
|
nix-update ${name}.unwrapped -vr 'v(.*)' --override-filename pkgs/by-name/in/incus/${
|
||||||
"-vr" "v\(.*\)"
|
if lts then "lts" else "latest"
|
||||||
];
|
}.nix
|
||||||
};
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
meta = {
|
meta = {
|
@ -1,48 +0,0 @@
|
|||||||
{ lib
|
|
||||||
, buildGoModule
|
|
||||||
, fetchFromGitHub
|
|
||||||
, fetchpatch
|
|
||||||
, nix-update-script
|
|
||||||
}:
|
|
||||||
|
|
||||||
buildGoModule rec {
|
|
||||||
pname = "lxd-to-incus";
|
|
||||||
version = "0.4.0";
|
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
|
||||||
owner = "lxc";
|
|
||||||
repo = "incus";
|
|
||||||
rev = "refs/tags/v${version}";
|
|
||||||
hash = "sha256-crWepf5j3Gd1lhya2DGIh/to7l+AnjKJPR+qUd9WOzw=";
|
|
||||||
};
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
# create migration touch file, remove > 0.4.0
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://github.com/lxc/incus/commit/edc5fd2a9baccfb7b6814a440e2947cbb580afcf.diff";
|
|
||||||
hash = "sha256-ffQfMFrKDPuLU4jVbG/VGHSO3DmeHw30ATJ8yxJAoHQ=";
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
modRoot = "cmd/lxd-to-incus";
|
|
||||||
|
|
||||||
vendorHash = "sha256-cBAqJz3Y4CqyxTt7u/4mXoQPKmKgQ3gYJV1NiC/H+TA=";
|
|
||||||
|
|
||||||
CGO_ENABLED = 0;
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
updateScript = nix-update-script {
|
|
||||||
extraArgs = [
|
|
||||||
"-vr" "v\(.*\)"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
description = "LXD to Incus migration tool";
|
|
||||||
homepage = "https://linuxcontainers.org/incus";
|
|
||||||
license = lib.licenses.asl20;
|
|
||||||
maintainers = lib.teams.lxc.members;
|
|
||||||
platforms = lib.platforms.linux;
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user