Skip to content

Commit

Permalink
Merge master into staging-next
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 19, 2024
2 parents 2ab7280 + abc12d1 commit d5c9b46
Show file tree
Hide file tree
Showing 50 changed files with 866 additions and 354 deletions.
18 changes: 18 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6529,6 +6529,13 @@
githubId = 46724898;
name = "Erik Backman";
};
erikeah = {
email = "[email protected]";
github = "erikeah";
githubId = 11900869;
keys = [ { fingerprint = "4142 0380 C7F8 BCDA CC9E 7ABA 0FF3 076B 71F2 5DEF"; } ];
name = "Erik Alonso";
};
erikryb = {
email = "[email protected]";
github = "erikryb";
Expand Down Expand Up @@ -7877,6 +7884,17 @@
githubId = 15957973;
name = "Jeffry Molanus";
};
gileri = {
email = "[email protected]";
github = "gileri";
githubId = 493438;
name = "Éric Gillet";
keys = [
{
fingerprint = "E478 85DC 8F33 FA86 D3FC 183D 80A8 14DB 8ED5 70BC";
}
];
};
gilice = {
email = "[email protected]";
github = "gilice";
Expand Down
3 changes: 3 additions & 0 deletions nixos/doc/manual/release-notes/rl-2411.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@
- [chromadb](https://www.trychroma.com/), an open-source AI application
database. Batteries included. Available as [services.chromadb](options.html#opt-services.chromadb.enable).

- [bitmagnet](https://bitmagnet.io/), A self-hosted BitTorrent indexer, DHT crawler, content classifier and torrent search engine with web UI, GraphQL API and Servarr stack integration.
Available as [services.bitmagnet](options.html#opt-services.bitmagnet.enable).

- [Wakapi](https://wakapi.dev/), a time tracking software for programmers. Available as [services.wakapi](#opt-services.wakapi.enable).

- [foot](https://codeberg.org/dnkl/foot), a fast, lightweight and minimalistic Wayland terminal emulator. Available as [programs.foot](#opt-programs.foot.enable).
Expand Down
2 changes: 2 additions & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@
./services/hardware/irqbalance.nix
./services/hardware/joycond.nix
./services/hardware/kanata.nix
./services/hardware/kmonad.nix
./services/hardware/lcd.nix
./services/hardware/libinput.nix
./services/hardware/lirc.nix
Expand Down Expand Up @@ -1359,6 +1360,7 @@
./services/system/uptimed.nix
./services/system/userborn.nix
./services/system/zram-generator.nix
./services/torrent/bitmagnet.nix
./services/torrent/deluge.nix
./services/torrent/flexget.nix
./services/torrent/flood.nix
Expand Down
190 changes: 190 additions & 0 deletions nixos/modules/services/hardware/kmonad.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
{
config,
lib,
pkgs,
...
}:

let
cfg = config.services.kmonad;

# Per-keyboard options:
keyboard =
{ name, ... }:
{
options = {
name = lib.mkOption {
type = lib.types.str;
example = "laptop-internal";
description = "Keyboard name.";
};

device = lib.mkOption {
type = lib.types.path;
example = "/dev/input/by-id/some-dev";
description = "Path to the keyboard's device file.";
};

extraGroups = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = ''
Extra permission groups to attach to the KMonad instance for
this keyboard.
Since KMonad runs as an unprivileged user, it may sometimes
need extra permissions in order to read the keyboard device
file. If your keyboard's device file isn't in the input
group you'll need to list its group in this option.
'';
};

defcfg = {
enable = lib.mkEnableOption ''
Automatically generate the defcfg block.
When this is option is set to true the config option for
this keyboard should not include a defcfg block.
'';

compose = {
key = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = "ralt";
description = "The (optional) compose key to use.";
};

delay = lib.mkOption {
type = lib.types.int;
default = 5;
description = "The delay (in milliseconds) between compose key sequences.";
};
};

fallthrough = lib.mkEnableOption "Re-emit unhandled key events.";

allowCommands = lib.mkEnableOption "Allow keys to run shell commands.";
};

config = lib.mkOption {
type = lib.types.lines;
description = "Keyboard configuration.";
};
};

config = {
name = lib.mkDefault name;
};
};

# Create a complete KMonad configuration file:
mkCfg =
keyboard:
let
defcfg = ''
(defcfg
input (device-file "${keyboard.device}")
output (uinput-sink "kmonad-${keyboard.name}")
${
lib.optionalString (keyboard.defcfg.compose.key != null) ''
cmp-seq ${keyboard.defcfg.compose.key}
cmp-seq-delay ${toString keyboard.defcfg.compose.delay}
''
}
fallthrough ${lib.boolToString keyboard.defcfg.fallthrough}
allow-cmd ${lib.boolToString keyboard.defcfg.allowCommands}
)
'';
in
pkgs.writeTextFile {
name = "kmonad-${keyboard.name}.cfg";
text = lib.optionalString keyboard.defcfg.enable (defcfg + "\n") + keyboard.config;
checkPhase = "${cfg.package}/bin/kmonad -d $out";
};

# Build a systemd path config that starts the service below when a
# keyboard device appears:
mkPath =
keyboard:
let
name = "kmonad-${keyboard.name}";
in
lib.nameValuePair name {
description = "KMonad trigger for ${keyboard.device}";
wantedBy = [ "paths.target" ];
pathConfig = {
Unit = "${name}.service";
PathExists = keyboard.device;
};
};

# Build a systemd service that starts KMonad:
mkService =
keyboard:
let
cmd = [
(lib.getExe cfg.package)
"--input"
''device-file "${keyboard.device}"''
] ++ cfg.extraArgs ++ [ "${mkCfg keyboard}" ];
in
lib.nameValuePair "kmonad-${keyboard.name}" {
description = "KMonad for ${keyboard.device}";
script = lib.escapeShellArgs cmd;
unitConfig = {
# Control rate limiting.
# Stop the restart logic if we restart more than
# StartLimitBurst times in a period of StartLimitIntervalSec.
StartLimitIntervalSec = 2;
StartLimitBurst = 5;
};
serviceConfig = {
Restart = "always";
# Restart at increasing intervals from 2s to 1m
RestartSec = 2;
RestartSteps = 30;
RestartMaxDelaySec = "1min";
Nice = -20;
DynamicUser = true;
User = "kmonad";
Group = "kmonad";
SupplementaryGroups = [
# These ensure that our dynamic user has access to the device node
config.users.groups.input.name
config.users.groups.uinput.name
] ++ keyboard.extraGroups;
};
};
in
{
options.services.kmonad = {
enable = lib.mkEnableOption "KMonad: An advanced keyboard manager.";

package = lib.mkPackageOption pkgs "kmonad" { };

keyboards = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule keyboard);
default = { };
description = "Keyboard configuration.";
};

extraArgs = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
example = [
"--log-level"
"debug"
];
description = "Extra arguments to pass to KMonad.";
};
};

config = lib.mkIf cfg.enable {
hardware.uinput.enable = true;

systemd = {
paths = lib.mapAttrs' (_: mkPath) cfg.keyboards;
services = lib.mapAttrs' (_: mkService) cfg.keyboards;
};
};
}
16 changes: 11 additions & 5 deletions nixos/modules/services/networking/sing-box.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,17 @@ in
systemd.packages = [ cfg.package ];

systemd.services.sing-box = {
preStart = ''
umask 0077
mkdir -p /etc/sing-box
${utils.genJqSecretsReplacementSnippet cfg.settings "/etc/sing-box/config.json"}
'';
preStart = utils.genJqSecretsReplacementSnippet cfg.settings "/run/sing-box/config.json";
serviceConfig = {
StateDirectory = "sing-box";
StateDirectoryMode = "0700";
RuntimeDirectory = "sing-box";
RuntimeDirectoryMode = "0700";
ExecStart = [
""
"${lib.getExe cfg.package} -D \${STATE_DIRECTORY} -C \${RUNTIME_DIRECTORY} run"
];
};
wantedBy = [ "multi-user.target" ];
};
};
Expand Down
Loading

0 comments on commit d5c9b46

Please sign in to comment.