summary refs log tree commit diff
path: root/nixos/modules/services/hardware
diff options
context:
space:
mode:
authorwoojiq <yurii.shymon@gmail.com>2023-10-07 11:50:04 +0300
committerwoojiq <yurii.shymon@gmail.com>2023-10-07 11:50:04 +0300
commitfee1832e8456407c706818e92b5f2e44c9509777 (patch)
treeb7114494975123f640cdc3240524a1c5592244a6 /nixos/modules/services/hardware
parent34d8d08fdd2bfa089dc670a6f3e5f0d645370925 (diff)
downloadnixpkgs-fee1832e8456407c706818e92b5f2e44c9509777.tar
nixpkgs-fee1832e8456407c706818e92b5f2e44c9509777.tar.gz
nixpkgs-fee1832e8456407c706818e92b5f2e44c9509777.tar.bz2
nixpkgs-fee1832e8456407c706818e92b5f2e44c9509777.tar.lz
nixpkgs-fee1832e8456407c706818e92b5f2e44c9509777.tar.xz
nixpkgs-fee1832e8456407c706818e92b5f2e44c9509777.tar.zst
nixpkgs-fee1832e8456407c706818e92b5f2e44c9509777.zip
nixos/keyd: add `extraConfig` option
Diffstat (limited to 'nixos/modules/services/hardware')
-rw-r--r--nixos/modules/services/hardware/keyd.nix32
1 files changed, 21 insertions, 11 deletions
diff --git a/nixos/modules/services/hardware/keyd.nix b/nixos/modules/services/hardware/keyd.nix
index ead2f456a20..724e9b95684 100644
--- a/nixos/modules/services/hardware/keyd.nix
+++ b/nixos/modules/services/hardware/keyd.nix
@@ -2,7 +2,6 @@
 with lib;
 let
   cfg = config.services.keyd;
-  settingsFormat = pkgs.formats.ini { };
 
   keyboardOptions = { ... }: {
     options = {
@@ -16,7 +15,7 @@ let
       };
 
       settings = mkOption {
-        type = settingsFormat.type;
+        type = (pkgs.formats.ini { }).type;
         default = { };
         example = {
           main = {
@@ -37,6 +36,20 @@ let
           See <https://github.com/rvaiya/keyd> how to configure.
         '';
       };
+
+      extraConfig = mkOption {
+        type = types.lines;
+        default = "";
+        example = ''
+          [control+shift]
+          h = left
+        '';
+        description = lib.mdDoc ''
+          Extra configuration that is appended to the end of the file.
+          **Do not** write `ids` section here, use a separate option for it.
+          You can use this option to define compound layers that must always be defined after the layer they are comprised.
+        '';
+      };
     };
   };
 in
@@ -85,15 +98,12 @@ in
     environment.etc = mapAttrs'
       (name: options:
         nameValuePair "keyd/${name}.conf" {
-          source = pkgs.runCommand "${name}.conf"
-            {
-              ids = ''
-                [ids]
-                ${concatStringsSep "\n" options.ids}
-              '';
-              passAsFile = [ "ids" ];
-            } ''
-            cat $idsPath <(echo) ${settingsFormat.generate "keyd-${name}.conf" options.settings} >$out
+          text = ''
+            [ids]
+            ${concatStringsSep "\n" options.ids}
+
+            ${generators.toINI {} options.settings}
+            ${options.extraConfig}
           '';
         })
       cfg.keyboards;