mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
lomiri.lomiri: Replace NIXOS_XKB_LAYOUTS envvar with file (#345288)
This commit is contained in:
commit
a825406b15
@ -44,10 +44,9 @@ in {
|
||||
telephony-service
|
||||
teleports
|
||||
]);
|
||||
variables = {
|
||||
# To override the keyboard layouts in Lomiri
|
||||
NIXOS_XKB_LAYOUTS = config.services.xserver.xkb.layout;
|
||||
};
|
||||
|
||||
# To override the default keyboard layout in Lomiri
|
||||
etc.${pkgs.lomiri.lomiri.passthru.etcLayoutsFile}.text = lib.strings.replaceStrings [","] ["\n"] config.services.xserver.xkb.layout;
|
||||
};
|
||||
|
||||
hardware = {
|
||||
|
@ -700,4 +700,92 @@ in
|
||||
}
|
||||
);
|
||||
|
||||
keymap =
|
||||
let
|
||||
pwInput = "qwerty";
|
||||
pwOutput = "qwertz";
|
||||
in
|
||||
makeTest (
|
||||
{ pkgs, lib, ... }:
|
||||
{
|
||||
name = "lomiri-keymap";
|
||||
|
||||
meta = {
|
||||
maintainers = lib.teams.lomiri.members;
|
||||
};
|
||||
|
||||
nodes.machine =
|
||||
{ config, ... }:
|
||||
{
|
||||
imports = [ ./common/user-account.nix ];
|
||||
|
||||
virtualisation.memorySize = 2047;
|
||||
|
||||
users.users.${user} = {
|
||||
inherit description;
|
||||
password = lib.mkForce pwOutput;
|
||||
};
|
||||
|
||||
services.desktopManager.lomiri.enable = lib.mkForce true;
|
||||
services.displayManager.defaultSession = lib.mkForce "lomiri";
|
||||
|
||||
# Help with OCR
|
||||
fonts.packages = [ pkgs.inconsolata ];
|
||||
|
||||
# Non-QWERTY keymap to test keymap patch
|
||||
services.xserver.xkb.layout = "de";
|
||||
};
|
||||
|
||||
enableOCR = true;
|
||||
|
||||
testScript =
|
||||
{ nodes, ... }:
|
||||
''
|
||||
def wait_for_text(text):
|
||||
"""
|
||||
Wait for on-screen text, and try to optimise retry count for slow hardware.
|
||||
"""
|
||||
machine.sleep(10)
|
||||
machine.wait_for_text(text)
|
||||
|
||||
start_all()
|
||||
machine.wait_for_unit("multi-user.target")
|
||||
|
||||
# Lomiri in greeter mode should use the correct keymap
|
||||
with subtest("lomiri greeter keymap works"):
|
||||
machine.wait_for_unit("display-manager.service")
|
||||
machine.wait_until_succeeds("pgrep -u lightdm -f 'lomiri --mode=greeter'")
|
||||
|
||||
# Start page shows current time
|
||||
wait_for_text(r"(AM|PM)")
|
||||
machine.screenshot("lomiri_greeter_launched")
|
||||
|
||||
# Advance to login part
|
||||
machine.send_key("ret")
|
||||
wait_for_text("${description}")
|
||||
machine.screenshot("lomiri_greeter_login")
|
||||
|
||||
# Login
|
||||
machine.send_chars("${pwInput}\n")
|
||||
machine.wait_until_succeeds("pgrep -u ${user} -f 'lomiri --mode=full-shell'")
|
||||
|
||||
# Output rendering from Lomiri has started when it starts printing performance diagnostics
|
||||
machine.wait_for_console_text("Last frame took")
|
||||
# Look for datetime's clock, one of the last elements to load
|
||||
wait_for_text(r"(AM|PM)")
|
||||
machine.screenshot("lomiri_launched")
|
||||
|
||||
# Lomiri in desktop mode should use the correct keymap
|
||||
with subtest("lomiri session keymap works"):
|
||||
machine.send_key("ctrl-alt-t")
|
||||
wait_for_text(r"(${user}|machine)")
|
||||
machine.screenshot("terminal_opens")
|
||||
|
||||
machine.send_chars("touch ${pwInput}\n")
|
||||
machine.wait_for_file("/home/alice/${pwOutput}", 10)
|
||||
|
||||
machine.send_key("alt-f4")
|
||||
'';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
From 9e843a203f68ca75d430f1032a92d3c87f9ed2c2 Mon Sep 17 00:00:00 2001
|
||||
From: OPNA2608 <opna2608@protonmail.com>
|
||||
Date: Sun, 29 Sep 2024 12:05:07 +0200
|
||||
Subject: [PATCH] plugins/AccountsService/AccountsService.cpp: If keymap unset,
|
||||
read fallbacks from NixOS-specific file
|
||||
|
||||
---
|
||||
plugins/AccountsService/AccountsService.cpp | 15 +++++++++++++++
|
||||
1 file changed, 15 insertions(+)
|
||||
|
||||
diff --git a/plugins/AccountsService/AccountsService.cpp b/plugins/AccountsService/AccountsService.cpp
|
||||
index bfc4bf3ce..9308220a9 100644
|
||||
--- a/plugins/AccountsService/AccountsService.cpp
|
||||
+++ b/plugins/AccountsService/AccountsService.cpp
|
||||
@@ -311,6 +311,21 @@ QStringList AccountsService::keymaps() const
|
||||
return simplifiedMaps;
|
||||
}
|
||||
|
||||
+ QFile fallbackNixosLayouts ("@nixosLayoutFile@");
|
||||
+ if (fallbackNixosLayouts.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
+ while (!fallbackNixosLayouts.atEnd()) {
|
||||
+ QString line = QString(fallbackNixosLayouts.readLine()).simplified();
|
||||
+ if (!line.isEmpty()) {
|
||||
+ simplifiedMaps.append(line);
|
||||
+ }
|
||||
+ }
|
||||
+ fallbackNixosLayouts.close();
|
||||
+ }
|
||||
+
|
||||
+ if (!simplifiedMaps.isEmpty()) {
|
||||
+ return simplifiedMaps;
|
||||
+ }
|
||||
+
|
||||
return {QStringLiteral("us")};
|
||||
}
|
||||
|
||||
--
|
||||
2.44.1
|
||||
|
@ -1,29 +0,0 @@
|
||||
From 640cab41986fac83742af39dd19877041a2ab8dc Mon Sep 17 00:00:00 2001
|
||||
From: OPNA2608 <opna2608@protonmail.com>
|
||||
Date: Sat, 1 Jun 2024 00:22:27 +0200
|
||||
Subject: [PATCH] Check NIXOS_XKB_LAYOUTS for layouts before falling back to
|
||||
"us"
|
||||
|
||||
---
|
||||
plugins/AccountsService/AccountsService.cpp | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/plugins/AccountsService/AccountsService.cpp b/plugins/AccountsService/AccountsService.cpp
|
||||
index bcf18246c..f4a7dfaa1 100644
|
||||
--- a/plugins/AccountsService/AccountsService.cpp
|
||||
+++ b/plugins/AccountsService/AccountsService.cpp
|
||||
@@ -295,6 +295,11 @@ QStringList AccountsService::keymaps() const
|
||||
return simplifiedMaps;
|
||||
}
|
||||
|
||||
+ char* fallbackNixosLayouts = getenv("NIXOS_XKB_LAYOUTS");
|
||||
+ if (fallbackNixosLayouts != NULL && fallbackNixosLayouts[0] != '\0') {
|
||||
+ return QString(fallbackNixosLayouts).split(QLatin1Char(','), Qt::SkipEmptyParts);
|
||||
+ }
|
||||
+
|
||||
return {QStringLiteral("us")};
|
||||
}
|
||||
|
||||
--
|
||||
2.42.0
|
||||
|
@ -6,6 +6,7 @@
|
||||
fetchpatch2,
|
||||
gitUpdater,
|
||||
linkFarm,
|
||||
substituteAll,
|
||||
nixosTests,
|
||||
ayatana-indicator-datetime,
|
||||
bash,
|
||||
@ -116,7 +117,10 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
})
|
||||
|
||||
./9901-lomiri-Disable-Wizard.patch
|
||||
./9902-lomiri-Check-NIXOS_XKB_LAYOUTS.patch
|
||||
(substituteAll {
|
||||
src = ./9902-Layout-fallback-file.patch;
|
||||
nixosLayoutFile = "/etc/" + finalAttrs.finalPackage.passthru.etcLayoutsFile;
|
||||
})
|
||||
];
|
||||
|
||||
postPatch =
|
||||
@ -269,12 +273,14 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
etcLayoutsFile = "lomiri/keymaps";
|
||||
tests = {
|
||||
inherit (nixosTests.lomiri)
|
||||
greeter
|
||||
desktop-basics
|
||||
desktop-appinteractions
|
||||
desktop-ayatana-indicators
|
||||
keymap
|
||||
;
|
||||
};
|
||||
updateScript = gitUpdater { };
|
||||
|
Loading…
Reference in New Issue
Block a user