Skip to content
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

update ly to unstable version and add nixos/ly module #297434

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions nixos/doc/manual/release-notes/rl-2411.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

- Create the first release note entry in this section!

- A new display-manager `services.displayManager.ly` was added.
It is a tui based replacement of sddm and lightdm for window manager users.
Users can use it by `services.displayManager.ly.enable` and config it by
`services.displayManager.ly.settings` to generate `/etc/ly/config.ini`

## New Services {#sec-release-24.11-new-services}

- Create the first release note entry in this section!
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@
./services/display-managers/default.nix
./services/display-managers/greetd.nix
./services/display-managers/sddm.nix
./services/display-managers/ly.nix
./services/editors/emacs.nix
./services/editors/haste.nix
./services/editors/infinoted.nix
Expand Down
3 changes: 2 additions & 1 deletion nixos/modules/services/display-managers/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ in
noDmUsed = !(dmConf.gdm.enable
|| cfg.sddm.enable
|| dmConf.xpra.enable
|| dmConf.lightdm.enable);
|| dmConf.lightdm.enable
|| cfg.ly.enable);
in lib.mkIf noDmUsed (lib.mkDefault false);

systemd.services.display-manager = {
Expand Down
132 changes: 132 additions & 0 deletions nixos/modules/services/display-managers/ly.nix
Vonfry marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{ config, lib, pkgs, ... }:

let
dmcfg = config.services.displayManager;
xcfg = config.services.xserver;
xdmcfg = xcfg.displayManager;
cfg = config.services.displayManager.ly;
xEnv = config.systemd.services.display-manager.environment;

ly = cfg.package;

iniFmt = pkgs.formats.iniWithGlobalSection { };

inherit (lib)
concatMapStrings
attrNames getAttr
mkIf mkOption mkEnableOption mkPackageOption
;

xserverWrapper = pkgs.writeShellScript "xserver-wrapper" ''
${concatMapStrings (n: "export ${n}=\"${getAttr n xEnv}\"\n") (attrNames xEnv)}
exec systemd-cat -t xserver-wrapper ${xdmcfg.xserverBin} ${toString xdmcfg.xserverArgs} "$@"
'';

defaultConfig = {
shutdown_cmd = "/run/current-system/systemd/bin/systemctl poweroff";
restart_cmd = "/run/current-system/systemd/bin/systemctl reboot";
tty = 2;
service_name = "ly";
path = "/run/current-system/sw/bin";
term_reset_cmd = "${pkgs.ncurses}/bin/tput reset";
term_restore_cursor_cmd = "${pkgs.ncurses}/bin/tput cnorm";
mcookie_cmd = "/run/current-system/sw/bin/mcookie";
waylandsessions = "${dmcfg.sessionData.desktops}/share/wayland-sessions";
wayland_cmd = dmcfg.sessionData.wrapper;
xsessions = "${dmcfg.sessionData.desktops}/share/xsessions";
xauth_cmd = lib.optionalString xcfg.enable "${pkgs.xorg.xauth}/bin/xauth";
x_cmd = lib.optionalString xcfg.enable xserverWrapper;
x_cmd_setup = dmcfg.sessionData.wrapper;
};

finalConfig = defaultConfig // cfg.settings;

cfgFile = iniFmt.generate "config.ini" { globalSection = finalConfig; };

in
{
options = {
services.displayManager.ly = {
enable = mkEnableOption "ly as the display manager";

package = mkPackageOption pkgs [ "ly" ] { };

settings = mkOption {
type = with lib.types; attrsOf (oneOf [ str int bool ]);
default = { };
example = {
load = false;
save = false;
};
description = ''
Extra settings merged in and overwriting defaults in config.ini.
'';
};
};
};

config = mkIf cfg.enable {

assertions = [
{
assertion = !dmcfg.autoLogin.enable;
message = ''
ly doesn't support auto login.
'';
}
];

security.pam.services.ly = {
startSession = true;
unixAuth = true;
};

environment = {
etc."ly/config.ini".source = cfgFile;
systemPackages = [ ly ];

pathsToLink = [ "/share/ly" ];
};

services = {
dbus.packages = [ ly ];

displayManager = {
enable = true;
execCmd = "exec /run/current-system/sw/bin/ly";
};

xserver = {
# To enable user switching, allow ly to allocate TTYs/displays dynamically.
tty = null;
display = null;
};
};

systemd = {
# We're not using the upstream unit, so copy these:
# https://github.com/fairyglade/ly/blob/master/res/ly.service
services.display-manager = {
after = [
"systemd-user-sessions.service"
"plymouth-quit-wait.service"
"getty@tty${toString finalConfig.tty}.service"
];

conflicts = [
"getty@tty7.service"
];

serviceConfig = {
Type = "idle";
StandardInput = "tty";
TTYPath = "/dev/tty${toString finalConfig.tty}";
TTYReset = "yes";
TTYVHangup = "yes";
};
};
};
};

meta.maintainers = with lib.maintainers; [ vonfry ];
}
3 changes: 2 additions & 1 deletion nixos/modules/services/x11/xserver.nix
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,8 @@ in
|| dmConf.xpra.enable
|| dmConf.sx.enable
|| dmConf.startx.enable
|| config.services.greetd.enable);
|| config.services.greetd.enable
|| config.services.displayManager.ly.enable);
in mkIf (default) (mkDefault true);

