From dbb17ef3bebecf0179bed905e921f7324713ae09 Mon Sep 17 00:00:00 2001 From: Cottand Date: Sun, 17 Dec 2023 18:33:56 +0000 Subject: [PATCH] docs: NixOS module examples --- doc/src/Nix.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++---- flake.nix | 2 +- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/doc/src/Nix.md b/doc/src/Nix.md index 107bb82..2cbfa54 100644 --- a/doc/src/Nix.md +++ b/doc/src/Nix.md @@ -6,22 +6,66 @@ Leng is also packaged as [a Nix flake](../../flake.nix). You can simply run `nix run github:cottand/leng` to run latest `master`. -## Installing +## Installing in NixOS via a Module + +The leng flake also exports a NixOS module for easy deployment on NixOS machines. ### In your flake ```nix { - # pinned version for safety - inputs.grimn.url = "github:cottand/leng/v1.3.1"; + inputs = { + # pinned version for safety + leng.url = "github:cottand/leng/v1.4.0"; + leng.nixpkgs.follows = "nixpkgs"; + }; - outputs = { self, leng }: { + outputs = { self, leng, ... }: { # Use in your outputs + nixosConfigurations."this-is-a-server-innit" = nixpkgs.lib.nixosSystem { + modules = [ + ./configuration.nix + leng.nixosModules.default # <- import leng module + { + services.leng = { # <-- now you can use services.leng! + enable = true; + configuration = { + api = "127.0.0.1:8080"; + metrics.enabled = true; + blocking.sourcesStore = "/var/lib/leng-sources"; + }; + }; + } + ]; + }; }; } ``` +### Legacy Nix + +Add the following inside your configuration.nix: +```nix +{pkgs, lib, ... }: { + imports = [ + # import leng module + (builtins.getFlake "github:cottand/leng/1.4.0").nixosModules.default + ]; + + # now you can use services.leng! + services.leng = { + enable = true; + configuration = { + api = "127.0.0.1:8080"; + metrics.enabled = true; + blocking.sourcesStore = "/var/lib/leng-sources"; + }; + }; + +} +``` + ## Developing The flake's development shell simply includes Go 1.21+ and a [fish](https://fishshell.com/) shell. You can enter it with `nix develop`. diff --git a/flake.nix b/flake.nix index e327d85..c25baee 100644 --- a/flake.nix +++ b/flake.nix @@ -81,7 +81,7 @@ { api = "127.0.0.1:8080"; metrics.enabled = true; - blocking.sourcesStore = "/var/leng-sources"; + blocking.sourcesStore = "/var/lib/leng-sources"; } ''; };