diff options
Diffstat (limited to 'pkgs/tools/virtualization')
12 files changed, 95 insertions, 457 deletions
diff --git a/pkgs/tools/virtualization/awsebcli/default.nix b/pkgs/tools/virtualization/awsebcli/default.nix index 01b05b5481f5f..64d5022c2de8c 100644 --- a/pkgs/tools/virtualization/awsebcli/default.nix +++ b/pkgs/tools/virtualization/awsebcli/default.nix @@ -23,16 +23,21 @@ let in with localPython.pkgs; buildPythonApplication rec { pname = "awsebcli"; - version = "3.20.7"; + version = "3.20.9"; format = "setuptools"; src = fetchFromGitHub { owner = "aws"; repo = "aws-elastic-beanstalk-cli"; rev = "refs/tags/${version}"; - hash = "sha256-DxjoEkFnY4aSfxVKPpnJLmnjLtZnlM74XXd0K8mcdoY="; + hash = "sha256-tnBDEeR+SCHb9UT3pTO7ISm4TVICvVfrV5cfz/60YQY="; }; + postPatch = '' + # https://github.com/aws/aws-elastic-beanstalk-cli/pull/469 + substituteInPlace setup.py --replace "scripts=['bin/eb']," "" + ''; + nativeBuildInputs = [ pythonRelaxDepsHook ]; diff --git a/pkgs/tools/virtualization/cloud-init/0001-add-nixos-support.patch b/pkgs/tools/virtualization/cloud-init/0001-add-nixos-support.patch index f26690bacb70f..2e293321ac02a 100644 --- a/pkgs/tools/virtualization/cloud-init/0001-add-nixos-support.patch +++ b/pkgs/tools/virtualization/cloud-init/0001-add-nixos-support.patch @@ -1,10 +1,10 @@ diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py -index b82852e1..c998b21e 100644 +index 7b83df8d..6d04de1a 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py -@@ -74,6 +74,7 @@ OSFAMILIES = { +@@ -75,6 +75,7 @@ OSFAMILIES = { ], - "openEuler": ["openEuler"], + "openeuler": ["openeuler"], "OpenCloudOS": ["OpenCloudOS", "TencentOS"], + "nixos": ["nixos"], } @@ -12,7 +12,7 @@ index b82852e1..c998b21e 100644 LOG = logging.getLogger(__name__) diff --git a/cloudinit/distros/nixos.py b/cloudinit/distros/nixos.py new file mode 100644 -index 00000000..d53d2a62 +index 00000000..954e564b --- /dev/null +++ b/cloudinit/distros/nixos.py @@ -0,0 +1,109 @@ diff --git a/pkgs/tools/virtualization/cloud-init/0002-Add-Udhcpc-support.patch b/pkgs/tools/virtualization/cloud-init/0002-Add-Udhcpc-support.patch deleted file mode 100644 index 0df3f27a2c40b..0000000000000 --- a/pkgs/tools/virtualization/cloud-init/0002-Add-Udhcpc-support.patch +++ /dev/null @@ -1,421 +0,0 @@ -From 53260ce3bd70a0852d3e0d5569474214cea0ec0c Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= <jfroche@pyxel.be> -Date: Mon, 19 Jun 2023 15:56:46 +0200 -Subject: [PATCH] net/dhcp: add udhcpc support - -The currently used dhcp client, dhclient, is coming from the unmaintained package, isc-dhcp-client (refer https://www.isc.org/dhcp/) which ended support in 2022. - -This change introduce support for the dhcp client, udhcpc, from the busybox project. Busybox advantages are that it is available across many distributions and comes with lightweight executables. ---- - cloudinit/distros/__init__.py | 8 +- - cloudinit/net/dhcp.py | 129 ++++++++++++++++++++++- - tests/unittests/net/test_dhcp.py | 175 ++++++++++++++++++++++++++++++- - tools/.github-cla-signers | 1 + - 4 files changed, 309 insertions(+), 4 deletions(-) - -diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py -index ec148939..0fab8945 100644 ---- a/cloudinit/distros/__init__.py -+++ b/cloudinit/distros/__init__.py -@@ -110,14 +110,18 @@ class Distro(persistence.CloudInitPickleMixin, metaclass=abc.ABCMeta): - resolve_conf_fn = "/etc/resolv.conf" - - osfamily: str -- dhcp_client_priority = [dhcp.IscDhclient, dhcp.Dhcpcd] -+ dhcp_client_priority = [dhcp.IscDhclient, dhcp.Dhcpcd, dhcp.Udhcpc] - - def __init__(self, name, cfg, paths): - self._paths = paths - self._cfg = cfg - self.name = name - self.networking: Networking = self.networking_cls() -- self.dhcp_client_priority = [dhcp.IscDhclient, dhcp.Dhcpcd] -+ self.dhcp_client_priority = [ -+ dhcp.IscDhclient, -+ dhcp.Dhcpcd, -+ dhcp.Udhcpc, -+ ] - - def _unpickle(self, ci_pkl_version: int) -> None: - """Perform deserialization fixes for Distro.""" -diff --git a/cloudinit/net/dhcp.py b/cloudinit/net/dhcp.py -index 6c8c2f54..f5586cea 100644 ---- a/cloudinit/net/dhcp.py -+++ b/cloudinit/net/dhcp.py -@@ -21,6 +21,7 @@ from cloudinit import subp, temp_utils, util - from cloudinit.net import ( - find_fallback_nic, - get_devicelist, -+ get_ib_interface_hwaddr, - get_interface_mac, - is_ib_interface, - ) -@@ -28,6 +29,37 @@ from cloudinit.net import ( - LOG = logging.getLogger(__name__) - - NETWORKD_LEASES_DIR = "/run/systemd/netif/leases" -+UDHCPC_SCRIPT = """#!/bin/sh -+log() { -+ echo "udhcpc[$PPID]" "$interface: $2" -+} -+[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1 -+case $1 in -+ bound|renew) -+ cat <<JSON > "$LEASE_FILE" -+{ -+ "interface": "$interface", -+ "fixed-address": "$ip", -+ "subnet-mask": "$subnet", -+ "routers": "${router%% *}", -+ "static_routes" : "${staticroutes}" -+} -+JSON -+ ;; -+ deconfig) -+ log err "Not supported" -+ exit 1 -+ ;; -+ leasefail | nak) -+ log err "configuration failed: $1: $message" -+ exit 1 -+ ;; -+ *) -+ echo "$0: Unknown udhcpc command: $1" >&2 -+ exit 1 -+ ;; -+esac -+""" - - - class NoDHCPLeaseError(Exception): -@@ -50,6 +82,10 @@ class NoDHCPLeaseMissingDhclientError(NoDHCPLeaseError): - """Raised when unable to find dhclient.""" - - -+class NoDHCPLeaseMissingUdhcpcError(NoDHCPLeaseError): -+ """Raised when unable to find udhcpc client.""" -+ -+ - def select_dhcp_client(distro): - """distros set priority list, select based on this order which to use - -@@ -60,7 +96,10 @@ def select_dhcp_client(distro): - dhcp_client = client() - LOG.debug("DHCP client selected: %s", client.client_name) - return dhcp_client -- except NoDHCPLeaseMissingDhclientError: -+ except ( -+ NoDHCPLeaseMissingDhclientError, -+ NoDHCPLeaseMissingUdhcpcError, -+ ): - LOG.warning("DHCP client not found: %s", client.client_name) - raise NoDHCPLeaseMissingDhclientError() - -@@ -497,3 +536,91 @@ class Dhcpcd: - - def __init__(self): - raise NoDHCPLeaseMissingDhclientError("Dhcpcd not yet implemented") -+ -+ -+class Udhcpc(DhcpClient): -+ client_name = "udhcpc" -+ -+ def __init__(self): -+ self.udhcpc_path = subp.which("udhcpc") -+ if not self.udhcpc_path: -+ LOG.debug("Skip udhcpc configuration: No udhcpc command found.") -+ raise NoDHCPLeaseMissingUdhcpcError() -+ -+ def dhcp_discovery( -+ self, -+ interface, -+ dhcp_log_func=None, -+ distro=None, -+ ): -+ """Run udhcpc on the interface without scripts or filesystem artifacts. -+ -+ @param interface: Name of the network interface on which to run udhcpc. -+ @param dhcp_log_func: A callable accepting the udhcpc output and -+ error streams. -+ -+ @return: A list of dicts of representing the dhcp leases parsed from -+ the udhcpc lease file. -+ """ -+ LOG.debug("Performing a dhcp discovery on %s", interface) -+ -+ tmp_dir = temp_utils.get_tmp_ancestor(needs_exe=True) -+ lease_file = os.path.join(tmp_dir, interface + ".lease.json") -+ with contextlib.suppress(FileNotFoundError): -+ os.remove(lease_file) -+ -+ # udhcpc needs the interface up to send initial discovery packets -+ subp.subp(["ip", "link", "set", "dev", interface, "up"], capture=True) -+ -+ udhcpc_script = os.path.join(tmp_dir, "udhcpc_script") -+ util.write_file(udhcpc_script, UDHCPC_SCRIPT, 0o755) -+ -+ cmd = [ -+ self.udhcpc_path, -+ "-O", -+ "staticroutes", -+ "-i", -+ interface, -+ "-s", -+ udhcpc_script, -+ "-n", # Exit if lease is not obtained -+ "-q", # Exit after obtaining lease -+ "-f", # Run in foreground -+ "-v", -+ ] -+ -+ # For INFINIBAND port the dhcpc must be running with -+ # client id option. So here we are checking if the interface is -+ # INFINIBAND or not. If yes, we are generating the the client-id to be -+ # used with the udhcpc -+ if is_ib_interface(interface): -+ dhcp_client_identifier = get_ib_interface_hwaddr( -+ interface, ethernet_format=True -+ ) -+ cmd.extend( -+ ["-x", "0x3d:%s" % dhcp_client_identifier.replace(":", "")] -+ ) -+ try: -+ out, err = subp.subp( -+ cmd, update_env={"LEASE_FILE": lease_file}, capture=True -+ ) -+ except subp.ProcessExecutionError as error: -+ LOG.debug( -+ "udhcpc exited with code: %s stderr: %r stdout: %r", -+ error.exit_code, -+ error.stderr, -+ error.stdout, -+ ) -+ raise NoDHCPLeaseError from error -+ -+ if dhcp_log_func is not None: -+ dhcp_log_func(out, err) -+ -+ lease_json = util.load_json(util.load_file(lease_file)) -+ static_routes = lease_json["static_routes"].split() -+ if static_routes: -+ # format: dest1/mask gw1 ... destn/mask gwn -+ lease_json["static_routes"] = [ -+ i for i in zip(static_routes[::2], static_routes[1::2]) -+ ] -+ return [lease_json] -diff --git a/tests/unittests/net/test_dhcp.py b/tests/unittests/net/test_dhcp.py -index 55d4c6e9..9123cd15 100644 ---- a/tests/unittests/net/test_dhcp.py -+++ b/tests/unittests/net/test_dhcp.py -@@ -13,6 +13,8 @@ from cloudinit.net.dhcp import ( - NoDHCPLeaseError, - NoDHCPLeaseInterfaceError, - NoDHCPLeaseMissingDhclientError, -+ NoDHCPLeaseMissingUdhcpcError, -+ Udhcpc, - maybe_perform_dhcp_discovery, - networkd_load_leases, - ) -@@ -388,11 +390,13 @@ class TestDHCPDiscoveryClean(CiTestCase): - self.logs.getvalue(), - ) - -+ @mock.patch("cloudinit.temp_utils.get_tmp_ancestor", return_value="/tmp") - @mock.patch("cloudinit.net.dhcp.find_fallback_nic", return_value="eth9") - @mock.patch("cloudinit.net.dhcp.os.remove") - @mock.patch("cloudinit.net.dhcp.subp.subp") - @mock.patch("cloudinit.net.dhcp.subp.which") -- def test_dhcp_client_failover(self, m_which, m_subp, m_remove, m_fallback): -+ def test_dhcp_client_failover(self, m_which, m_subp, m_remove, m_fallback, -+ m_get_tmp_ancestor): - """Log and do nothing when nic is absent and no fallback is found.""" - m_subp.side_effect = [ - ("", ""), -@@ -928,3 +932,172 @@ class TestEphemeralDhcpLeaseErrors: - pass - - assert len(m_dhcp.mock_calls) == 1 -+ -+ -+class TestUDHCPCDiscoveryClean(CiTestCase): -+ with_logs = True -+ maxDiff = None -+ -+ @mock.patch("cloudinit.temp_utils.get_tmp_ancestor", return_value="/tmp") -+ @mock.patch("cloudinit.net.dhcp.subp.which") -+ @mock.patch("cloudinit.net.dhcp.find_fallback_nic") -+ def test_absent_udhcpc_command(self, m_fallback, m_which, -+ m_get_tmp_ancestor): -+ """When dhclient doesn't exist in the OS, log the issue and no-op.""" -+ m_fallback.return_value = "eth9" -+ m_which.return_value = None # udhcpc isn't found -+ -+ distro = MockDistro() -+ distro.dhcp_client_priority = [Udhcpc] -+ -+ with pytest.raises(NoDHCPLeaseMissingDhclientError): -+ maybe_perform_dhcp_discovery(distro) -+ -+ self.assertIn( -+ "Skip udhcpc configuration: No udhcpc command found.", -+ self.logs.getvalue(), -+ ) -+ -+ @mock.patch("cloudinit.temp_utils.get_tmp_ancestor", return_value="/tmp") -+ @mock.patch("cloudinit.net.dhcp.is_ib_interface", return_value=False) -+ @mock.patch("cloudinit.net.dhcp.subp.which", return_value="/sbin/udhcpc") -+ @mock.patch("cloudinit.net.dhcp.os.remove") -+ @mock.patch("cloudinit.net.dhcp.subp.subp") -+ @mock.patch("cloudinit.util.load_json") -+ @mock.patch("cloudinit.util.load_file") -+ @mock.patch("cloudinit.util.write_file") -+ def test_udhcpc_discovery( -+ self, -+ m_write_file, -+ m_load_file, -+ m_loadjson, -+ m_subp, -+ m_remove, -+ m_which, -+ mocked_is_ib_interface, -+ m_get_tmp_ancestor, -+ ): -+ """dhcp_discovery runs udcpc and parse the dhcp leases.""" -+ m_subp.return_value = ("", "") -+ m_loadjson.return_value = { -+ "interface": "eth9", -+ "fixed-address": "192.168.2.74", -+ "subnet-mask": "255.255.255.0", -+ "routers": "192.168.2.1", -+ "static_routes": "10.240.0.1/32 0.0.0.0 0.0.0.0/0 10.240.0.1", -+ } -+ self.assertEqual( -+ [ -+ { -+ "fixed-address": "192.168.2.74", -+ "interface": "eth9", -+ "routers": "192.168.2.1", -+ "static_routes": [ -+ ("10.240.0.1/32", "0.0.0.0"), -+ ("0.0.0.0/0", "10.240.0.1"), -+ ], -+ "subnet-mask": "255.255.255.0", -+ } -+ ], -+ Udhcpc().dhcp_discovery("eth9", distro=MockDistro()), -+ ) -+ # Interface was brought up before dhclient called -+ m_subp.assert_has_calls( -+ [ -+ mock.call( -+ ["ip", "link", "set", "dev", "eth9", "up"], -+ capture=True, -+ ), -+ mock.call( -+ [ -+ "/sbin/udhcpc", -+ "-O", -+ "staticroutes", -+ "-i", -+ "eth9", -+ "-s", -+ "/tmp/udhcpc_script", -+ "-n", -+ "-q", -+ "-f", -+ "-v", -+ ], -+ update_env={"LEASE_FILE": "/tmp/eth9.lease.json"}, -+ capture=True, -+ ), -+ ] -+ ) -+ -+ @mock.patch("cloudinit.temp_utils.get_tmp_ancestor", return_value="/tmp") -+ @mock.patch("cloudinit.net.dhcp.is_ib_interface", return_value=True) -+ @mock.patch("cloudinit.net.dhcp.get_ib_interface_hwaddr") -+ @mock.patch("cloudinit.net.dhcp.subp.which", return_value="/sbin/udhcpc") -+ @mock.patch("cloudinit.net.dhcp.os.remove") -+ @mock.patch("cloudinit.net.dhcp.subp.subp") -+ @mock.patch("cloudinit.util.load_json") -+ @mock.patch("cloudinit.util.load_file") -+ @mock.patch("cloudinit.util.write_file") -+ def test_udhcpc_discovery_ib( -+ self, -+ m_write_file, -+ m_load_file, -+ m_loadjson, -+ m_subp, -+ m_remove, -+ m_which, -+ m_get_ib_interface_hwaddr, -+ m_is_ib_interface, -+ m_get_tmp_ancestor, -+ ): -+ """dhcp_discovery runs udcpc and parse the dhcp leases.""" -+ m_subp.return_value = ("", "") -+ m_loadjson.return_value = { -+ "interface": "ib0", -+ "fixed-address": "192.168.2.74", -+ "subnet-mask": "255.255.255.0", -+ "routers": "192.168.2.1", -+ "static_routes": "10.240.0.1/32 0.0.0.0 0.0.0.0/0 10.240.0.1", -+ } -+ m_get_ib_interface_hwaddr.return_value = "00:21:28:00:01:cf:4b:01" -+ self.assertEqual( -+ [ -+ { -+ "fixed-address": "192.168.2.74", -+ "interface": "ib0", -+ "routers": "192.168.2.1", -+ "static_routes": [ -+ ("10.240.0.1/32", "0.0.0.0"), -+ ("0.0.0.0/0", "10.240.0.1"), -+ ], -+ "subnet-mask": "255.255.255.0", -+ } -+ ], -+ Udhcpc().dhcp_discovery("ib0", distro=MockDistro()), -+ ) -+ # Interface was brought up before dhclient called -+ m_subp.assert_has_calls( -+ [ -+ mock.call( -+ ["ip", "link", "set", "dev", "ib0", "up"], capture=True -+ ), -+ mock.call( -+ [ -+ "/sbin/udhcpc", -+ "-O", -+ "staticroutes", -+ "-i", -+ "ib0", -+ "-s", -+ "/tmp/udhcpc_script", -+ "-n", -+ "-q", -+ "-f", -+ "-v", -+ "-x", -+ "0x3d:0021280001cf4b01", -+ ], -+ update_env={"LEASE_FILE": "/tmp/ib0.lease.json"}, -+ capture=True, -+ ), -+ ] -+ ) -diff --git a/tools/.github-cla-signers b/tools/.github-cla-signers -index b4a9326e..4d82a055 100644 ---- a/tools/.github-cla-signers -+++ b/tools/.github-cla-signers -@@ -65,6 +65,7 @@ jacobsalmela - jamesottinger - Jehops - jf -+jfroche - Jille - JohnKepplers - johnsonshi --- -2.40.1 - diff --git a/pkgs/tools/virtualization/cloud-init/default.nix b/pkgs/tools/virtualization/cloud-init/default.nix index 5b85bae033afb..edf456d3094e5 100644 --- a/pkgs/tools/virtualization/cloud-init/default.nix +++ b/pkgs/tools/virtualization/cloud-init/default.nix @@ -12,24 +12,23 @@ , coreutils , gitUpdater , busybox +, procps }: python3.pkgs.buildPythonApplication rec { pname = "cloud-init"; - version = "23.2.2"; + version = "23.3.1"; namePrefix = ""; src = fetchFromGitHub { owner = "canonical"; repo = "cloud-init"; rev = "refs/tags/${version}"; - hash = "sha256-lOeLVgT/qTB6JhRcLv9QIfNLMnMyNlUp3dMCqva9Tes="; + hash = "sha256-3UxTqlhLZi/3/buWqDGto4cZN03uONbA8HEWQtaIRxU="; }; patches = [ ./0001-add-nixos-support.patch - # upstream: https://github.com/canonical/cloud-init/pull/4190 - ./0002-Add-Udhcpc-support.patch ]; prePatch = '' @@ -71,10 +70,12 @@ python3.pkgs.buildPythonApplication rec { httpretty dmidecode # needed for tests; at runtime we rather want the setuid wrapper + passlib shadow responses pytest-mock coreutils + procps ]; makeWrapperArgs = [ @@ -84,8 +85,11 @@ python3.pkgs.buildPythonApplication rec { disabledTests = [ # tries to create /var "test_dhclient_run_with_tmpdir" + "test_dhcp_client_failover" # clears path and fails because mkdir is not found "test_path_env_gets_set_from_main" + # fails to find cat + "test_subp_combined_stderr_stdout" # tries to read from /etc/ca-certificates.conf while inside the sandbox "test_handler_ca_certs" "TestRemoveDefaultCaCerts" diff --git a/pkgs/tools/virtualization/distrobuilder/default.nix b/pkgs/tools/virtualization/distrobuilder/default.nix index ac65ea3f54b9d..3619d2f25a14b 100644 --- a/pkgs/tools/virtualization/distrobuilder/default.nix +++ b/pkgs/tools/virtualization/distrobuilder/default.nix @@ -24,7 +24,7 @@ buildGoModule rec { pname = "distrobuilder"; version = "2.1"; - vendorSha256 = "sha256-yRMsf8KfpNmVUX4Rn4ZPLUPFZCT/g78MKAfgbFDPVkE="; + vendorHash = "sha256-yRMsf8KfpNmVUX4Rn4ZPLUPFZCT/g78MKAfgbFDPVkE="; src = fetchFromGitHub { owner = "lxc"; diff --git a/pkgs/tools/virtualization/google-guest-oslogin/default.nix b/pkgs/tools/virtualization/google-guest-oslogin/default.nix index 32ca1ed003553..7600952a45b60 100644 --- a/pkgs/tools/virtualization/google-guest-oslogin/default.nix +++ b/pkgs/tools/virtualization/google-guest-oslogin/default.nix @@ -9,13 +9,13 @@ stdenv.mkDerivation rec { pname = "google-guest-oslogin"; - version = "20230808.00"; + version = "20230831.00"; src = fetchFromGitHub { owner = "GoogleCloudPlatform"; repo = "guest-oslogin"; rev = version; - sha256 = "sha256-6CHMnoPrfXFAgTyIoGPsMos9CaW6W0zcbpIG1j7DRqk="; + sha256 = "sha256-9QCB94HVbeLjioJuSN1Aa+EqFncojPoWFxw5mS9bDGw="; }; postPatch = '' diff --git a/pkgs/tools/virtualization/jumppad/default.nix b/pkgs/tools/virtualization/jumppad/default.nix index 45a3e30603f64..a993fe9484d26 100644 --- a/pkgs/tools/virtualization/jumppad/default.nix +++ b/pkgs/tools/virtualization/jumppad/default.nix @@ -2,15 +2,15 @@ buildGoModule rec { pname = "jumppad"; - version = "0.5.38"; + version = "0.5.51"; src = fetchFromGitHub { owner = "jumppad-labs"; repo = pname; rev = "v${version}"; - hash = "sha256-s779QQ1fzVKFIMoj7X3MLLo1Z3NBSGPoKoDi3xM0fr8="; + hash = "sha256-Az/rNkGwwrYZfay+KjINjIT2PNsoGDNCwZnXZTeKqM4="; }; - vendorHash = "sha256-37j7taSmWhs9NQbv41aljR07HCTRrLd3ddiktV/XKBs="; + vendorHash = "sha256-onUs7ZbnzJGbs+Q+1jvqUp9y9ecOxhtcdx/fkxZntmc="; ldflags = [ "-s" "-w" "-X main.version=${version}" diff --git a/pkgs/tools/virtualization/marathonctl/default.nix b/pkgs/tools/virtualization/marathonctl/default.nix index 12111819c26bf..e8f27e00d851c 100644 --- a/pkgs/tools/virtualization/marathonctl/default.nix +++ b/pkgs/tools/virtualization/marathonctl/default.nix @@ -11,7 +11,7 @@ buildGoModule rec { sha256 = "sha256-MigmvOwYa0uYPexchS4MP74I1Tp6QHYuQVSOh1+FrMg="; }; - vendorSha256 = "sha256-Oiol4KuPOyJq2Bfc5div+enX4kQqYn20itmwWBecuIg="; + vendorHash = "sha256-Oiol4KuPOyJq2Bfc5div+enX4kQqYn20itmwWBecuIg="; ldflags = [ "-s" "-w" ]; diff --git a/pkgs/tools/virtualization/mkosi/default.nix b/pkgs/tools/virtualization/mkosi/default.nix index 345e65d04881c..582f32abfa371 100644 --- a/pkgs/tools/virtualization/mkosi/default.nix +++ b/pkgs/tools/virtualization/mkosi/default.nix @@ -1,52 +1,101 @@ { lib , fetchFromGitHub +, fetchpatch +, stdenv +, python3 +, bubblewrap +, systemd + + # Python packages , setuptools +, setuptools-scm +, wheel , buildPythonApplication , pytestCheckHook -, bubblewrap -, systemd -, stdenv +, pefile + + # Optional dependencies +, withQemu ? false +, qemu +, OVMF }: let # For systemd features used by mkosi, see # https://github.com/systemd/mkosi/blob/19bb5e274d9a9c23891905c4bcbb8f68955a701d/action.yaml#L64-L72 - systemdForMkosi = systemd.override { - # Will be added in #243242 - # withRepart = true; - # withBootloader = true; + systemdForMkosi = (systemd.overrideAttrs (oldAttrs: { + patches = oldAttrs.patches ++ [ + # Enable setting a deterministic verity seed for systemd-repart. Remove when upgrading to systemd 255. + (fetchpatch { + url = "https://github.com/systemd/systemd/commit/81e04781106e3db24e9cf63c1d5fdd8215dc3f42.patch"; + hash = "sha256-KO3poIsvdeepPmXWQXNaJJCPpmBb4sVmO+ur4om9f5k="; + }) + # Propagate SOURCE_DATE_EPOCH to mcopy. Remove when upgrading to systemd 255. + (fetchpatch { + url = "https://github.com/systemd/systemd/commit/4947de275a5553399854cc748f4f13e4ae2ba069.patch"; + hash = "sha256-YIZZyc3f8pQO9fMAxiNhDdV8TtL4pXoh+hwHBzRWtfo="; + }) + ]; + })).override { + withRepart = true; + withBootloader = true; + withSysusers = true; + withFirstboot = true; withEfi = true; withUkify = true; }; + + python3pefile = python3.withPackages (ps: with ps; [ + pefile + ]); in buildPythonApplication rec { pname = "mkosi"; - version = "15.2-pre"; # 15.1 is the latest release, but we require a newer commit + version = "17.1"; format = "pyproject"; src = fetchFromGitHub { owner = "systemd"; repo = "mkosi"; - # Fix from the commit is needed to run on NixOS, - # see https://github.com/systemd/mkosi/issues/1792 - rev = "ca9673cbcbd9f293e5566cec4a1ba14bbcd075b8"; - hash = "sha256-y5gG/g33HBpH1pTXfjHae25bc5p/BvlCm9QxOIYtcA8="; + rev = "v${version}"; + hash = "sha256-v6so6MFOkxPOnPDgAgni517NX4vUnkPd7o4UMSUHL24="; }; + patches = [ + (fetchpatch { + # Fix tests. Remove in next release. + url = "https://github.com/systemd/mkosi/commit/3e2642c743b2ccb78fd0a99e75993824034f7124.patch"; + hash = "sha256-x9xb8Pz7l2FA8pfhQd7KqITxbnjjwBUh0676uggcukI="; + }) + ]; + # Fix ctypes finding library # https://github.com/NixOS/nixpkgs/issues/7307 - patchPhase = lib.optionalString stdenv.isLinux '' - substituteInPlace mkosi/run.py --replace \ - 'ctypes.util.find_library("c")' "'${stdenv.cc.libc}/lib/libc.so.6'" + postPatch = lib.optionalString stdenv.isLinux '' + substituteInPlace mkosi/run.py \ + --replace 'ctypes.util.find_library("c")' "'${stdenv.cc.libc}/lib/libc.so.6'" + substituteInPlace mkosi/__init__.py \ + --replace '/usr/lib/systemd/ukify' "${systemdForMkosi}/lib/systemd/ukify" + '' + lib.optionalString withQemu '' + substituteInPlace mkosi/qemu.py \ + --replace '/usr/share/ovmf/x64/OVMF_VARS.fd' "${OVMF.variables}" \ + --replace '/usr/share/ovmf/x64/OVMF_CODE.fd' "${OVMF.firmware}" ''; nativeBuildInputs = [ setuptools + setuptools-scm + wheel ]; + makeWrapperArgs = [ + "--set MKOSI_INTERPRETER ${python3pefile}/bin/python3" + ]; propagatedBuildInputs = [ systemdForMkosi bubblewrap + ] ++ lib.optional withQemu [ + qemu ]; postInstall = '' @@ -61,6 +110,7 @@ buildPythonApplication rec { meta = with lib; { description = "Build legacy-free OS images"; homepage = "https://github.com/systemd/mkosi"; + changelog = "https://github.com/systemd/mkosi/releases/tag/v${version}"; license = licenses.lgpl21Only; mainProgram = "mkosi"; maintainers = with maintainers; [ malt3 katexochen ]; diff --git a/pkgs/tools/virtualization/reg/default.nix b/pkgs/tools/virtualization/reg/default.nix index eaa937f6f3265..84aecc3ff671d 100644 --- a/pkgs/tools/virtualization/reg/default.nix +++ b/pkgs/tools/virtualization/reg/default.nix @@ -12,7 +12,7 @@ buildGoModule rec { owner = "genuinetools"; repo = "reg"; rev = "v${version}"; - sha256 = "1jlza1czfssssi3y9zi6kr8k9msfa7vp215ibhwbz4h97av5xw5m"; + hash = "sha256-tfBetjoJkr84XLEEcfdRTtc0UZ4m/uRH1Fpr91lQn8o="; }; patches = [ @@ -29,7 +29,7 @@ buildGoModule rec { }) ]; - vendorSha256 = null; + vendorHash = null; doCheck = false; meta = with lib; { diff --git a/pkgs/tools/virtualization/rootlesskit/default.nix b/pkgs/tools/virtualization/rootlesskit/default.nix index d19d4b8d5129a..cfd89ee451e64 100644 --- a/pkgs/tools/virtualization/rootlesskit/default.nix +++ b/pkgs/tools/virtualization/rootlesskit/default.nix @@ -11,7 +11,7 @@ buildGoModule rec { hash = "sha256-QjGjP7GiJiP2bJE707Oc4wZ9o/gRmSboK9xGbbyG5EM="; }; - vendorSha256 = "sha256-mNuj4/e1qH3P5MfbwPLddXWhc8aDcQuoSSHZ+S+zKWw="; + vendorHash = "sha256-mNuj4/e1qH3P5MfbwPLddXWhc8aDcQuoSSHZ+S+zKWw="; passthru = { updateScript = nix-update-script { }; diff --git a/pkgs/tools/virtualization/uefi-run/default.nix b/pkgs/tools/virtualization/uefi-run/default.nix index aacb6f7d583be..9486995538ce5 100644 --- a/pkgs/tools/virtualization/uefi-run/default.nix +++ b/pkgs/tools/virtualization/uefi-run/default.nix @@ -20,6 +20,6 @@ rustPlatform.buildRustPackage rec { description = "Directly run UEFI applications in qemu"; homepage = "https://github.com/Richard-W/uefi-run"; license = licenses.mit; - maintainers = [ maintainers.maddiethecafebabe ]; + maintainers = with maintainers; [ ]; }; } |