nixos: pass driver version to user service

The user-service drop-in invoked activate without a driver version, so
the script defaulted to driver 0 and always managed the per-user
home-manager profile, ignoring enableLegacyProfileManagement. Use the
same version as the system service and assert both generated
user-service commands.
This commit is contained in:
Austin Horstman
2026-09-29 22:51:37 -05:00
committed by GitHub
parent b0d0106ef6
commit c421f4751f
2 changed files with 24 additions and 2 deletions
+2 -2
View File
@@ -9,6 +9,7 @@
let
inherit (lib) mkIf;
cfg = config.home-manager;
driverVersion = if cfg.enableLegacyProfileManagement then "0" else "1";
baseService = username: {
Type = "oneshot";
@@ -75,7 +76,6 @@ in
_: usercfg:
let
inherit (usercfg.home) username homeDirectory activationPackage;
driverVersion = if cfg.enableLegacyProfileManagement then "0" else "1";
in
lib.nameValuePair "home-manager-${utils.escapeSystemdPath username}" (
lib.attrsets.recursiveUpdate (baseUnit username) {
@@ -145,7 +145,7 @@ in
packages = [
(pkgs.writeTextDir "${hmDropIn}/10-user-activation.conf" ''
[Service]
ExecStart=${home.activationPackage}/activate
ExecStart=${home.activationPackage}/activate --driver-version ${driverVersion}
'')
];
}
@@ -50,7 +50,29 @@
let
legacy = "${nodes.machine.system.build.toplevel}/specialisation/legacy";
modern = "${nodes.machine.system.build.toplevel}/specialisation/modern";
userServiceDropIn =
enableLegacyProfileManagement:
let
nixosEval = import "${pkgs.path}/nixos/lib/eval-config.nix" {
system = pkgs.stdenv.hostPlatform.system;
modules = [
../../../nixos
{
system.stateVersion = "24.11";
users.users.alice.isNormalUser = true;
home-manager = {
startAsUserService = true;
inherit enableLegacyProfileManagement;
users.alice.home.stateVersion = "24.11";
};
}
];
};
in
(builtins.head nixosEval.config.users.users.alice.packages).text;
in
assert pkgs.lib.hasInfix " --driver-version 0\n" (userServiceDropIn true);
assert pkgs.lib.hasInfix " --driver-version 1\n" (userServiceDropIn false);
''
start_all()