aboutsummaryrefslogtreecommitdiff
path: root/home-manager/nixos
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2020-02-03 10:05:30 +0100
committerKatharina Fey <kookie@spacekookie.de>2020-02-03 10:05:30 +0100
commitc488527c95c874d3b8743c915173ad7bfb05d5af (patch)
tree2b874dc5606a9dff44096a5e8557f00dc52ac2b6 /home-manager/nixos
parent899a451e08f7d6d2c8214d119c2a0316849a0ed4 (diff)
parent6cc4fd6ede4909226cb81d3475834251ed1b7210 (diff)
Merge commit '6cc4fd6ede4909226cb81d3475834251ed1b7210'
Diffstat (limited to 'home-manager/nixos')
-rw-r--r--home-manager/nixos/default.nix145
1 files changed, 68 insertions, 77 deletions
diff --git a/home-manager/nixos/default.nix b/home-manager/nixos/default.nix
index f53b4d4d6b7..f4e417bda71 100644
--- a/home-manager/nixos/default.nix
+++ b/home-manager/nixos/default.nix
@@ -6,34 +6,38 @@ let
cfg = config.home-manager;
- hmModule = types.submodule ({name, ...}: {
- imports = import ../modules/modules.nix { inherit lib pkgs; };
-
- config = {
- submoduleSupport.enable = true;
- submoduleSupport.externalPackageInstall = cfg.useUserPackages;
-
- # The per-user directory inside /etc/profiles is not known by
- # fontconfig by default.
- fonts.fontconfig.enable =
- cfg.useUserPackages && config.fonts.fontconfig.enable;
-
- home.username = config.users.users.${name}.name;
- home.homeDirectory = config.users.users.${name}.home;
- };
- });
-
- serviceEnvironment =
- optionalAttrs (cfg.backupFileExtension != null) {
- HOME_MANAGER_BACKUP_EXT = cfg.backupFileExtension;
- }
- // optionalAttrs cfg.verbose {
- VERBOSE = "1";
- };
+ extendedLib = import ../modules/lib/stdlib-extended.nix pkgs.lib;
+
+ hmModule = types.submoduleWith {
+ specialArgs = { lib = extendedLib; };
+ modules = [
+ ({ name, ... }: {
+ imports = import ../modules/modules.nix {
+ inherit pkgs;
+ lib = extendedLib;
+ };
+
+ config = {
+ submoduleSupport.enable = true;
+ submoduleSupport.externalPackageInstall = cfg.useUserPackages;
+
+ # The per-user directory inside /etc/profiles is not known by
+ # fontconfig by default.
+ fonts.fontconfig.enable = cfg.useUserPackages
+ && config.fonts.fontconfig.enable;
+
+ home.username = config.users.users.${name}.name;
+ home.homeDirectory = config.users.users.${name}.home;
+ };
+ })
+ ];
+ };
-in
+ serviceEnvironment = optionalAttrs (cfg.backupFileExtension != null) {
+ HOME_MANAGER_BACKUP_EXT = cfg.backupFileExtension;
+ } // optionalAttrs cfg.verbose { VERBOSE = "1"; };
-{
+in {
options = {
home-manager = {
useUserPackages = mkEnableOption ''
@@ -55,7 +59,7 @@ in
users = mkOption {
type = types.attrsOf hmModule;
- default = {};
+ default = { };
description = ''
Per-user Home Manager configuration.
'';
@@ -63,57 +67,44 @@ in
};
};
- config = mkIf (cfg.users != {}) {
- warnings =
- flatten (flip mapAttrsToList cfg.users (user: config:
- flip map config.warnings (warning:
- "${user} profile: ${warning}"
- )
- ));
-
- assertions =
- flatten (flip mapAttrsToList cfg.users (user: config:
- flip map config.assertions (assertion:
- {
- inherit (assertion) assertion;
- message = "${user} profile: ${assertion.message}";
- }
- )
- ));
-
- users.users = mkIf cfg.useUserPackages (
- mapAttrs (username: usercfg: {
- packages = usercfg.home.packages;
- }) cfg.users
- );
+ config = mkIf (cfg.users != { }) {
+ warnings = flatten (flip mapAttrsToList cfg.users (user: config:
+ flip map config.warnings (warning: "${user} profile: ${warning}")));
+
+ assertions = flatten (flip mapAttrsToList cfg.users (user: config:
+ flip map config.assertions (assertion: {
+ inherit (assertion) assertion;
+ message = "${user} profile: ${assertion.message}";
+ })));
+
+ users.users = mkIf cfg.useUserPackages
+ (mapAttrs (username: usercfg: { packages = usercfg.home.packages; })
+ 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" ];
-
- environment = serviceEnvironment;
-
- serviceConfig = {
- User = usercfg.home.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.runtimeShell} -el
- echo Activating home-manager configuration for ${username}
- exec ${usercfg.home.activationPackage}/activate
- '';
- };
- }
- ) cfg.users;
+ 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" ];
+
+ environment = serviceEnvironment;
+
+ serviceConfig = {
+ User = usercfg.home.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.runtimeShell} -el
+ echo Activating home-manager configuration for ${username}
+ exec ${usercfg.home.activationPackage}/activate
+ '';
+ };
+ }) cfg.users;
};
}