services.xserver.videoDrivers = mkIf (cfg.videoDriver != null) [ cfg.videoDriver ];
Expand Down
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ in {
lomiri = handleTest ./lomiri.nix {};
lomiri-system-settings = handleTest ./lomiri-system-settings.nix {};
lorri = handleTest ./lorri/default.nix {};
ly = handleTest ./ly.nix {};
maddy = discoverTests (import ./maddy { inherit handleTest; });
maestral = handleTest ./maestral.nix {};
magic-wormhole-mailbox-server = handleTest ./magic-wormhole-mailbox-server.nix {};
Expand Down
37 changes: 37 additions & 0 deletions nixos/tests/ly.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import ./make-test-python.nix ({ lib, ... }:

{
name = "ly";

Vonfry marked this conversation as resolved.
Show resolved Hide resolved
nodes.machine = { ... }: {
imports = [ ./common/user-account.nix ];
services.displayManager.ly = {
enable = true;
settings = {
load = false;
save = false;
};
};
services.xserver.enable = true;
services.displayManager.defaultSession = "none+icewm";
services.xserver.windowManager.icewm.enable = true;
};

testScript = { nodes, ... }: let
user = nodes.machine.users.users.alice;
in ''
start_all()
machine.wait_until_tty_matches("2", "password:")
machine.send_key("ctrl-alt-f2")
machine.sleep(1)
machine.screenshot("ly")
machine.send_chars("alice")
machine.send_key("tab")
machine.send_chars("${user.password}")
machine.send_key("ret")
machine.wait_for_file("/run/user/${toString user.uid}/lyxauth")
machine.succeed("xauth merge /run/user/${toString user.uid}/lyxauth")
machine.wait_for_window("^IceWM ")
machine.screenshot("icewm")
'';
})
30 changes: 19 additions & 11 deletions pkgs/applications/display-managers/ly/default.nix
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
{ stdenv, lib, fetchFromGitHub, git, linux-pam, libxcb }:
{ stdenv
, lib
, fetchFromGitHub
, linux-pam
, libxcb
, makeBinaryWrapper
, zig
, callPackage
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation {
pname = "ly";
version = "0.6.0";
version = "0.6.0-unstable-2024-05-10";

# The unstable version fixes the issue where configurations are ignored due
# to a wrong array length during parsing the config file.
# When the next stable version is released, we should use stable one instead.
src = fetchFromGitHub {
owner = "fairyglade";
repo = "ly";
rev = "v${version}";
hash = "sha256-78XD6DK9aQi8hITWJWnFZ3U9zWTcuw3vtRiU3Lhu7O4=";
fetchSubmodules = true;
rev = "7506d6a7d5ce841ee8c24e5b3eaa930681a39199";
hash = "sha256-UYTYcgkDMqyIDUigHoOEZEzo2GoeJlTpurSgKOkbt4w=";
};

hardeningDisable = [ "all" ];
nativeBuildInputs = [ git ];
nativeBuildInputs = [ makeBinaryWrapper zig.hook ];
buildInputs = [ libxcb linux-pam ];

installPhase = ''
mkdir -p $out/bin
cp bin/ly $out/bin
postPatch = ''
ln -s ${callPackage ./deps.nix { }} $ZIG_GLOBAL_CACHE_DIR/p
'';

meta = with lib; {
Expand Down
68 changes: 68 additions & 0 deletions pkgs/applications/display-managers/ly/deps.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.