Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions nixos/modules/services/x11/display-managers/lightdm-greeters/gtk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{ config, lib, pkgs, ... }:

with lib;

let

dmcfg = config.services.xserver.displayManager;
ldmcfg = dmcfg.lightdm;
cfg = ldmcfg.greeters.gtk;

inherit (pkgs) stdenv lightdm writeScript writeText;

theme = cfg.theme.package;
icons = cfg.iconTheme.package;

# The default greeter provided with this expression is the GTK greeter.
# Again, we need a few things in the environment for the greeter to run with
# fonts/icons.
wrappedGtkGreeter = stdenv.mkDerivation {
name = "lightdm-gtk-greeter";
buildInputs = [ pkgs.makeWrapper ];

buildCommand = ''
# This wrapper ensures that we actually get themes
makeWrapper ${pkgs.lightdm_gtk_greeter}/sbin/lightdm-gtk-greeter \
$out/greeter \
--prefix PATH : "${pkgs.glibc}/bin" \
--set GDK_PIXBUF_MODULE_FILE "${pkgs.gdk_pixbuf}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" \
--set GTK_PATH "${theme}:${pkgs.gtk3}" \
--set GTK_EXE_PREFIX "${theme}" \
--set GTK_DATA_PREFIX "${theme}" \
--set XDG_DATA_DIRS "${theme}/share:${icons}/share" \
--set XDG_CONFIG_HOME "${theme}/share"

cat - > $out/lightdm-gtk-greeter.desktop << EOF
[Desktop Entry]
Name=LightDM Greeter
Comment=This runs the LightDM Greeter
Exec=$out/greeter
Type=Application
EOF
'';
};

gtkGreeterConf = writeText "lightdm-gtk-greeter.conf"
''
[greeter]
theme-name = ${cfg.theme.name}
icon-theme-name = ${cfg.iconTheme.name}
background = ${ldmcfg.background}
'';

in
{
options = {

services.xserver.displayManager.lightdm.greeters.gtk = {

enable = mkOption {
type = types.bool;
default = true;
description = ''
Whether to enable lightdm-gtk-greeter as the lightdm greeter.
'';
};

theme = {

package = mkOption {
type = types.path;
default = pkgs.gnome3.gnome_themes_standard;
description = ''
The package path that contains the theme given in the name option.
'';
};

name = mkOption {
type = types.str;
default = "Adwaita";
description = ''
Name of the theme to use for the lightdm-gtk-greeter.
'';
};

};

iconTheme = {

package = mkOption {
type = types.path;
default = pkgs.gnome3.defaultIconTheme;
description = ''
The package path that contains the icon theme given in the name option.
'';
};

name = mkOption {
type = types.str;
default = "Adwaita";
description = ''
Name of the icon theme to use for the lightdm-gtk-greeter.
'';
};

};

};

};

config = mkIf cfg.enable {

services.xserver.displayManager.lightdm.greeter = mkDefault {
package = wrappedGtkGreeter;
name = "lightdm-gtk-greeter";
};

environment.etc."lightdm/lightdm-gtk-greeter.conf".source = gtkGreeterConf;

};
}
73 changes: 24 additions & 49 deletions nixos/modules/services/x11/display-managers/lightdm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,6 @@ let
exec ${dmcfg.xserverBin} ${dmcfg.xserverArgs}
'';

theme = pkgs.gnome3.gnome_themes_standard;
icons = pkgs.gnome3.defaultIconTheme;

# The default greeter provided with this expression is the GTK greeter.
# Again, we need a few things in the environment for the greeter to run with
# fonts/icons.
wrappedGtkGreeter = stdenv.mkDerivation {
name = "lightdm-gtk-greeter";
buildInputs = [ pkgs.makeWrapper ];

buildCommand = ''
# This wrapper ensures that we actually get themes
makeWrapper ${pkgs.lightdm_gtk_greeter}/sbin/lightdm-gtk-greeter \
$out/greeter \
--prefix PATH : "${pkgs.glibc}/bin" \
--set GDK_PIXBUF_MODULE_FILE "${pkgs.gdk_pixbuf}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" \
--set GTK_PATH "${theme}:${pkgs.gtk3}" \
--set GTK_EXE_PREFIX "${theme}" \
--set GTK_DATA_PREFIX "${theme}" \
--set XDG_DATA_DIRS "${theme}/share:${icons}/share" \
--set XDG_CONFIG_HOME "${theme}/share"

cat - > $out/lightdm-gtk-greeter.desktop << EOF
[Desktop Entry]
Name=LightDM Greeter
Comment=This runs the LightDM Greeter
Exec=$out/greeter
Type=Application
EOF
'';
};

usersConf = writeText "users.conf"
''
[UserList]
Expand All @@ -72,34 +40,42 @@ let
${cfg.extraSeatDefaults}
'';

gtkGreeterConf = writeText "lightdm-gtk-greeter.conf"
''
[greeter]
theme-name = Adwaita
icon-theme-name = Adwaita
background = ${cfg.background}
'';

in
{
# Note: the order in which lightdm greeter modules are imported
# here determines the default: later modules (if enable) are
# preferred.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand how this comment applies. If I also had a Qt greeter then I would have to explicitly disable the Gtk greeter in order to use the Qt one, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of, if another greeter gets enabled, it should disable the default greeter, similar to how if lightdm is enabled, it disables the default displayManager, slim.

However, if for some reason multiple greeters are enabled, the order of this import list will determine what greeter will be loaded, as every greeter should set the greeter option in this file. The last greeter to be loaded should overwrite the previously configuration in this option, and will thus be the one that is loaded.

As I'm new to nix/nixos I'm not a 100% sure that it works this way, but from what I gathered from other modules, it should. If this is not the way nix works, I'll have to find another way to define which greeter gets loaded by lightdm.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, I'm not entirely sure if it's going to override without specifying the type property on the lightdm.greeter option. It is the type of the option that specifies the behavior of combining multiple values. Check out lib/types.nix for a list of all possible types.

I don't think it's important that this multiple-greeter stuff necessarily works right now though, because we only have Gtk anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, we can check and test the behavior properly when we have another greeter implementation.

However, could we split the single option, that holds the expected configuration, into two separate options; greeter.package & greeter.name. That way we can add proper types and explanation to the config options, and from what I understand of the nix syntax, shouldn't break backwards compatibility.

imports = [
./lightdm-greeters/gtk.nix
];

options = {

services.xserver.displayManager.lightdm = {

enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether to enable lightdm as the display manager.
'';
};

greeter = mkOption {
description = ''
The LightDM greeter to login via. The package should be a directory
containing a .desktop file matching the name in the 'name' option.
'';
default = {
name = "lightdm-gtk-greeter";
package = wrappedGtkGreeter;
greeter = {
package = mkOption {
type = types.path;
description = ''
The LightDM greeter to login via. The package should be a directory
containing a .desktop file matching the name in the 'name' option.
'';

};
name = mkOption {
type = types.string;
description = ''
The name of a .desktop file in the directory specified
in the 'package' option.
'';
};
};

Expand Down Expand Up @@ -135,7 +111,6 @@ in
'';
};

environment.etc."lightdm/lightdm-gtk-greeter.conf".source = gtkGreeterConf;
environment.etc."lightdm/lightdm.conf".source = lightdmConf;
environment.etc."lightdm/users.conf".source = usersConf;

Expand Down