From 17260c31264ea0de35594e9bb28770972cdb74d0 Mon Sep 17 00:00:00 2001 From: "Markus S. Wamser" Date: Sat, 7 Jun 2025 22:57:21 +0200 Subject: [PATCH] ly: add option to build without x11 support --- .../modules/services/display-managers/ly.nix | 7 ++- nixos/tests/ly.nix | 46 +++++++++++++++---- pkgs/by-name/ly/ly/package.nix | 7 ++- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/nixos/modules/services/display-managers/ly.nix b/nixos/modules/services/display-managers/ly.nix index 51a99a7ec458..76047c3942a7 100644 --- a/nixos/modules/services/display-managers/ly.nix +++ b/nixos/modules/services/display-managers/ly.nix @@ -12,7 +12,7 @@ let cfg = config.services.displayManager.ly; xEnv = config.systemd.services.display-manager.environment; - ly = cfg.package; + ly = cfg.package.override { x11Support = cfg.x11Support; }; iniFmt = pkgs.formats.iniWithGlobalSection { }; @@ -57,6 +57,11 @@ in options = { services.displayManager.ly = { enable = mkEnableOption "ly as the display manager"; + x11Support = mkOption { + description = "Whether to enable support for X11"; + type = lib.types.bool; + default = true; + }; package = mkPackageOption pkgs [ "ly" ] { }; diff --git a/nixos/tests/ly.nix b/nixos/tests/ly.nix index 4791bf8056f2..b7bee09c3372 100644 --- a/nixos/tests/ly.nix +++ b/nixos/tests/ly.nix @@ -1,23 +1,35 @@ -{ ... }: +{ lib, ... }: +let + machineBase = { + imports = [ ./common/user-account.nix ]; + services.displayManager.ly = { + enable = true; + settings = { + load = false; + save = false; + }; + }; + }; +in { name = "ly"; nodes.machine = { ... }: - { - imports = [ ./common/user-account.nix ]; - services.displayManager.ly = { - enable = true; - settings = { - load = false; - save = false; - }; - }; + lib.attrsets.recursiveUpdate machineBase { + services.displayManager.ly.x11Support = true; services.xserver.enable = true; services.displayManager.defaultSession = "none+icewm"; services.xserver.windowManager.icewm.enable = true; }; + nodes.machineNoX11 = + { ... }: + lib.attrsets.recursiveUpdate machineBase { + services.displayManager.ly.x11Support = false; + services.displayManager.defaultSession = "sway"; + programs.sway.enable = true; + }; testScript = { nodes, ... }: @@ -26,6 +38,7 @@ in '' start_all() + machine.wait_until_tty_matches("2", "password:") machine.send_key("ctrl-alt-f2") machine.sleep(1) @@ -38,5 +51,18 @@ machine.succeed("xauth merge /run/user/${toString user.uid}/lyxauth") machine.wait_for_window("^IceWM ") machine.screenshot("icewm") + + machineNoX11.wait_until_tty_matches("2", "password:") + machineNoX11.send_key("ctrl-alt-f2") + machineNoX11.sleep(1) + machineNoX11.screenshot("ly-no-x11") + machineNoX11.send_chars("alice") + machineNoX11.send_key("tab") + machineNoX11.send_chars("${user.password}") + machineNoX11.send_key("ret") + machineNoX11.wait_for_file("/run/user/${toString user.uid}/wayland-1") + machineNoX11.wait_for_file("/run/user/${toString user.uid}/sway-ipc.*.sock") + machineNoX11.sleep(5) + machineNoX11.screenshot("sway") ''; } diff --git a/pkgs/by-name/ly/ly/package.nix b/pkgs/by-name/ly/ly/package.nix index a3fc6dda1966..be47fbe07f1a 100644 --- a/pkgs/by-name/ly/ly/package.nix +++ b/pkgs/by-name/ly/ly/package.nix @@ -8,6 +8,7 @@ zig_0_14, callPackage, nixosTests, + x11Support ? true, }: stdenv.mkDerivation (finalAttrs: { @@ -27,9 +28,8 @@ stdenv.mkDerivation (finalAttrs: { zig_0_14.hook ]; buildInputs = [ - libxcb linux-pam - ]; + ] ++ (lib.optionals x11Support [ libxcb ]); postPatch = '' ln -s ${ @@ -38,6 +38,9 @@ stdenv.mkDerivation (finalAttrs: { } } $ZIG_GLOBAL_CACHE_DIR/p ''; + zigBuildFlags = [ + "-Denable_x11_support=${lib.boolToString x11Support}" + ]; passthru.tests = { inherit (nixosTests) ly; };