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
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,14 @@ programs.noctalia-greeter = {

# Optional configuration
greeter-args = "";
settings.cursor = {
theme = "Adwaita";
size = 24;
package = pkgs.adwaita-icon-theme;
settings = {
cursor = {
theme = "Adwaita";
size = 24;
};
keyboard = {
layout = "us";
};
};
};
```
Expand All @@ -137,6 +141,9 @@ The module enables greetd and sets the session command automatically.
`--session <name>` to set a default session. Run `noctalia-greeter sessions`
to list valid names.

`settings` accepts a Nix attrset, a raw TOML string, or a path to a `.toml` file,
and is copied to `/var/lib/noctalia-greeter/greeter.toml` on boot.

## Building and installing

Requires [just](https://github.com/casey/just) and [meson](https://mesonbuild.com/).
Expand Down Expand Up @@ -314,9 +321,7 @@ command = "env XCURSOR_THEME=Adwaita XCURSOR_SIZE=24 /usr/bin/noctalia-greeter-s
```

If the theme is not under the default search path, also set
`XCURSOR_PATH` (or `cursor_path`) to the directory that contains it. On NixOS,
use the `programs.noctalia-greeter.settings.cursor` options instead, which wire this up
for you.
`XCURSOR_PATH` (or `cursor.path`) to the directory that contains it.

## Keyboard

Expand Down
85 changes: 48 additions & 37 deletions nix/nixos-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
}:
let
cfg = config.programs.noctalia-greeter;
tomlFormat = pkgs.formats.toml { };

generateToml =
name: value:
if lib.isString value then
pkgs.writeText name value
else if builtins.isPath value || lib.isStorePath value then
value
else
tomlFormat.generate name value;
in
{
options.programs.noctalia-greeter = {
Expand All @@ -22,45 +32,41 @@ in
description = "Arguments to add onto noctalia-greeter-session command.";
};

settings.cursor = {
theme = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "Adwaita";
description = ''
Cursor theme name for the greeter.
'';
};

size = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
example = 24;
description = "Cursor size for the greeter.";
};

package = lib.mkOption {
type = lib.types.nullOr lib.types.package;
default = null;
example = lib.literalExpression "pkgs.adwaita-icon-theme";
description = ''
Package providing the cursor theme.
'';
};
settings = lib.mkOption {
type =
with lib.types;
oneOf [
tomlFormat.type
str
path
];
default = { };
description = ''
Settings for noctalia-greeter written to greeter.toml.
Can be written as:
- A Nix attrset (converted to TOML via nixpkgs' tomlFormat)
- A raw TOML string
- A path to a `.toml` file
'';
example = lib.literalExpression ''
{
cursor = {
theme = "Adwaita";
size = 24;
};
keyboard = {
layout = "us";
};
}
'';
};
};

config =
let
user = config.services.greetd.settings.default_session.user;
cursor = cfg.settings.cursor;
cursorEnv =
lib.optional (cursor.theme != null) "XCURSOR_THEME=${cursor.theme}"
++ lib.optional (cursor.size != null) "XCURSOR_SIZE=${toString cursor.size}"
++ lib.optional (cursor.package != null) "XCURSOR_PATH=${cursor.package}/share/icons";
envPrefix = lib.optionalString (
cursorEnv != [ ]
) "${pkgs.coreutils}/bin/env ${lib.concatStringsSep " " cursorEnv} ";
group =
if config.users.users.${user}.group != "" then config.users.users.${user}.group else "greeter";
in
lib.mkIf cfg.enable {
environment.systemPackages = [
Expand All @@ -69,16 +75,21 @@ in

systemd.tmpfiles.settings."10-noctalia-greeter" = {
"/var/lib/noctalia-greeter".d = {
inherit user;
group =
if config.users.users.${user}.group != "" then config.users.users.${user}.group else "greeter";
inherit user group;
mode = "0750";
};
}
// lib.optionalAttrs (cfg.settings != { }) {
"/var/lib/noctalia-greeter/greeter.toml".C = {
argument = generateToml "greeter.toml" cfg.settings;
inherit user group;
mode = "0644";
};
};

services.greetd = {
enable = lib.mkDefault true;
settings.default_session.command = lib.mkDefault "${envPrefix}${cfg.package}/bin/noctalia-greeter-session -- ${cfg.greeter-args}";
settings.default_session.command = lib.mkDefault "${cfg.package}/bin/noctalia-greeter-session -- ${cfg.greeter-args}";
};

assertions = [
Expand Down
Loading