diff options
author | Adam Stephens <adam@valkor.net> | 2024-03-18 23:02:30 -0400 |
---|---|---|
committer | Adam Stephens <adam@valkor.net> | 2024-03-19 22:48:07 -0400 |
commit | deb5be50c46fe9785fe56e8fdfff1a51c9017ef1 (patch) | |
tree | b187c116c014dd20264f8bc69b93d56b6da17d11 /pkgs/by-name/in | |
parent | bf8c4dafb6bb8e164f5136b4698f53971dc1235b (diff) |
incus: move wrapper to nixos module
Diffstat (limited to 'pkgs/by-name/in')
-rw-r--r-- | pkgs/by-name/in/incus/529.patch | 29 | ||||
-rw-r--r-- | pkgs/by-name/in/incus/client.nix | 40 | ||||
-rw-r--r-- | pkgs/by-name/in/incus/generic.nix (renamed from pkgs/by-name/in/incus/unwrapped.nix) | 57 | ||||
-rw-r--r-- | pkgs/by-name/in/incus/latest.nix | 12 | ||||
-rw-r--r-- | pkgs/by-name/in/incus/lts.nix | 2 | ||||
-rw-r--r-- | pkgs/by-name/in/incus/package.nix | 162 | ||||
-rwxr-xr-x | pkgs/by-name/in/incus/update.nu | 22 |
7 files changed, 111 insertions, 213 deletions
diff --git a/pkgs/by-name/in/incus/529.patch b/pkgs/by-name/in/incus/529.patch new file mode 100644 index 0000000000000..5e4156b907ca3 --- /dev/null +++ b/pkgs/by-name/in/incus/529.patch @@ -0,0 +1,29 @@ +From 32a4beecbf8098fdbb15ef5f36088956922630f7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber@stgraber.org> +Date: Fri, 23 Feb 2024 18:47:15 -0500 +Subject: [PATCH] incusd/device/disk: Fix incorrect block volume usage +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Stéphane Graber <stgraber@stgraber.org> +--- + internal/server/device/disk.go | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/internal/server/device/disk.go b/internal/server/device/disk.go +index 0d19e21139..4f9a3e7c1b 100644 +--- a/internal/server/device/disk.go ++++ b/internal/server/device/disk.go +@@ -339,6 +339,11 @@ func (d *disk) validateConfig(instConf instance.ConfigReader) error { + var usedBy []string + + err = storagePools.VolumeUsedByInstanceDevices(d.state, d.pool.Name(), storageProjectName, &dbVolume.StorageVolume, true, func(inst db.InstanceArgs, project api.Project, usedByDevices []string) error { ++ // Don't count the current instance. ++ if d.inst != nil && d.inst.Project().Name == inst.Project && d.inst.Name() == inst.Name { ++ return nil ++ } ++ + usedBy = append(usedBy, inst.Name) + + return nil diff --git a/pkgs/by-name/in/incus/client.nix b/pkgs/by-name/in/incus/client.nix index 76f792377b100..5d69725ba59dd 100644 --- a/pkgs/by-name/in/incus/client.nix +++ b/pkgs/by-name/in/incus/client.nix @@ -1,28 +1,28 @@ { lts ? false, + meta, + patches, + src, + vendorHash, + version, lib, buildGoModule, - fetchpatch, - fetchFromGitHub, installShellFiles, }: let - releaseFile = if lts then ./lts.nix else ./latest.nix; - inherit (import releaseFile { inherit fetchpatch; }) version hash vendorHash; + pname = "incus${lib.optionalString lts "-lts"}-client"; in -buildGoModule rec { - pname = "incus-client"; - - inherit vendorHash version; - - src = fetchFromGitHub { - owner = "lxc"; - repo = "incus"; - rev = "refs/tags/v${version}"; - inherit hash; - }; +buildGoModule { + inherit + meta + patches + pname + src + vendorHash + version + ; CGO_ENABLED = 0; @@ -41,14 +41,4 @@ buildGoModule rec { # 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"; - }; } diff --git a/pkgs/by-name/in/incus/unwrapped.nix b/pkgs/by-name/in/incus/generic.nix index 7a28737ea3905..f6a8954066c39 100644 --- a/pkgs/by-name/in/incus/unwrapped.nix +++ b/pkgs/by-name/in/incus/generic.nix @@ -1,10 +1,18 @@ { + hash, lts ? false, + patches, + updateScriptArgs ? "", + vendorHash, + version, +}: +{ + callPackage, lib, buildGoModule, - fetchpatch, fetchFromGitHub, + writeScript, writeShellScript, acl, cowsql, @@ -19,31 +27,28 @@ }: let - releaseFile = if lts then ./lts.nix else ./latest.nix; - inherit (import releaseFile { inherit fetchpatch; }) - version - hash + pname = "incus${lib.optionalString lts "-lts"}"; +in + +buildGoModule rec { + inherit patches + pname vendorHash + version ; - name = "incus${lib.optionalString lts "-lts"}"; -in - -buildGoModule { - pname = "${name}-unwrapped"; - - inherit patches vendorHash version; src = fetchFromGitHub { owner = "lxc"; repo = "incus"; - rev = "v${version}"; + rev = "refs/tags/v${version}"; inherit hash; }; + # replace with env var > 0.6 https://github.com/lxc/incus/pull/610 postPatch = '' substituteInPlace internal/usbid/load.go \ - --replace "/usr/share/misc/usb.ids" "${hwdata}/share/hwdata/usb.ids" + --replace-fail "/usr/share/misc/usb.ids" "${hwdata}/share/hwdata/usb.ids" ''; excludedPackages = [ @@ -107,12 +112,23 @@ buildGoModule { ''; passthru = { - 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 + client = callPackage ./client.nix { + inherit + lts + meta + patches + src + vendorHash + version + ; + }; + + tests = nixosTests.incus; + + ui = callPackage ./ui.nix { }; + + updateScript = writeScript "ovs-update.nu" '' + ${./update.nu} ${updateScriptArgs} ''; }; @@ -123,5 +139,6 @@ buildGoModule { license = lib.licenses.asl20; maintainers = lib.teams.lxc.members; platforms = lib.platforms.linux; + mainProgram = "incus"; }; } diff --git a/pkgs/by-name/in/incus/latest.nix b/pkgs/by-name/in/incus/latest.nix deleted file mode 100644 index 78c09a857488f..0000000000000 --- a/pkgs/by-name/in/incus/latest.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ fetchpatch }: -{ - hash = "sha256-tGuAS0lZvoYb+TvmCklQ8TADZhbm4w/lhdI0ycS4/0o="; - version = "0.6.0"; - vendorHash = "sha256-+WmgLOEBJ/7GF596iiTgyTPxn8l+hE6RVqjLKfCi5rs="; - patches = [ - (fetchpatch { - url = "https://github.com/lxc/incus/pull/529.patch"; - hash = "sha256-2aaPrzW/LVJidWeom0rqYOGpT2gvuV1yHLJN/TwQ1fk="; - }) - ]; -} diff --git a/pkgs/by-name/in/incus/lts.nix b/pkgs/by-name/in/incus/lts.nix index a78deb48e23b0..1537d4d99bc6f 100644 --- a/pkgs/by-name/in/incus/lts.nix +++ b/pkgs/by-name/in/incus/lts.nix @@ -1,3 +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 -_: { } +import ./generic.nix { } diff --git a/pkgs/by-name/in/incus/package.nix b/pkgs/by-name/in/incus/package.nix index 2958ab036ac9f..40fd52de86179 100644 --- a/pkgs/by-name/in/incus/package.nix +++ b/pkgs/by-name/in/incus/package.nix @@ -1,157 +1,9 @@ -{ - lts ? false, - - lib, - callPackage, - linkFarm, - makeWrapper, - stdenv, - symlinkJoin, - writeShellScriptBin, - acl, - apparmor-parser, - apparmor-profiles, - attr, - bash, - btrfs-progs, - cdrkit, - criu, - dnsmasq, - e2fsprogs, - getent, - gnutar, - gptfdisk, - gzip, - iproute2, - iptables, - kmod, - lvm2, - minio, - nftables, - OVMF, - qemu_kvm, - qemu-utils, - rsync, - spice-gtk, - squashfsTools, - thin-provisioning-tools, - util-linux, - virtiofsd, - xz, -}: -let - unwrapped = callPackage ./unwrapped.nix { inherit lts; }; - client = callPackage ./client.nix { inherit lts; }; - name = "incus${lib.optionalString lts "-lts"}"; - - binPath = lib.makeBinPath [ - acl - attr - bash - btrfs-progs - cdrkit - criu - dnsmasq - e2fsprogs - getent - gnutar - gptfdisk - gzip - iproute2 - iptables - kmod - lvm2 - minio - nftables - qemu_kvm - qemu-utils - rsync - squashfsTools - thin-provisioning-tools - util-linux - virtiofsd - xz - - (writeShellScriptBin "apparmor_parser" '' - exec '${apparmor-parser}/bin/apparmor_parser' -I '${apparmor-profiles}/etc/apparmor.d' "$@" - '') +import ./generic.nix { + hash = "sha256-tGuAS0lZvoYb+TvmCklQ8TADZhbm4w/lhdI0ycS4/0o="; + version = "0.6.0"; + vendorHash = "sha256-+WmgLOEBJ/7GF596iiTgyTPxn8l+hE6RVqjLKfCi5rs="; + patches = [ + # fix storage bug, fixed in > 0.6 + ./529.patch ]; - - clientBinPath = [ spice-gtk ]; - - ovmf-2mb = OVMF.override { - secureBoot = true; - fdSize2MB = true; - }; - - ovmf-4mb = OVMF.override { - secureBoot = true; - fdSize4MB = true; - }; - - ovmf-prefix = if stdenv.hostPlatform.isAarch64 then "AAVMF" else "OVMF"; - - # 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 - ovmf = linkFarm "incus-ovmf" [ - { - name = "OVMF_CODE.2MB.fd"; - path = "${ovmf-2mb.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.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 -symlinkJoin { - name = "${name}-${unwrapped.version}"; - - paths = [ unwrapped ]; - - nativeBuildInputs = [ makeWrapper ]; - - postBuild = '' - wrapProgram $out/bin/incusd --prefix PATH : ${lib.escapeShellArg binPath}:${qemu_kvm}/libexec:$out/bin --set INCUS_OVMF_PATH ${ovmf} - - wrapProgram $out/bin/incus --prefix PATH : ${lib.makeBinPath clientBinPath} - ''; - - passthru = { - inherit client unwrapped; - ui = callPackage ./ui.nix {}; - - inherit (unwrapped) tests; - }; - - inherit (unwrapped) meta pname version; } diff --git a/pkgs/by-name/in/incus/update.nu b/pkgs/by-name/in/incus/update.nu new file mode 100755 index 0000000000000..1a0755e8f32d8 --- /dev/null +++ b/pkgs/by-name/in/incus/update.nu @@ -0,0 +1,22 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i nu -p nushell common-updater-scripts gnused + +def main [--lts = false, --regex: string] { + let attr = $"incus(if $lts {"-lts"})" + let file = $"(pwd)/pkgs/by-name/in/incus/(if $lts { "lts" } else { "package" }).nix" + + let tags = list-git-tags --url=https://github.com/lxc/incus | lines | sort --natural | str replace v '' + let latest_tag = if $regex == null { $tags } else { $tags | find --regex $regex } | last + let current_version = nix eval --raw -f default.nix $"($attr).version" | str trim + + if $latest_tag != $current_version { + update-source-version $attr $latest_tag $"--file=($file)" + + let oldVendorHash = nix-instantiate . --eval --strict -A $"($attr).goModules.drvAttrs.outputHash" --json | from json + let vendorHash = do { nix-build -A $"($attr).goModules" } | complete | get stderr | lines | str trim | find --regex 'got:[[:space:]]*sha256' | split row ' ' | last + open $file | str replace $oldVendorHash $vendorHash | save --force $file + + } + + {"lts?": $lts, before: $current_version, after: $latest_tag} +} |