From 090a94b268f74e2e6ef8ae0fc4bb50b23f20ba7b Mon Sep 17 00:00:00 2001 From: Gabriel Fontes Date: Fri, 14 Aug 2026 14:30:48 -0300 Subject: [PATCH] fix(system-manager): remove evaluation-time package reads Assisted-by: pi (gpt-5.6-sol) --- hosts/ubuntu/common/global/default.nix | 13 +++++++------ hosts/ubuntu/electra/default.nix | 6 +++++- modules/system-manager/wireless.nix | 22 +++++----------------- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/hosts/ubuntu/common/global/default.nix b/hosts/ubuntu/common/global/default.nix index d3c4f834..ee0c3012 100644 --- a/hosts/ubuntu/common/global/default.nix +++ b/hosts/ubuntu/common/global/default.nix @@ -4,11 +4,12 @@ pkgs, ... }: let - dbusSessionConfig = - builtins.replaceStrings - ["/etc/dbus-1/session.conf"] - [""] - (builtins.readFile "${pkgs.dbus}/share/dbus-1/session.conf"); + dbusSessionConfig = pkgs.runCommandLocal "dbus-session.conf" {} '' + substitute ${pkgs.dbus}/share/dbus-1/session.conf "$out" \ + --replace-fail \ + '/etc/dbus-1/session.conf' \ + "" + ''; in { imports = [ @@ -28,7 +29,7 @@ in { # Nix's D-Bus tools use /etc for their primary config, while Ubuntu keeps the # defaults in /usr/share and reserves /etc for local includes. Remove the # self-include when installing those defaults into /etc. - environment.etc."dbus-1/session.conf".text = dbusSessionConfig; + environment.etc."dbus-1/session.conf".source = dbusSessionConfig; # The management CLI on the system PATH (/run/system-manager/sw/bin), like # nixos-rebuild on NixOS, so switching doesn't need `nix run`. diff --git a/hosts/ubuntu/electra/default.nix b/hosts/ubuntu/electra/default.nix index 3c464c7b..5b5f184b 100644 --- a/hosts/ubuntu/electra/default.nix +++ b/hosts/ubuntu/electra/default.nix @@ -11,5 +11,9 @@ # Pinned rather than auto-detected: with an empty list the upstream module # installs a udev rule that calls /run/current-system/systemd/bin/systemctl, # a path that does not exist outside NixOS. - networking.wireless.interfaces = ["wlp0s20f3"]; + networking.wireless = { + # system-manager lacks the NixOS D-Bus module that installs its policy. + dbusControlled = false; + interfaces = ["wlp0s20f3"]; + }; } diff --git a/modules/system-manager/wireless.nix b/modules/system-manager/wireless.nix index 02176a2a..f5290bbe 100644 --- a/modules/system-manager/wireless.nix +++ b/modules/system-manager/wireless.nix @@ -3,9 +3,9 @@ # # system-manager reuses nixpkgs' systemdUtils, environment.etc and userborn, so # the unit, the generated wpa_supplicant.conf and the wpa_supplicant user all -# come out unchanged. Only a handful of NixOS-only options are missing: three -# are read but never acted on, and the two that do matter are re-expressed on -# top of environment.etc, which the host distro reads from the same paths. +# come out unchanged. Only a handful of NixOS-only options are missing: four +# are read but never acted on, and the udev rules are re-expressed on top of +# environment.etc, which the host distro reads from the same path. { config, lib, @@ -51,19 +51,7 @@ in { }; }; - config = { - environment.etc = lib.mkMerge [ - (lib.mkIf (cfg.udev.extraRules != "") { - "udev/rules.d/99-system-manager.rules".text = cfg.udev.extraRules; - }) - # The attribute name may not carry string context, hence the discard; the - # value keeps its reference to the store path. - (lib.listToAttrs (map (file: { - name = "dbus-1/system.d/" + builtins.unsafeDiscardStringContext (baseNameOf file); - value = {source = file;}; - }) - (lib.concatMap (pkg: lib.filesystem.listFilesRecursive "${pkg}/share/dbus-1/system.d") - (lib.filter (pkg: builtins.pathExists "${pkg}/share/dbus-1/system.d") cfg.dbus.packages)))) - ]; + config = lib.mkIf (cfg.udev.extraRules != "") { + environment.etc."udev/rules.d/99-system-manager.rules".text = cfg.udev.extraRules; }; }