dotfiles/system/modules/buffyboard.nix

51 lines
1.6 KiB
Nix
Raw Normal View History

2024-03-19 15:05:23 +07:00
{ config
, lib
, pkgs
, ...
}:
let
cfg = config.phone;
in
2024-03-19 15:05:23 +07:00
{
options.phone.buffyboard = {
enable = lib.mkEnableOption "buffyboard";
2024-03-19 15:05:23 +07:00
};
config = lib.mkIf cfg.buffyboard.enable {
2024-03-19 15:05:23 +07:00
boot.initrd.kernelModules = [ "uinput" "evdev" ];
boot.initrd.extraUtilsCommands = ''
copy_bin_and_libs ${pkgs.buffyboard}/bin/buffyboard
cp -a ${pkgs.libinput.out}/share $out/
'';
boot.initrd.extraUdevRulesCommands = ''
cp -v ${config.systemd.package}/lib/udev/rules.d/60-input-id.rules $out/
cp -v ${config.systemd.package}/lib/udev/rules.d/60-persistent-input.rules $out/
cp -v ${config.systemd.package}/lib/udev/rules.d/70-touchpad.rules $out/
'';
boot.initrd.preLVMCommands = ''
mkdir -p /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.libinput.name}/
ln -s "$(dirname "$(dirname "$(which buffyboard)")")"/share /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.libinput.name}/
buffyboard 2>/dev/null &
'';
boot.initrd.postMountCommands = ''
pkill -x buffyboard
'';
systemd.services.buffyboard = {
description = "buffyboard";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${pkgs.buffyboard}/bin/buffyboard";
Restart = "always";
RestartSec = "1";
};
};
security.sudo.extraRules = [
{ groups = [ "users" ];
commands = [
{ command = "/run/current-system/sw/bin/systemctl stop buffyboard"; options = [ "SETENV" "NOPASSWD" ]; }
{ command = "/run/current-system/sw/bin/systemctl start buffyboard"; options = [ "SETENV" "NOPASSWD" ]; }
]; }
];
};
}