diff options
author | Robert Helgesson <robert@rycee.net> | 2019-04-11 01:09:27 +0200 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2019-04-11 01:09:27 +0200 |
commit | b6e1d826850fdcd79e067677ec0d5ec20fdf12b7 (patch) | |
tree | 326f79ca1681eff32d9cdf1e50768deb78a05f12 /modules/xsession.nix | |
parent | 6cd5c8fca5ed00099060317a9fa99c1ceed72a83 (diff) |
home-environment: make `home.keyboard` optional
When set to `null` then the `xsession` module will not attempt to
manage the keyboard settings.
Diffstat (limited to 'modules/xsession.nix')
-rw-r--r-- | modules/xsession.nix | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/modules/xsession.nix b/modules/xsession.nix index 1c562dd0dfc..42fe45bb18a 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -66,39 +66,43 @@ in }; config = mkIf cfg.enable { - systemd.user.services.setxkbmap = { - Unit = { - Description = "Set up keyboard in X"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; + systemd.user = { + services = mkIf (config.home.keyboard != null) { + setxkbmap = { + Unit = { + Description = "Set up keyboard in X"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + Type = "oneshot"; + ExecStart = + let + args = concatStringsSep " " ( + [ + "-layout '${config.home.keyboard.layout}'" + "-variant '${config.home.keyboard.variant}'" + ] ++ + (map (v: "-option '${v}'") config.home.keyboard.options) + ); + in + "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${args}"; + }; + }; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; - - Service = { - Type = "oneshot"; - ExecStart = - let - args = concatStringsSep " " ( - [ - "-layout '${config.home.keyboard.layout}'" - "-variant '${config.home.keyboard.variant}'" - ] ++ - (map (v: "-option '${v}'") config.home.keyboard.options) - ); - in - "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${args}"; - }; - }; - - # A basic graphical session target for Home Manager. - systemd.user.targets.hm-graphical-session = { - Unit = { - Description = "Home Manager X session"; - Requires = [ "graphical-session-pre.target" ]; - BindsTo = [ "graphical-session.target" ]; + # A basic graphical session target for Home Manager. + targets.hm-graphical-session = { + Unit = { + Description = "Home Manager X session"; + Requires = [ "graphical-session-pre.target" ]; + BindsTo = [ "graphical-session.target" ]; + }; }; }; |