11.stylix/modules/regreet/nixos.nix
Flameopathic c8e4a0d218
treewide: optionalize stylix.image option (#717)
Optionalize the stylix.image option when stylix.base16Scheme is set,
making the following Stylix configurations valid:

    [
      // Now it possible to set 'stylix.image = null', if
      // stylix.base16Scheme is set.
      {
        base16Scheme = /* ... */;
      }

      // This configuration was already possible.
      {
        image = /* ... */;
      }

      // This configuration was already possible.
      {
        base16Scheme = /* ... */;
        image = /* ... */;
      }
    ]

Closes: https://github.com/danth/stylix/issues/200
Closes: https://github.com/danth/stylix/issues/442
Link: https://github.com/danth/stylix/pull/717

Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Tested-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Reviewed-by: Daniel Thwaites <danth@danth.me>
2025-02-24 15:13:57 +01:00

63 lines
2 KiB
Nix

{
pkgs,
config,
lib,
...
}:
let
cfg = config.stylix.targets.regreet;
in
{
options.stylix.targets.regreet = {
enable = config.lib.stylix.mkEnableTarget "ReGreet" true;
useWallpaper = config.lib.stylix.mkEnableWallpaper "ReGreet" true;
};
config =
lib.mkIf
(config.stylix.enable && cfg.enable && pkgs.stdenv.hostPlatform.isLinux)
{
warnings =
let
cfg = config.programs.regreet;
in
lib.optional
(
cfg.enable
&&
# defined in https://github.com/NixOS/nixpkgs/blob/8f3e1f807051e32d8c95cd12b9b421623850a34d/nixos/modules/programs/regreet.nix#L153
config.services.greetd.settings.default_session.command
!= "${pkgs.dbus}/bin/dbus-run-session ${lib.getExe pkgs.cage} ${lib.escapeShellArgs cfg.cageArgs} -- ${lib.getExe cfg.package}"
)
"stylix: regreet: custom services.greetd.settings.default_session.command value may not work: ${config.services.greetd.settings.default_session.command}";
programs.regreet = {
settings.GTK.application_prefer_dark_theme = config.stylix.polarity == "dark";
settings.background = lib.mkIf cfg.useWallpaper {
path = config.stylix.image;
fit =
let
inherit (config.stylix) imageScalingMode;
in
if imageScalingMode == "fill" then
"Cover"
else if imageScalingMode == "fit" then
"Contain"
else if imageScalingMode == "stretch" then
"Fill"
# No other available options
else
null;
};
font = {
inherit (config.stylix.fonts.sansSerif) name package;
};
cursorTheme = {
inherit (config.stylix.cursor) name package;
};
theme = {
package = pkgs.adw-gtk3;
name = "adw-gtk3";
};
};
};
}