Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,7 @@
./services/x11/hardware/synaptics.nix
./services/x11/hardware/wacom.nix
./services/x11/imwheel.nix
./services/x11/neolight.nix
./services/x11/picom.nix
./services/x11/redshift.nix
./services/x11/touchegg.nix
Expand Down
30 changes: 30 additions & 0 deletions nixos/modules/services/x11/neolight.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
config,
pkgs,
lib,
...
}:

let
cfg = config.services.xserver.xkb.neolight;
in
{
options.services.xserver.xkb.neolight = {
package = lib.mkPackageOption pkgs "neolight" { };
enable = lib.mkEnableOption "neolight xkb layout, extra keyboard layers for programming based on Neo";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really need to provide more information on what this actually does and how to use the layout, either here or in the NixOS manual.

Also, you should add a test case to nixosTests.keymap (see nixos/tests/keymap.nix). There is one already for neo and one for extraLayout that you can adapt.

};

config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
environment.sessionVariables.XKB_CONFIG_ROOT = lib.mkForce "${cfg.package}/share/X11/xkb";

assertions = [
{
assertion = config.services.xserver.xkb.extraLayouts == { };
message = "Neolight conflicts with xkb.extraLayouts";
}
];
};

meta.maintainers = with lib.maintainers; [ drafolin ];
}
100 changes: 100 additions & 0 deletions pkgs/by-name/ne/neolight/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
xkeyboard_config,
ed,
fetchFromGitHub,
lib,
}:
xkeyboard_config.overrideAttrs (old: {
neolightSrc = fetchFromGitHub {
owner = "mihi314";
repo = "neolight";
tag = "v1.4.0";
hash = "sha256-m1beegjPPiyQpmiqp5NvCCjBvpebH79A0R7PNjc0Xd8=";
};

postInstall = ''
cd $out/share/X11/xkb
cp $neolightSrc/linux/neolight_symbols symbols/neolight
cp $neolightSrc/linux/neolight_types types/neolight

${ed}/bin/ed -v rules/evdev.xml <<EOF
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but... what does this do? 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the two cp lines copy the symbols and types from neolight;

NeoLight adds two layers on top of your regular keyboard, therefore this is necessary, although a bit of a hack. Really here, I'm just adapting the install.sh script from mihi314/neolight.

Copy link
Copy Markdown
Member

@Sigmanificient Sigmanificient Aug 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question is about the ed command

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry! thought the three lines were selected.

the ed command is the one i saw was used in the implementation of services.xserver.xkb.extraLayouts. It allows to edit a file in-place.

As for the file itself, it's used to be displayed, for example, in gnome tweaks, as a checkbox you can simply tick to enable neolight.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean what does it do to that file, does it creates it? Does it append to it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it appends to it, right after the first match of <layoutList>
/<layoutList>/ looks for the match
a starts the append operation
[...] is the content
. finishes the append operation
w writes to the file

/<layoutList>/
a
<!-- BEGIN neolight -->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove these comments, in the upstream script they were used to splice out the layout in case you uninstall it, but in NixOS this is unnecessary.

<layout>
<configItem>
<name>neolight</name>
<shortDescription>de</shortDescription>
<description>German (Neolight)</description>
<countryList>
<iso3166Id>DE</iso3166Id>
</countryList>
<languageList>
<iso639Id>deu</iso639Id>
</languageList>
</configItem>
<variantList>
<variant>
<configItem>
<name>de_escape_keys</name>
<description>German (Neolight + escape keys)</description>
</configItem>
</variant>
</variantList>
</layout>
<!-- END neolight -->
.
/<optionList>/
a
<!-- BEGIN neolight -->
<group allowMultipleSelection="false">
<configItem>
<name>neolight</name>
<description>Neolight</description>
</configItem>
<option>
<configItem>
<name>neolight</name>
<description>Add the neolight layers to the first layout</description>
</configItem>
</option>
<option>
<configItem>
<name>neolight:escape_keys</name>
<description>Add the neolight layers and additional escape keys to the first layout</description>
</configItem>
</option>
</group>
<!-- END neolight -->
.
w
EOF

${ed}/bin/ed -v types/complete <<EOF
/};/
i
include "neolight"
.
w
EOF

${ed}/bin/ed -v rules/evdev <<EOF
a
// BEGIN NEOLIGHT
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

! option = symbols
neolight = +neolight(layers)
neolight:escape_keys = +neolight(layers)+neolight(escape_keys)
neolight:jp = +neolight(jp)
// END NEOLIGHT
.
w
EOF
'';

meta = {
maintainers = with lib.maintainers; [ drafolin ];
homepage = "https://github.com/mihi314/neolight";
description = "Neolight is a fork of the XKB layout for programming based on Neo";
license = lib.licenses.gpl3Plus;
};
})
Loading