From 7fed7a400d3605d8a390607eaabda0fba00d900f Mon Sep 17 00:00:00 2001 From: nikstur Date: Tue, 21 Apr 2026 18:50:12 +0200 Subject: [PATCH 1/8] nixos/systemd/initrd: fix modprobe Contains the same fix as in d36077c0b686c91cea9d20edd58da632d4f28318 but now for the initrd. --- nixos/modules/system/boot/systemd/initrd.nix | 4 ++++ nixos/tests/systemd-initrd-modprobe.nix | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix index 370fceb94844..3dd954a526bb 100644 --- a/nixos/modules/system/boot/systemd/initrd.nix +++ b/nixos/modules/system/boot/systemd/initrd.nix @@ -640,6 +640,10 @@ in ) cfg.automounts ); + services."modprobe@" = lib.mkIf (config.system.build.kernel.config.isYes "MODULES") { + serviceConfig.ExecSearchPath = lib.makeBinPath [ cfg.package.kmod ]; + }; + services.initrd-find-nixos-closure = lib.mkIf (!config.system.nixos-init.enable) { description = "Find NixOS closure"; diff --git a/nixos/tests/systemd-initrd-modprobe.nix b/nixos/tests/systemd-initrd-modprobe.nix index 88237f5ab801..894de6e29ffd 100644 --- a/nixos/tests/systemd-initrd-modprobe.nix +++ b/nixos/tests/systemd-initrd-modprobe.nix @@ -18,6 +18,10 @@ rtt = machine.succeed("cat /sys/module/tcp_hybla/parameters/rtt0") assert int(rtt) == 42, "Parameter should be respected for initrd kernel modules" + with subtest("modprobe@ services work"): + modprobe_service_status = machine.succeed("systemctl show --property ExecMainStatus modprobe@9pnet_virtio.service") + t.assertEqual("ExecMainStatus=0\n", modprobe_service_status) + # Make sure it sticks in stage 2 machine.switch_root() machine.wait_for_unit("multi-user.target") From 2c7f0d79701976cc68481e6ed23e245e860da2b1 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 21 Apr 2026 19:08:54 +0100 Subject: [PATCH 2/8] nixos-rebuild-ng: mock pathlib.Path.exists in test_upgrade_channels This should avoid make it try to call the real path to see if it exists. Seems to be an issue in a particular setup in aarch64-darwin at least, but I can't reproduce. Fix: #511860. --- pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py b/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py index f8c6d75c5290..8fb4d5ef166e 100644 --- a/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py +++ b/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py @@ -892,11 +892,13 @@ def test_switch_to_configuration_with_systemd_run( ], ) @patch("pathlib.Path.is_dir", autospec=True, return_value=True) +@patch("pathlib.Path.exists", autospec=True, return_value=False) @patch("os.geteuid", autospec=True, return_value=1000) @patch(get_qualified_name(n.run_wrapper, n), autospec=True) def test_upgrade_channels( mock_run: Mock, mock_geteuid: Mock, + mock_exists: Mock, mock_is_dir: Mock, mock_glob: Mock, ) -> None: @@ -912,7 +914,11 @@ def test_upgrade_channels( ["nix-channel", "--update", "nixos"], check=False, sudo=True ) + # root check mock_geteuid.return_value = 0 + # (channel_path / ".update-on-nixos-rebuild").exists() + mock_exists.return_value = True + n.upgrade_channels(all_channels=True, sudo=False) mock_run.assert_has_calls( [ From 4cec3122850f3aa592b04648c1088268bc6144a6 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 21 Apr 2026 20:01:49 +0100 Subject: [PATCH 3/8] nixos-rebuild-ng: refactor test_upgrade_channels --- .../nixos-rebuild-ng/src/nixos_rebuild/nix.py | 8 ++- .../ni/nixos-rebuild-ng/src/tests/test_nix.py | 67 +++++++++++-------- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py b/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py index c825320eae74..c6b5b4d63c45 100644 --- a/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py +++ b/pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py @@ -726,7 +726,11 @@ def switch_to_configuration( ) -def upgrade_channels(all_channels: bool = False, sudo: bool = False) -> None: +def upgrade_channels( + all_channels: bool = False, + sudo: bool = False, + channels_dir: Path = Path("/nix/var/nix/profiles/per-user/root/channels/"), +) -> None: """Upgrade channels for classic Nix. It will either upgrade just the `nixos` channel (including any channel @@ -739,7 +743,7 @@ def upgrade_channels(all_channels: bool = False, sudo: bool = False) -> None: ) channel_updated = False - for channel_path in Path("/nix/var/nix/profiles/per-user/root/channels/").glob("*"): + for channel_path in channels_dir.glob("*"): if channel_path.is_dir() and ( all_channels or channel_path.name == "nixos" diff --git a/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py b/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py index 8fb4d5ef166e..bccb2f196970 100644 --- a/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py +++ b/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py @@ -882,50 +882,61 @@ def test_switch_to_configuration_with_systemd_run( ) -@patch( - "pathlib.Path.glob", - autospec=True, - return_value=[ - Path("/nix/var/nix/profiles/per-user/root/channels/nixos"), - Path("/nix/var/nix/profiles/per-user/root/channels/nixos-hardware"), - Path("/nix/var/nix/profiles/per-user/root/channels/home-manager"), - ], -) -@patch("pathlib.Path.is_dir", autospec=True, return_value=True) -@patch("pathlib.Path.exists", autospec=True, return_value=False) @patch("os.geteuid", autospec=True, return_value=1000) @patch(get_qualified_name(n.run_wrapper, n), autospec=True) -def test_upgrade_channels( - mock_run: Mock, - mock_geteuid: Mock, - mock_exists: Mock, - mock_is_dir: Mock, - mock_glob: Mock, -) -> None: +def test_upgrade_channels(mock_run: Mock, mock_geteuid: Mock, tmpdir: Path) -> None: + tmp_path = Path(tmpdir) + with pytest.raises(m.NixOSRebuildError) as e: - n.upgrade_channels(all_channels=False, sudo=False) + n.upgrade_channels(all_channels=False, sudo=False, channels_dir=tmp_path) assert str(e.value) == ( "error: if you pass the '--upgrade' or '--upgrade-all' flag, you must " "also pass '--sudo' or run the command as root (e.g., with sudo)" ) - n.upgrade_channels(all_channels=False, sudo=True) - mock_run.assert_called_once_with( - ["nix-channel", "--update", "nixos"], check=False, sudo=True + (tmp_path / "nixos").mkdir() + (tmp_path / "nixos-hardware").mkdir() + (tmp_path / "nixos-hardware" / ".update-on-nixos-rebuild").touch() + (tmp_path / "home-manager").mkdir() + + # should work because we are passing sudo=True even with os.geteuid == 1000 + n.upgrade_channels(all_channels=False, sudo=True, channels_dir=tmp_path) + mock_run.assert_has_calls( + [ + call( + ["nix-channel", "--update", "nixos-hardware"], + check=False, + sudo=True, + ), + call( + ["nix-channel", "--update", "nixos"], + check=False, + sudo=True, + ), + ] ) + mock_run.reset_mock() # root check mock_geteuid.return_value = 0 - # (channel_path / ".update-on-nixos-rebuild").exists() - mock_exists.return_value = True - n.upgrade_channels(all_channels=True, sudo=False) + n.upgrade_channels(all_channels=True, sudo=False, channels_dir=tmp_path) mock_run.assert_has_calls( [ - call(["nix-channel", "--update", "nixos"], check=False, sudo=False), call( - ["nix-channel", "--update", "nixos-hardware"], check=False, sudo=False + ["nix-channel", "--update", "home-manager"], + check=False, + sudo=False, + ), + call( + ["nix-channel", "--update", "nixos-hardware"], + check=False, + sudo=False, + ), + call( + ["nix-channel", "--update", "nixos"], + check=False, + sudo=False, ), - call(["nix-channel", "--update", "home-manager"], check=False, sudo=False), ] ) From f666e9f83681577480b6e04b6a47c2d29e72d4f1 Mon Sep 17 00:00:00 2001 From: K900 Date: Wed, 22 Apr 2026 18:44:08 +0300 Subject: [PATCH 4/8] nixos-rebuild-ng: don't assert on exact order of calls Depends on filesystem ordering semantics. --- pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py b/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py index bccb2f196970..9b225eca4e84 100644 --- a/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py +++ b/pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py @@ -913,7 +913,8 @@ def test_upgrade_channels(mock_run: Mock, mock_geteuid: Mock, tmpdir: Path) -> N check=False, sudo=True, ), - ] + ], + any_order=True, ) mock_run.reset_mock() @@ -938,5 +939,6 @@ def test_upgrade_channels(mock_run: Mock, mock_geteuid: Mock, tmpdir: Path) -> N check=False, sudo=False, ), - ] + ], + any_order=True, ) From a9d60f3c4dddfbba6ec759e5e29a1c32bdf6fa82 Mon Sep 17 00:00:00 2001 From: K900 Date: Wed, 22 Apr 2026 18:31:30 +0300 Subject: [PATCH 5/8] linux_7_0: 7.0 -> 7.0.1 --- pkgs/os-specific/linux/kernel/kernels-org.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/kernels-org.json b/pkgs/os-specific/linux/kernel/kernels-org.json index a6e58099a242..e06aa4ad0c27 100644 --- a/pkgs/os-specific/linux/kernel/kernels-org.json +++ b/pkgs/os-specific/linux/kernel/kernels-org.json @@ -40,8 +40,8 @@ "lts": false }, "7.0": { - "version": "7.0", - "hash": "sha256:1w4i705i0nl1xqv7fdhdbhy7j3xrzhl31fabs6vmgiw7nf06szxv", + "version": "7.0.1", + "hash": "sha256:1gw7v1j0pp2w6fm5y1n0krhnfvgab2jkrvcvwl8hx614dnikbjdj", "lts": false } } From 28ed039c78a6feb946d5111f9e40f72ac3418221 Mon Sep 17 00:00:00 2001 From: K900 Date: Wed, 22 Apr 2026 18:31:38 +0300 Subject: [PATCH 6/8] linux_6_19: 6.19.13 -> 6.19.14 --- pkgs/os-specific/linux/kernel/kernels-org.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/kernels-org.json b/pkgs/os-specific/linux/kernel/kernels-org.json index e06aa4ad0c27..d3eb3a1617bd 100644 --- a/pkgs/os-specific/linux/kernel/kernels-org.json +++ b/pkgs/os-specific/linux/kernel/kernels-org.json @@ -35,8 +35,8 @@ "lts": true }, "6.19": { - "version": "6.19.13", - "hash": "sha256:0j2ncikwi4mkx9v33ahzmi2qq2bx5f82701nnha1grs0lzzb2n85", + "version": "6.19.14", + "hash": "sha256:11giqsz9qa7s9lm94nn4h1bcb2411crsbfyvzrvhfjmy75kvzs6d", "lts": false }, "7.0": { From 0b01c28e67a1a33bf0e13db453a0563c4fc56f49 Mon Sep 17 00:00:00 2001 From: K900 Date: Wed, 22 Apr 2026 18:31:45 +0300 Subject: [PATCH 7/8] linux_6_18: 6.18.23 -> 6.18.24 --- pkgs/os-specific/linux/kernel/kernels-org.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/kernels-org.json b/pkgs/os-specific/linux/kernel/kernels-org.json index d3eb3a1617bd..21e09362052f 100644 --- a/pkgs/os-specific/linux/kernel/kernels-org.json +++ b/pkgs/os-specific/linux/kernel/kernels-org.json @@ -30,8 +30,8 @@ "lts": true }, "6.18": { - "version": "6.18.23", - "hash": "sha256:0d2ihdz5hdy1ywhck76y9rnzzvkl2lhrb5xvc6w5l4ydpxv8wb9a", + "version": "6.18.24", + "hash": "sha256:0pr5s7hkmn7n17bm7p6sqrkq8g9z42jnvqihv96kn42qrrbwa1y2", "lts": true }, "6.19": { From 7138b26451e6ccb06b62884ce76edb46e358df75 Mon Sep 17 00:00:00 2001 From: K900 Date: Wed, 22 Apr 2026 18:31:49 +0300 Subject: [PATCH 8/8] linux_6_12: 6.12.82 -> 6.12.83 --- pkgs/os-specific/linux/kernel/kernels-org.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/kernels-org.json b/pkgs/os-specific/linux/kernel/kernels-org.json index 21e09362052f..b6e78ceacaa9 100644 --- a/pkgs/os-specific/linux/kernel/kernels-org.json +++ b/pkgs/os-specific/linux/kernel/kernels-org.json @@ -25,8 +25,8 @@ "lts": true }, "6.12": { - "version": "6.12.82", - "hash": "sha256:1a8r1wzfssrnqbf4yvbcfynf5w6la4vy1w5wlns1p63krl2hnmqf", + "version": "6.12.83", + "hash": "sha256:0cfzvhm876jm61cy023apwmi5axjilwfc0xnag9jd9fzs4n1gqrr", "lts": true }, "6.18": {