mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-07 05:58:28 -04:00
greeter: migrated dms-greeter to github/AvengeMedia/dank-greeter
This commit is contained in:
@@ -1,290 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
dmsPkgs,
|
||||
options,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) types;
|
||||
cfg = config.programs.dank-material-shell.greeter;
|
||||
cfgDms = config.programs.dank-material-shell;
|
||||
cfgAutoLogin = config.services.displayManager.autoLogin;
|
||||
sessionData = config.services.displayManager.sessionData;
|
||||
|
||||
inherit (config.services.greetd.settings.default_session) user;
|
||||
|
||||
compositorPackage =
|
||||
let
|
||||
configured = lib.attrByPath [ "programs" cfg.compositor.name "package" ] null config;
|
||||
in
|
||||
if configured != null then configured else builtins.getAttr cfg.compositor.name pkgs;
|
||||
|
||||
cacheDir = "/var/lib/dms-greeter";
|
||||
greeterScript = pkgs.writeShellScriptBin "dms-greeter" ''
|
||||
export PATH=$PATH:${
|
||||
lib.makeBinPath [
|
||||
cfg.quickshell.package
|
||||
compositorPackage
|
||||
pkgs.glib # provides gdbus, used by the fprintd hardware probe in GreeterContent.qml
|
||||
pkgs.jq # reads the user's cursor theme from settings.json in dms-greeter
|
||||
]
|
||||
}
|
||||
${
|
||||
lib.escapeShellArgs (
|
||||
[
|
||||
"sh"
|
||||
"${cfg.package}/share/quickshell/dms/Modules/Greetd/assets/dms-greeter"
|
||||
"--cache-dir"
|
||||
cacheDir
|
||||
"--command"
|
||||
cfg.compositor.name
|
||||
"-p"
|
||||
"${cfg.package}/share/quickshell/dms"
|
||||
]
|
||||
++ lib.optionals (cfg.compositor.customConfig != "") [
|
||||
"-C"
|
||||
"${pkgs.writeText "dmsgreeter-compositor-config" cfg.compositor.customConfig}"
|
||||
]
|
||||
)
|
||||
} ${lib.optionalString cfg.logs.save "> ${cfg.logs.path} 2>&1"}
|
||||
'';
|
||||
|
||||
autoLoginCommand =
|
||||
pkgs.runCommand "dms-greeter-autologin-command"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
pkgs.gnugrep
|
||||
pkgs.coreutils
|
||||
];
|
||||
}
|
||||
''
|
||||
set -euo pipefail
|
||||
|
||||
session="${sessionData.autologinSession}"
|
||||
desktops="${sessionData.desktops}"
|
||||
|
||||
for sessionFile in \
|
||||
"$desktops/share/wayland-sessions/$session.desktop" \
|
||||
"$desktops/share/xsessions/$session.desktop"
|
||||
do
|
||||
if [ -f "$sessionFile" ]; then
|
||||
command="$(grep -m1 '^Exec=' "$sessionFile" | cut -d= -f2- || true)"
|
||||
|
||||
if [ -n "$command" ]; then
|
||||
printf '%s\n' "$command" > "$out"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "dms-greeter autologin: could not resolve Exec for session '$session'" >&2
|
||||
exit 1
|
||||
'';
|
||||
|
||||
jq = lib.getExe pkgs.jq;
|
||||
in
|
||||
{
|
||||
imports =
|
||||
let
|
||||
msg = "The option 'programs.dank-material-shell.greeter.compositor.extraConfig' is deprecated. Please use 'programs.dank-material-shell.greeter.compositor.customConfig' instead.";
|
||||
in
|
||||
[
|
||||
(lib.mkRemovedOptionModule [
|
||||
"programs"
|
||||
"dank-material-shell"
|
||||
"greeter"
|
||||
"compositor"
|
||||
"extraConfig"
|
||||
] msg)
|
||||
./dms-rename.nix
|
||||
];
|
||||
|
||||
options.programs.dank-material-shell.greeter = {
|
||||
enable = lib.mkEnableOption "DankMaterialShell greeter";
|
||||
package = lib.mkOption {
|
||||
type = types.package;
|
||||
default = if cfgDms.enable or false then cfgDms.package else dmsPkgs.dms-shell;
|
||||
defaultText = lib.literalExpression ''
|
||||
if config.programs.dank-material-shell.enable
|
||||
then config.programs.dank-material-shell.package
|
||||
else built from source;
|
||||
'';
|
||||
description = ''
|
||||
The DankMaterialShell package to use for the greeter.
|
||||
|
||||
Defaults to the package from `programs.dank-material-shell` if it is enabled,
|
||||
otherwise defaults to building from source.
|
||||
'';
|
||||
};
|
||||
compositor.name = lib.mkOption {
|
||||
type = types.enum [
|
||||
"niri"
|
||||
"hyprland"
|
||||
"sway"
|
||||
"labwc"
|
||||
"mango"
|
||||
"scroll"
|
||||
"miracle"
|
||||
];
|
||||
description = "Compositor to run greeter in";
|
||||
};
|
||||
compositor.customConfig = lib.mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = "Custom compositor config";
|
||||
};
|
||||
configFiles = lib.mkOption {
|
||||
type = types.listOf types.path;
|
||||
default = [ ];
|
||||
description = "Config files to copy into data directory";
|
||||
example = [
|
||||
"/home/user/.config/DankMaterialShell/settings.json"
|
||||
];
|
||||
};
|
||||
configHome = lib.mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
example = "/home/user";
|
||||
description = ''
|
||||
User home directory to copy configurations for greeter
|
||||
If DMS config files are in non-standard locations then use the configFiles option instead
|
||||
'';
|
||||
};
|
||||
quickshell = {
|
||||
package = lib.mkOption {
|
||||
default =
|
||||
if (lib.hasAttrByPath [ "programs" "dank-material-shell" "quickshell" "package" ] options) then
|
||||
config.programs.dank-material-shell.quickshell.package
|
||||
else
|
||||
pkgs.quickshell;
|
||||
|
||||
defaultText = ''
|
||||
if (lib.hasAttrByPath [ "programs" "dank-material-shell" "quickshell" "package" ] options) then
|
||||
config.programs.dank-material-shell.quickshell.package
|
||||
else
|
||||
pkgs.quickshell;
|
||||
'';
|
||||
|
||||
description = ''
|
||||
The quickshell package to use (we recommend at least 0.3.0, currently available in nixos-unstable).
|
||||
Defaults to the same set in `programs.dank-material-shell.quickshell.package`, if using the NixOS module.";
|
||||
'';
|
||||
};
|
||||
};
|
||||
logs.save = lib.mkEnableOption "saving logs from DMS greeter to file";
|
||||
logs.path = lib.mkOption {
|
||||
type = types.path;
|
||||
default = "/tmp/dms-greeter.log";
|
||||
description = ''
|
||||
File path to save DMS greeter logs to
|
||||
'';
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = (config.users.users.${user} or { }) != { };
|
||||
message = ''
|
||||
dmsgreeter: user set for greetd default_session ${user} does not exist. Please create it before referencing it.
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion = cfgAutoLogin.enable -> sessionData.autologinSession != null;
|
||||
message = ''
|
||||
dms-greeter auto-login requires services.displayManager.defaultSession to be set,
|
||||
or at least one session in services.displayManager.sessionPackages.
|
||||
'';
|
||||
}
|
||||
];
|
||||
# DMS currently relies on /etc/pam.d/login for lock screen password auth on NixOS.
|
||||
# Declare security.pam.services.dankshell only if you want to override that runtime fallback.
|
||||
# Do not add pam_u2f or pam_fprintd here for security-key unlock, enable
|
||||
# programs.dank-material-shell.lockscreen.securityKey.enable, which declares the
|
||||
# dedicated dankshell-u2f service DMS drives on its own.
|
||||
# security.pam.services.dankshell = {
|
||||
# # Example: add faillock
|
||||
# faillock.enable = true;
|
||||
# };
|
||||
services.greetd = {
|
||||
enable = lib.mkDefault true;
|
||||
settings = {
|
||||
default_session.command = lib.mkDefault (lib.getExe greeterScript);
|
||||
initial_session = lib.mkIf (cfgAutoLogin.enable && (cfgAutoLogin.user != null)) {
|
||||
inherit (cfgAutoLogin) user;
|
||||
command = ''${lib.getExe pkgs.bash} -lc "${pkgs.systemd}/bin/systemd-cat $(<${autoLoginCommand})"'';
|
||||
};
|
||||
};
|
||||
};
|
||||
fonts.packages = with pkgs; [
|
||||
fira-code
|
||||
inter
|
||||
material-symbols
|
||||
];
|
||||
systemd.tmpfiles.settings."10-dmsgreeter" = {
|
||||
${cacheDir}.d = {
|
||||
inherit user;
|
||||
group =
|
||||
if config.users.users.${user}.group != "" then config.users.users.${user}.group else "greeter";
|
||||
mode = "0750";
|
||||
};
|
||||
};
|
||||
systemd.services.greetd.preStart = ''
|
||||
cd ${cacheDir}
|
||||
${lib.concatStringsSep "\n" (
|
||||
lib.map (f: ''
|
||||
if [ -f "${f}" ]; then
|
||||
cp "${f}" .
|
||||
fi
|
||||
'') cfg.configFiles
|
||||
)}
|
||||
|
||||
if [ -f session.json ]; then
|
||||
copy_wallpaper() {
|
||||
local path=$(${jq} -r ".$1 // empty" session.json)
|
||||
if [ -f "$path" ]; then
|
||||
cp "$path" "$2"
|
||||
${jq} ".$1 = \"${cacheDir}/$2\"" session.json > session.tmp
|
||||
mv session.tmp session.json
|
||||
fi
|
||||
}
|
||||
|
||||
copy_monitor_wallpapers() {
|
||||
${jq} -r ".$1 // {} | to_entries[] | .key + \":\" + .value" session.json 2>/dev/null | while IFS=: read monitor path; do
|
||||
local dest="$2-$(echo "$monitor" | tr -c '[:alnum:]' '-')"
|
||||
if [ -f "$path" ]; then
|
||||
cp "$path" "$dest"
|
||||
${jq} --arg m "$monitor" --arg p "${cacheDir}/$dest" ".$1[\$m] = \$p" session.json > session.tmp
|
||||
mv session.tmp session.json
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
copy_wallpaper "wallpaperPath" "wallpaper"
|
||||
copy_wallpaper "wallpaperPathLight" "wallpaper-light"
|
||||
copy_wallpaper "wallpaperPathDark" "wallpaper-dark"
|
||||
copy_monitor_wallpapers "monitorWallpapers" "wallpaper-monitor"
|
||||
copy_monitor_wallpapers "monitorWallpapersLight" "wallpaper-monitor-light"
|
||||
copy_monitor_wallpapers "monitorWallpapersDark" "wallpaper-monitor-dark"
|
||||
fi
|
||||
|
||||
if [ -f settings.json ]; then
|
||||
theme_file="$(${jq} -r '.customThemeFile // empty' settings.json)"
|
||||
if [ -f "$theme_file" ] && [ -r "$theme_file" ]; then
|
||||
cp "$theme_file" custom-theme.json
|
||||
mv settings.json settings.orig.json
|
||||
${jq} '.customThemeFile = "${cacheDir}/custom-theme.json"' settings.orig.json > settings.json
|
||||
fi
|
||||
fi
|
||||
|
||||
mv dms-colors.json colors.json || :
|
||||
chown ${user}: * || :
|
||||
'';
|
||||
programs.dank-material-shell.greeter.configFiles = lib.mkIf (cfg.configHome != null) [
|
||||
"${cfg.configHome}/.config/DankMaterialShell/settings.json"
|
||||
"${cfg.configHome}/.local/state/DankMaterialShell/session.json"
|
||||
"${cfg.configHome}/.cache/DankMaterialShell/dms-colors.json"
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -9,7 +9,6 @@ rec {
|
||||
paths = [
|
||||
nixos-module
|
||||
nixos-service-start-module
|
||||
greeter-niri-module
|
||||
niri-home-module
|
||||
home-manager-module
|
||||
];
|
||||
@@ -29,13 +28,6 @@ rec {
|
||||
;
|
||||
};
|
||||
|
||||
greeter-niri-module = import ./greeter-niri-module.nix {
|
||||
inherit
|
||||
self
|
||||
pkgs
|
||||
;
|
||||
};
|
||||
|
||||
niri-home-module = import ./niri-home-module.nix {
|
||||
inherit
|
||||
self
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
{
|
||||
self,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
pkgs.testers.runNixOSTest {
|
||||
name = "dms-greeter-niri-module";
|
||||
|
||||
nodes.machine = {
|
||||
imports = [
|
||||
self.nixosModules.greeter
|
||||
];
|
||||
|
||||
users.groups.greeter = { };
|
||||
users.users.greeter = {
|
||||
isSystemUser = true;
|
||||
group = "greeter";
|
||||
};
|
||||
users.users.alice.isNormalUser = true;
|
||||
|
||||
services.greetd.settings.default_session.user = "greeter";
|
||||
services.displayManager.autoLogin = {
|
||||
enable = true;
|
||||
user = "alice";
|
||||
};
|
||||
services.displayManager.defaultSession = "niri";
|
||||
|
||||
programs.niri.enable = true;
|
||||
|
||||
programs.dank-material-shell.greeter = {
|
||||
enable = true;
|
||||
compositor.name = "niri";
|
||||
};
|
||||
|
||||
system.stateVersion = "25.11";
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
import re
|
||||
|
||||
machine.wait_for_unit("multi-user.target")
|
||||
machine.wait_for_unit("greetd.service")
|
||||
|
||||
machine.succeed("systemctl is-enabled greetd.service")
|
||||
machine.succeed("systemctl is-active greetd.service")
|
||||
|
||||
greetd_unit = machine.succeed("cat /etc/systemd/system/greetd.service")
|
||||
config_match = re.search(r'--config (/nix/store[^ ]+-greetd.toml)', greetd_unit)
|
||||
if config_match is None:
|
||||
raise AssertionError(greetd_unit)
|
||||
|
||||
greetd_config_path = config_match.group(1)
|
||||
greetd_config = machine.succeed(f"cat {greetd_config_path}")
|
||||
t.assertIn("dms-greeter", greetd_config)
|
||||
t.assertIn("[initial_session]", greetd_config)
|
||||
|
||||
initial_session = greetd_config.split("[initial_session]", 1)[1]
|
||||
t.assertIn('user = "alice"', initial_session)
|
||||
t.assertIn("systemd-cat", initial_session)
|
||||
|
||||
script_match = re.search(r'command\s*=\s*"([^"]+/bin/dms-greeter)"', greetd_config)
|
||||
if script_match is None:
|
||||
raise AssertionError(greetd_config)
|
||||
|
||||
script_path = script_match.group(1)
|
||||
script = machine.succeed(f"cat {script_path}")
|
||||
t.assertIn("--command", script)
|
||||
t.assertIn("niri", script)
|
||||
t.assertIn("/share/quickshell/dms", script)
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user