Setting up ReGreet

I’ve been using Sway with greetd+tuigreet, but I’d like to get things looking a little nicer so I looked around and found ReGreet, but as I’m new to NixOS I’m having a bit of trouble understanding what I am required to do to set it up.

A brief look into the regreet entry in the configuration.nix manpage says the following:

programs.regreet.enable
           Enable ReGreet, a clean and customizable greeter for greetd.

           To use ReGreet, services.greetd has to be enabled and services.greetd.settings.default_session should contain the appropriate
           configuration to launch config.programs.regreet.package. For examples, see the ReGreet Readme[1].

           A minimal configuration that launches ReGreet in cage is enabled by this module by default.

The problem lies with the “default_session should contain the appropriate configuration to launch config.programs.regreet.package”, which is very vague and not all helped by the fact that the ReGreet Readme’s steps include creating an extra config file and linking to it:
"
If using Sway, create a sway config file (in a path such as /etc/greetd/sway-config) as follows:

exec "regreet; swaymsg exit"
include /etc/sway/config.d/*

Then, set Sway to use this config (whose path is shown here as /path/to/custom/sway/config) as the default greetd session:

[default_session] command = "sway --config /path/to/custom/sway/config" user = "greeter"

"

I probed around the manpages for sway, and it appears there is not an option to pass the configuration inline, and I cannot find anything in Nix’s configuration that would allow the creation of an extra config file.

I thought about using home manager to create this file, but it seems very wrong mixing these two. Am I missing something obvious?

You’d use something like:

{ config, ... }:
let
  sway-conf = pkgs.writeText "sway-gtkgreet-config" ''
    exec "${config.programs.regreet.package}/bin/regreet; ${config.programs.sway.package}/bin/swaymsg exit"
    include /etc/sway/config.d/*
  '';
in
{
  services.greetd.settings.default_session = {
    command = "${config.programs.sway.package}/bin/sway --config ${sway-conf}";
  };
}

There’s more to it though, you need to set up the environment correctly, and you’ll likely need to modify your X11 session scripts because regreet doesn’t properly implement the xdm spec (because that spec is a mess and very poorly defined).

I have a more extensive config for gtkgreet here, which may help. It’s not going to be identical, but largely similar.

I’d recommend gtkgreet personally because the xdm spec is such a mess - and there is no wayland spec at all - that just hand-writing your WM/DE launch scripts makes way more sense. Plus regreet is kinda sluggish IME

2 Likes