2017-10-14 20:56:02 +02:00
|
|
|
{ config, lib, pkgs, utils, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.home-manager;
|
|
|
|
|
|
|
|
hmModule = types.submodule ({name, ...}: {
|
|
|
|
imports = import ../modules/modules.nix {
|
|
|
|
inherit lib pkgs;
|
|
|
|
nixosSubmodule = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
home.username = config.users.users.${name}.name;
|
|
|
|
home.homeDirectory = config.users.users.${name}.home;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
home-manager.users = mkOption {
|
|
|
|
type = types.attrsOf hmModule;
|
|
|
|
default = {};
|
|
|
|
description = ''
|
|
|
|
Per-user Home Manager configuration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf (cfg.users != {}) {
|
|
|
|
systemd.services = mapAttrs' (username: usercfg:
|
|
|
|
nameValuePair ("home-manager-${utils.escapeSystemdPath username}") {
|
|
|
|
description = "Home Manager environment for ${username}";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2018-07-21 13:15:34 +02:00
|
|
|
wants = [ "nix-daemon.socket" ];
|
|
|
|
after = [ "nix-daemon.socket" ];
|
2017-10-14 20:56:02 +02:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = username;
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = "yes";
|
|
|
|
SyslogIdentifier = "hm-activate-${username}";
|
|
|
|
|
|
|
|
# The activation script is run by a login shell to make sure
|
|
|
|
# that the user is given a sane Nix environment.
|
|
|
|
ExecStart = pkgs.writeScript "activate-${username}" ''
|
|
|
|
#! ${pkgs.stdenv.shell} -el
|
|
|
|
echo Activating home-manager configuration for ${username}
|
|
|
|
exec ${usercfg.home.activationPackage}/activate
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|
|
|
|
) cfg.users;
|
|
|
|
};
|
|
|
|
}
|