Skip to content

Commit

Permalink
lxc/incus LTS upgrades: 6.0.1 -> 6.0.2 (NixOS#343058)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcstephens committed Sep 20, 2024
2 parents 7dae93e + ee30c81 commit d6ef783
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 42 deletions.
3 changes: 1 addition & 2 deletions nixos/modules/virtualisation/incus.nix
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,11 @@ let

environment = lib.mkMerge [
{
INCUS_EDK2_PATH = ovmf;
INCUS_LXC_TEMPLATE_CONFIG = "${pkgs.lxcfs}/share/lxc/config";
INCUS_USBIDS_PATH = "${pkgs.hwdata}/share/hwdata/usb.ids";
PATH = lib.mkForce serverBinPath;
}
(lib.mkIf (lib.versionOlder cfg.package.version "6.3.0") { INCUS_OVMF_PATH = ovmf; })
(lib.mkIf (lib.versionAtLeast cfg.package.version "6.3.0") { INCUS_EDK2_PATH = ovmf; })
(lib.mkIf (cfg.ui.enable) { "INCUS_UI" = cfg.ui.package; })
];

Expand Down
4 changes: 2 additions & 2 deletions pkgs/by-name/in/incus/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ buildGoModule rec {

ui = callPackage ./ui.nix { };

updateScript = writeScript "ovs-update.nu" ''
${./update.nu} ${updateScriptArgs}
updateScript = writeScript "ovs-update.py" ''
${./update.py} ${updateScriptArgs}
'';
};

Expand Down
9 changes: 4 additions & 5 deletions pkgs/by-name/in/incus/lts.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import ./generic.nix {
hash = "sha256-8GgzMiXn/78HkMuJ49cQA9BEQVAzPbG7jOxTScByR6Q=";
version = "6.0.1";
vendorHash = "sha256-dFg3LSG/ao73ODWcPDq5s9xUjuHabCMOB2AtngNCrlA=";
hash = "sha256-roPBHqy5toYF0X9mATl6QYb5GGlgPoGZYOC9vKpca88=";
version = "6.0.2";
vendorHash = "sha256-TP1NaUpsHF54mWQDcHS4uabfRJWu3k51ANNPdA4k1Go=";
patches = [
# qemu 9.1 compat, remove when added to LTS
./572afb06f66f83ca95efa1b9386fceeaa1c9e11b.patch
./58eeb4eeee8a9e7f9fa9c62443d00f0ec6797078.patch
./0c37b7e3ec65b4d0e166e2127d9f1835320165b8.patch
];
lts = true;
updateScriptArgs = "--lts=true --regex '6.0.*'";
updateScriptArgs = "--lts --regex '6.0.*'";
}
29 changes: 0 additions & 29 deletions pkgs/by-name/in/incus/update.nu

This file was deleted.

87 changes: 87 additions & 0 deletions pkgs/by-name/in/incus/update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python -p python3 python3Packages.looseversion common-updater-scripts nurl

import argparse
import json
import os
import re
from looseversion import LooseVersion
from subprocess import run

parser = argparse.ArgumentParser()
parser.add_argument("--lts", action="store_true")
parser.add_argument("--regex")
args = parser.parse_args()

nixpkgs_path = os.environ["PWD"]

attr = "incus"
file = f"pkgs/by-name/in/incus/package.nix"
if args.lts:
attr = "incus-lts"
file = f"pkgs/by-name/in/incus/lts.nix"

tags = (
run(["list-git-tags", "--url=https://github.com/lxc/incus"], capture_output=True)
.stdout.decode("utf-8")
.splitlines()
)
tags = [t.lstrip("v") for t in tags]

latest_version = "0"
for tag in tags:
if args.regex != None and not re.match(args.regex, tag):
continue

if LooseVersion(tag) > LooseVersion(latest_version):
latest_version = tag

current_version = (
run(
["nix", "eval", "--raw", "-f", "default.nix", f"{attr}.version"],
capture_output=True,
)
.stdout.decode("utf-8")
.strip()
)

if LooseVersion(latest_version) <= LooseVersion(current_version):
print("No update available")
exit(0)

print(f"Found new version {latest_version} > {current_version}")

run(["update-source-version", attr, latest_version, f"--file={file}"])

current_vendor_hash = (
run(
[
"nix-instantiate",
".",
"--eval",
"--strict",
"-A",
f"{attr}.goModules.drvAttrs.outputHash",
"--json",
],
capture_output=True,
)
.stdout.decode("utf-8")
.strip()
.strip('"')
)

latest_vendor_hash = (
run(
["nurl", "--expr", f"(import {nixpkgs_path} {{}}).{attr}.goModules"],
capture_output=True,
)
.stdout.decode("utf-8")
.strip()
)

with open(file, "r+") as f:
file_content = f.read()
file_content = re.sub(current_vendor_hash, latest_vendor_hash, file_content)
f.seek(0)
f.write(file_content)
4 changes: 2 additions & 2 deletions pkgs/by-name/lx/lxc/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

stdenv.mkDerivation (finalAttrs: {
pname = "lxc";
version = "6.0.1";
version = "6.0.2";

src = fetchFromGitHub {
owner = "lxc";
repo = "lxc";
rev = "refs/tags/v${finalAttrs.version}";
hash = "sha256-fJMNdMXlV1z9q1pMDh046tNmLDuK6zh6uPahTWzWMvc=";
hash = "sha256-qc60oSs2KahQJpSmhrctXpV2Zumv7EvlnGFaOCSCX/E=";
};

nativeBuildInputs = [
Expand Down
4 changes: 2 additions & 2 deletions pkgs/by-name/lx/lxcfs/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

stdenv.mkDerivation rec {
pname = "lxcfs";
version = "6.0.1";
version = "6.0.2";

src = fetchFromGitHub {
owner = "lxc";
repo = "lxcfs";
rev = "v${version}";
hash = "sha256-kJ9QaNI8v03E0//UyU6fsav1YGOlKGMxsbE8Pr1Dtic=";
hash = "sha256-5r1X/yUXTMC/2dNhpI+BVYeClIydefg2lurCGt7iA8Y=";
};

patches = [
Expand Down

0 comments on commit d6ef783

Please sign in to comment.