2017-10-14 18:56:02 +00:00
|
|
|
{ config, lib, pkgs, utils, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.home-manager;
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
serviceEnvironment = optionalAttrs (cfg.backupFileExtension != null) {
|
|
|
|
HOME_MANAGER_BACKUP_EXT = cfg.backupFileExtension;
|
|
|
|
} // optionalAttrs cfg.verbose { VERBOSE = "1"; };
|
2017-10-14 18:56:02 +00:00
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
in {
|
2022-06-07 18:45:06 +00:00
|
|
|
imports = [ ../integration-common.nix ];
|
2021-02-21 06:02:25 +00:00
|
|
|
|
2022-06-07 18:45:06 +00:00
|
|
|
config = mkMerge [
|
|
|
|
{
|
|
|
|
home-manager = {
|
|
|
|
extraSpecialArgs.nixosConfig = config;
|
2021-02-21 06:02:25 +00:00
|
|
|
|
2022-06-07 18:45:06 +00:00
|
|
|
sharedModules = [{
|
|
|
|
# The per-user directory inside /etc/profiles is not known by
|
|
|
|
# fontconfig by default.
|
2022-06-13 18:00:51 +00:00
|
|
|
fonts.fontconfig.enable = lib.mkDefault cfg.useUserPackages
|
2022-06-07 18:45:06 +00:00
|
|
|
&& config.fonts.fontconfig.enable;
|
|
|
|
}];
|
2017-12-19 14:43:40 +00:00
|
|
|
};
|
2022-06-07 18:45:06 +00:00
|
|
|
}
|
|
|
|
(mkIf (cfg.users != { }) {
|
|
|
|
systemd.services = mapAttrs' (_: usercfg:
|
|
|
|
let username = usercfg.home.username;
|
|
|
|
in nameValuePair ("home-manager-${utils.escapeSystemdPath username}") {
|
|
|
|
description = "Home Manager environment for ${username}";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
wants = [ "nix-daemon.socket" ];
|
|
|
|
after = [ "nix-daemon.socket" ];
|
|
|
|
before = [ "systemd-user-sessions.service" ];
|
|
|
|
|
|
|
|
environment = serviceEnvironment;
|
|
|
|
|
|
|
|
unitConfig = { RequiresMountsFor = usercfg.home.homeDirectory; };
|
|
|
|
|
|
|
|
stopIfChanged = false;
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = usercfg.home.username;
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = "yes";
|
|
|
|
TimeoutStartSec = 90;
|
|
|
|
SyslogIdentifier = "hm-activate-${username}";
|
|
|
|
|
|
|
|
ExecStart = let
|
|
|
|
systemctl =
|
|
|
|
"XDG_RUNTIME_DIR=\${XDG_RUNTIME_DIR:-/run/user/$UID} systemctl";
|
|
|
|
|
|
|
|
sed = "${pkgs.gnused}/bin/sed";
|
|
|
|
|
|
|
|
exportedSystemdVariables = concatStringsSep "|" [
|
|
|
|
"DBUS_SESSION_BUS_ADDRESS"
|
|
|
|
"DISPLAY"
|
|
|
|
"WAYLAND_DISPLAY"
|
|
|
|
"XAUTHORITY"
|
|
|
|
"XDG_RUNTIME_DIR"
|
|
|
|
];
|
|
|
|
|
|
|
|
setupEnv = pkgs.writeScript "hm-setup-env" ''
|
|
|
|
#! ${pkgs.runtimeShell} -el
|
|
|
|
|
|
|
|
# The activation script is run by a login shell to make sure
|
|
|
|
# that the user is given a sane environment.
|
|
|
|
# If the user is logged in, import variables from their current
|
|
|
|
# session environment.
|
|
|
|
eval "$(
|
|
|
|
${systemctl} --user show-environment 2> /dev/null \
|
|
|
|
| ${sed} -En '/^(${exportedSystemdVariables})=/s/^/export /p'
|
|
|
|
)"
|
|
|
|
|
|
|
|
exec "$1/activate"
|
|
|
|
'';
|
|
|
|
in "${setupEnv} ${usercfg.home.activationPackage}";
|
|
|
|
};
|
|
|
|
}) cfg.users;
|
|
|
|
})
|
|
|
|
];
|
2017-10-14 18:56:02 +00:00
|
|
|
}
|