Merge pull request #297434 from Vonfry/init-ly-module

add nixos/ly module and package update
This commit is contained in:
Thiago Kenji Okada 2024-08-06 19:32:22 +01:00 committed by GitHub
commit cb91750451
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 323 additions and 13 deletions

View File

@ -20,6 +20,11 @@
- NixOS now has support for *automatic boot assessment* (see [here](https://systemd.io/AUTOMATIC_BOOT_ASSESSMENT/)) for detailed description of the feature) for `systemd-boot` users. Available as [boot.loader.systemd-boot.bootCounting](#opt-boot.loader.systemd-boot.bootCounting.enable).
- 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}
- [FlareSolverr](https://github.com/FlareSolverr/FlareSolverr), proxy server to bypass Cloudflare protection. Available as [services.flaresolverr](#opt-services.flaresolverr.enable) service.

View File

@ -543,6 +543,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

View File

@ -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 = {

View File

@ -0,0 +1,147 @@
{
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}"
'') (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 ];
}

View File

@ -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 ];

View File

@ -544,6 +544,7 @@ in {
lomiri-filemanager-app = runTest ./lomiri-filemanager-app.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 {};

44
nixos/tests/ly.nix Normal file
View File

@ -0,0 +1,44 @@
import ./make-test-python.nix (
{ ... }:
{
name = "ly";
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")
'';
}
)

View File

@ -1,24 +1,22 @@
{ stdenv, lib, fetchFromGitHub, git, linux-pam, libxcb }:
{ stdenv, lib, fetchFromGitHub, linux-pam, libxcb, makeBinaryWrapper, zig_0_12
, callPackage }:
stdenv.mkDerivation rec {
stdenv.mkDerivation {
pname = "ly";
version = "0.6.0";
version = "1.0.2";
src = fetchFromGitHub {
owner = "fairyglade";
repo = "ly";
rev = "v${version}";
hash = "sha256-78XD6DK9aQi8hITWJWnFZ3U9zWTcuw3vtRiU3Lhu7O4=";
fetchSubmodules = true;
rev = "v1.0.2";
hash = "sha256-VUtNEL7Te/ba+wvL0SsUHlyv2NPmkYKs76TnW8r3ysw=";
};
hardeningDisable = [ "all" ];
nativeBuildInputs = [ git ];
nativeBuildInputs = [ makeBinaryWrapper zig_0_12.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; {

View File

@ -0,0 +1,112 @@
# generated by zon2nix (https://github.com/Cloudef/zig2nix)
{
lib,
linkFarm,
fetchurl,
fetchgit,
runCommandLocal,
zig,
name ? "zig-packages",
}:
with lib;
let
unpackZigArtifact =
{ name, artifact }:
runCommandLocal name { nativeBuildInputs = [ zig ]; } ''
hash="$(zig fetch --global-cache-dir "$TMPDIR" ${artifact})"
mv "$TMPDIR/p/$hash" "$out"
chmod 755 "$out"
'';
fetchZig =
{
name,
url,
hash,
}:
let
artifact = fetchurl { inherit url hash; };
in
unpackZigArtifact { inherit name artifact; };
fetchGitZig =
{
name,
url,
hash,
}:
let
parts = splitString "#" url;
base = elemAt parts 0;
rev = elemAt parts 1;
in
fetchgit {
inherit name rev hash;
url = base;
deepClone = false;
};
fetchZigArtifact =
{
name,
url,
hash,
}:
let
parts = splitString "://" url;
proto = elemAt parts 0;
path = elemAt parts 1;
fetcher = {
"git+http" = fetchGitZig {
inherit name hash;
url = "http://${path}";
};
"git+https" = fetchGitZig {
inherit name hash;
url = "https://${path}";
};
http = fetchZig {
inherit name hash;
url = "http://${path}";
};
https = fetchZig {
inherit name hash;
url = "https://${path}";
};
file = unpackZigArtifact {
inherit name;
artifact = /. + path;
};
};
in
fetcher.${proto};
in
linkFarm name [
{
name = "122014e73fd712190e109950837b97f6143f02d7e2b6986e1db70b6f4aadb5ba6a0d";
path = fetchZigArtifact {
name = "clap";
url = "https://github.com/Hejsil/zig-clap/archive/8c98e6404b22aafc0184e999d8f068b81cc22fa1.tar.gz";
hash = "sha256-3P9LyIlq4eNMOe+/jdVJgECfzveSUuRzTf9yhT4t8Zo=";
};
}
{
name = "12209b971367b4066d40ecad4728e6fdffc4cc4f19356d424c2de57f5b69ac7a619a";
path = fetchZigArtifact {
name = "zigini";
url = "https://github.com/Kawaii-Ash/zigini/archive/0bba97a12582928e097f4074cc746c43351ba4c8.tar.gz";
hash = "sha256-OdaJ5tqmk2MPwaAbpK4HRD/CcQCN+Cjj8U63BqUcFMs=";
};
}
{
name = "1220b0979ea9891fa4aeb85748fc42bc4b24039d9c99a4d65d893fb1c83e921efad8";
path = fetchZigArtifact {
name = "ini";
url = "https://github.com/ziglibs/ini/archive/e18d36665905c1e7ba0c1ce3e8780076b33e3002.tar.gz";
hash = "sha256-RQ6OPJBqqH7PCL+xiI58JT7vnIo6zbwpLWn+byZO5iM=";
};
}
]