57 lines
1.4 KiB
Nix
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;
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|