Skip to content

Install on nixOs via flake instructions #324

@andycandy-dev

Description

@andycandy-dev

In order to use swhkd package on nixOs:

  1. requires Fix permission groups #325
  2. I've added a packages output to the flake.nix file andycandy-dev@8a15e7a
    not as clean as it could have been but it works.
  3. above flake provides two packages, I had to use swhkd-no-rfkill as of [fix] remove rfkill switch support #254 conversation - otherwise running swhkd nuked my wifi.
  4. followed directions Latest changes to make swhkd work in Arch terminal #285 (comment) , which references Improve The Security Model #270 for setuid on my configuration.nix
{ config, lib, pkgs, inputs, ... }:
let
  swhkdPkg = inputs.swhkd.packages.x86_64-linux.swhkd-no-rfkill;
in
{
  security.wrappers.swhkd = {
    owner = "root";
    group = "root";
    setuid = true;
    source = "${swhkdPkg}/bin/swhkd";
  };
} 
  1. setup userspace systemd with home-manager
{ config, lib, pkgs, inputs, ... }:
let
  username = config.home.username;
  swhkdPkg = inputs.swhkd.packages.x86_64-linux.swhkd-no-rfkill;
  swhks-launcher = pkgs.writeShellScript "swhks-launcher" ''
    ${pkgs.killall}/bin/killall swhks swhkd 2>/dev/null || true
    ${swhkdPkg}/bin/swhks &
    sleep 0.5
    /run/wrappers/bin/swhkd -c /home/${username}/.config/swhkd/swhkdrc
  '';
in
{
  xdg.configFile."swhkd/swhkdrc".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/nixos-dots/home/swhkd/swhkdrc"; 

  systemd.user.services.swhkd = {
    Unit.Description = "Simple Wayland HotKey Server";
    Unit.After = [ "graphical-session.target" ];
    Service = {
      ExecStart = "${swhks-launcher}";
      ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
      Restart = "on-failure";
      KillMode = "mixed";
    };
    Install.WantedBy = [ "graphical-session.target" ];
  };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions