nixos-config/modules/services/homer.nix
Christoph Heiss 17b2af9fec
pkgs: Remove two unneeded lib.mdDoc usages
Signed-off-by: Christoph Heiss <christoph@c8h4.io>
2023-11-11 00:31:24 +01:00

57 lines
1.4 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.homer;
configFile =
pkgs.writeText "homer-config.yml" (generators.toYAML { } cfg.settings);
in {
options.services.homer = {
enable = mkEnableOption "Whether to enable the Homer dashboard nginx vhost";
package = mkPackageOption pkgs "homer" { };
virtualHost = {
name = mkOption {
description = "Name of the vhost to configure homer for.";
default = "localhost";
type = types.str;
};
location = mkOption {
description = "Path to serve homer at.";
default = "/";
type = types.path;
};
};
settings = mkOption {
description = ''
Configuration for the Homer dashboard.
See the [Homer documentation](https://github.com/bastienwirtz/homer/blob/main/docs/configuration.md)
for more information.
'';
default = { };
type = types.attrs;
};
};
config = mkIf cfg.enable {
services.nginx.virtualHosts.${cfg.virtualHost.name} = {
locations.${cfg.virtualHost.location}.root = "${cfg.package}/share/www";
locations."= ${
removeSuffix "/" cfg.virtualHost.location
}/assets/config.yml" = {
root = "${dirOf configFile}";
tryFiles = "/${baseNameOf configFile} =404";
extraConfig = ''
expires -1;
'';
};
};
};
}