From 9affc9f85e84e4648d097427aa9ed99ad4c0418f Mon Sep 17 00:00:00 2001 From: Tony Zorman Date: Thu, 30 May 2024 21:31:09 +0200 Subject: [PATCH] doc/installation/nix: Recommend flakes for NixOS --- doc/installation.md | 90 ++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/doc/installation.md b/doc/installation.md index 3fd04d52..de315483 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -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 +```