-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
lightdm module: Extract greeter configuration and add theme options #11336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
121 changes: 121 additions & 0 deletions
121
nixos/modules/services/x11/display-managers/lightdm-greeters/gtk.nix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
|
|
||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
typeproperty on thelightdm.greeteroption. It is the type of the option that specifies the behavior of combining multiple values. Check outlib/types.nixfor 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.
There was a problem hiding this comment.
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.