about summary refs log tree commit diff
path: root/pkgs/by-name/in
diff options
context:
space:
mode:
authorAdam C. Stephens <2071575+adamcstephens@users.noreply.github.com>2024-02-05 07:50:18 -0500
committerGitHub <noreply@github.com>2024-02-05 07:50:18 -0500
commitaf25a022c6b427ad0db39b3efca4ad0293176954 (patch)
treeb1cc364f0226c665f272f7eed382ca90c265fcdf /pkgs/by-name/in
parent2eab263f5c06f138468cebc032a6633b71281152 (diff)
parent273b448b6a3fe0961b939bea8f2c4e202e489448 (diff)
Merge pull request #285858 from adamcstephens/incus/refactor
incus: fix lxd-to-incus, add static client, support multi-version
Diffstat (limited to 'pkgs/by-name/in')
-rw-r--r--pkgs/by-name/in/incus/client.nix53
-rw-r--r--pkgs/by-name/in/incus/latest.nix5
-rw-r--r--pkgs/by-name/in/incus/lts.nix3
-rw-r--r--pkgs/by-name/in/incus/package.nix152
-rw-r--r--pkgs/by-name/in/incus/unwrapped.nix (renamed from pkgs/by-name/in/incus-unwrapped/package.nix)84
5 files changed, 206 insertions, 91 deletions
diff --git a/pkgs/by-name/in/incus/client.nix b/pkgs/by-name/in/incus/client.nix
new file mode 100644
index 0000000000000..46bf691c6951b
--- /dev/null
+++ b/pkgs/by-name/in/incus/client.nix
@@ -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";
+  };
+}
diff --git a/pkgs/by-name/in/incus/latest.nix b/pkgs/by-name/in/incus/latest.nix
new file mode 100644
index 0000000000000..0c0c32ba9af37
--- /dev/null
+++ b/pkgs/by-name/in/incus/latest.nix
@@ -0,0 +1,5 @@
+{
+  hash = "sha256-3eWkQT2P69ZfN62H9B4WLnmlUOGkpzRR0rctgchP+6A=";
+  version = "0.5.1";
+  vendorHash = "sha256-2ZJU7WshN4UIbJv55bFeo9qiAQ/wxu182mnz7pE60xA=";
+}
diff --git a/pkgs/by-name/in/incus/lts.nix b/pkgs/by-name/in/incus/lts.nix
new file mode 100644
index 0000000000000..d70793f94dfa1
--- /dev/null
+++ b/pkgs/by-name/in/incus/lts.nix
@@ -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
+{ }
diff --git a/pkgs/by-name/in/incus/package.nix b/pkgs/by-name/in/incus/package.nix
index d4a9ef55c611d..8a10f6eef7fd6 100644
--- a/pkgs/by-name/in/incus/package.nix
+++ b/pkgs/by-name/in/incus/package.nix
@@ -1,42 +1,49 @@
-{ lib
-, incus-unwrapped
-, 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
+{
+  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
@@ -70,9 +77,7 @@ let
     '')
   ];
 
-  clientBinPath = [
-    spice-gtk
-  ];
+  clientBinPath = [ spice-gtk ];
 
   ovmf-2mb = OVMF.override {
     secureBoot = true;
@@ -98,24 +103,57 @@ let
   # 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.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.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"; }
+    {
+      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.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.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
 symlinkJoin {
-  name = "incus-${incus-unwrapped.version}";
+  name = "${name}-${unwrapped.version}";
 
-  paths = [ incus-unwrapped ];
+  paths = [ unwrapped ];
 
   nativeBuildInputs = [ makeWrapper ];
 
@@ -126,8 +164,10 @@ symlinkJoin {
   '';
 
   passthru = {
-    inherit (incus-unwrapped) tests;
+    inherit client unwrapped;
+
+    inherit (unwrapped) tests;
   };
 
-  inherit (incus-unwrapped) meta pname version;
+  inherit (unwrapped) meta pname version;
 }
diff --git a/pkgs/by-name/in/incus-unwrapped/package.nix b/pkgs/by-name/in/incus/unwrapped.nix
index d415e873f5741..73257c5839406 100644
--- a/pkgs/by-name/in/incus-unwrapped/package.nix
+++ b/pkgs/by-name/in/incus/unwrapped.nix
@@ -1,41 +1,51 @@
-{ lib
-, buildGoModule
-, fetchFromGitHub
-, acl
-, cowsql
-, hwdata
-, libcap
-, lxc
-, pkg-config
-, sqlite
-, udev
-, installShellFiles
-, nix-update-script
-, nixosTests
+{
+  lts ? false,
+
+  lib,
+  buildGoModule,
+  fetchFromGitHub,
+  writeShellScript,
+  acl,
+  cowsql,
+  hwdata,
+  libcap,
+  lxc,
+  pkg-config,
+  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 {
-  pname = "incus-unwrapped";
-  version = "0.5.1";
+  pname = "${name}-unwrapped";
+
+  inherit vendorHash version;
 
   src = fetchFromGitHub {
     owner = "lxc";
     repo = "incus";
-    rev = "refs/tags/v${version}";
-    hash = "sha256-3eWkQT2P69ZfN62H9B4WLnmlUOGkpzRR0rctgchP+6A=";
+    rev = "v${version}";
+    inherit hash;
   };
 
-  vendorHash = "sha256-2ZJU7WshN4UIbJv55bFeo9qiAQ/wxu182mnz7pE60xA=";
-
   postPatch = ''
     substituteInPlace internal/usbid/load.go \
       --replace "/usr/share/misc/usb.ids" "${hwdata}/share/hwdata/usb.ids"
   '';
 
   excludedPackages = [
+    # statically compile these
     "cmd/incus-agent"
     "cmd/incus-migrate"
-    "cmd/lxd-to-incus"
+
+    # oidc test requires network
     "test/mini-oidc"
   ];
 
@@ -53,7 +63,10 @@ buildGoModule rec {
     udev.dev
   ];
 
-  ldflags = [ "-s" "-w" ];
+  ldflags = [
+    "-s"
+    "-w"
+  ];
   tags = [ "libsqlite3" ];
 
   # required for go-cowsql.
@@ -64,13 +77,15 @@ buildGoModule rec {
   '';
 
   preCheck =
-    let skippedTests = [
-      "TestValidateConfig"
-      "TestConvertNetworkConfig"
-      "TestConvertStorageConfig"
-      "TestSnapshotCommon"
-      "TestContainerTestSuite"
-    ]; in
+    let
+      skippedTests = [
+        "TestValidateConfig"
+        "TestConvertNetworkConfig"
+        "TestConvertStorageConfig"
+        "TestSnapshotCommon"
+        "TestContainerTestSuite"
+      ];
+    in
     ''
       # Disable tests requiring local operations
       buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
@@ -85,15 +100,14 @@ buildGoModule rec {
       --zsh <($out/bin/incus completion zsh)
   '';
 
-
   passthru = {
     tests.incus = nixosTests.incus;
 
-    updateScript = nix-update-script {
-       extraArgs = [
-        "-vr" "v\(.*\)"
-       ];
-     };
+    updateScript = writeShellScript "update-incus" ''
+      nix-update ${name}.unwrapped -vr 'v(.*)' --override-filename pkgs/by-name/in/incus/${
+        if lts then "lts" else "latest"
+      }.nix
+    '';
   };
 
   meta = {