summaryrefslogtreecommitdiffstats
path: root/nixos
diff options
context:
space:
mode:
authorLin Jian <me@linj.tech>2024-05-06 19:39:20 +0800
committerLin Jian <me@linj.tech>2024-05-06 20:25:09 +0800
commit1d93534ec437450ac9a7afdfadfb603b2c3be512 (patch)
tree7968749a8ac62bd2af46df09c471ed82d278222c /nixos
parented7d3328509e4f5c393fba519e403e9b89867b07 (diff)
nixos/kanata: check the config file at build time
Before this patch, checking the config file is done at runtime. Doing so at build time shortens the feedback loop[1][2]. [1]: https://github.com/NixOS/nixpkgs/issues/278135 [2]: https://github.com/jtroo/kanata/issues/689
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/hardware/kanata.nix22
1 files changed, 14 insertions, 8 deletions
diff --git a/nixos/modules/services/hardware/kanata.nix b/nixos/modules/services/hardware/kanata.nix
index 333b2d2a88a5..a88c993bf091 100644
--- a/nixos/modules/services/hardware/kanata.nix
+++ b/nixos/modules/services/hardware/kanata.nix
@@ -86,14 +86,20 @@ let
in
optionalString ((length devices) > 0) "linux-dev (${devicesString})";
- mkConfig = name: keyboard: pkgs.writeText "${mkName name}-config.kdb" ''
- (defcfg
- ${keyboard.extraDefCfg}
- ${mkDevices keyboard.devices}
- linux-continue-if-no-devs-found yes)
-
- ${keyboard.config}
- '';
+ mkConfig = name: keyboard: pkgs.writeTextFile {
+ name = "${mkName name}-config.kdb";
+ text = ''
+ (defcfg
+ ${keyboard.extraDefCfg}
+ ${mkDevices keyboard.devices}
+ linux-continue-if-no-devs-found yes)
+
+ ${keyboard.config}
+ '';
+ checkPhase = ''
+ ${getExe cfg.package} --cfg "$target" --check --debug
+ '';
+ };
mkService = name: keyboard: nameValuePair (mkName name) {
wantedBy = [ "multi-user.target" ];