Skip to content

Commit

Permalink
doc/installation/nix: Recommend flakes for NixOS
Browse files Browse the repository at this point in the history
  • Loading branch information
slotThe committed May 30, 2024
1 parent 9a97f4b commit 9affc9f
Showing 1 changed file with 49 additions and 41 deletions.
90 changes: 49 additions & 41 deletions doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,58 +384,66 @@ You can install `kmonad` via `xbps-install`:

### NixOS

The following instructions show how to install and configure KMonad in NixOS.
The following instructions show how to install and configure KMonad in NixOS with flakes enabled.
There is a NixOS module included in this repository that can be used
instead of a manual configuration.

#### configuration.nix

1. Clone this repository or copy the file
[`nix/nixos-module.nix`](../nix/nixos-module.nix) somewhere to your system.
#### flake.nix

2. Import `nixos-module.nix`, install KMonad, and configure your keyboard in
`configuration.nix`
1. Add KMonad as an input:

``` nix
imports =
[
...
/path/to/nixos-module.nix
];
environment.systemPackages = with pkgs; [
...
haskellPackages.kmonad
...
];
services.kmonad = {
enable = true;
keyboards = {
myKMonadOutput = {
device = "/dev/input/by-id/my-keyboard-kbd";
config = builtins.readFile /path/to/my/config.kbd;
};
};
# If you've installed KMonad from a different source, update this property
package = pkgs.haskellPackages.kmonad;
};
kmonad = {
url = "git+https://github.com/kmonad/kmonad?submodules=1&dir=nix";
inputs.nixpkgs.follows = "nixpkgs";
};
```

If you've set `enable = true;` in `services.kmonad`, do not put a
`setxkbmap` line in your `config.kbd`. Instead, set the options like
this:
2. Import the NixOS module in your configuration:

``` nix
services.xserver = {
xkbOptions = "compose:ralt";
layout = "us";
outputs = { kmonad, … }:
{
nixosConfigurations.«systemName» = nixpkgs.lib.nixosSystem {
modules = [
kmonad.nixosModules.default
];
};
};
```

3. Rebuild system:
#### configuration.nix

Finally, you can add

``` console
nixos-rebuild switch
```
``` nix
services.kmonad = {
enable = true;
keyboards = {
myKMonadOutput = {
device = "/dev/input/by-id/my-keyboard-kbd";
config = builtins.readFile /path/to/my/config.kbd;
};
};
};
```

to your `configuration.nix`.
For more configuration options, see [nixos-module.nix](../nix/nixos-module.nix).

If you've set `enable = true;` in `services.kmonad`,
do not put a `setxkbmap` line in your `config.kbd`.
Instead, set the options like this:

``` nix
services.xserver = {
xkbOptions = "compose:ralt";
layout = "us";
};
```

All that's left is to rebuild your system!

``` console
$ sudo nixos-rebuild switch --flake /path/to/flake
```

0 comments on commit 9affc9f

Please sign in to comment.