1
0
Fork 0
mirror of https://git.sr.ht/~roxwize/.dotfiles synced 2025-03-14 00:13:26 +00:00
This commit is contained in:
Rae 5e 2025-03-07 18:04:01 -05:00
parent 97f284d3fe
commit 72616a26ff
Signed by: rae
GPG key ID: 5B1A0FAB9BAB81EE

View file

@ -1,48 +1,48 @@
{ pkgs, lib, config, ... }: let { pkgs, lib, config, ... }: let
cfg = config.r5e.containers.homepage; cfg = config.r5e.containers.homepage;
settingsFormat = pkgs.formats.yaml {}; settingsFormat = pkgs.formats.yaml {};
in { in with lib; {
options.r5e.containers.homepage = { options.r5e.containers.homepage = {
enable = lib.mkEnableOption "homepage"; enable = mkEnableOption "homepage";
listenPort = { listenPort = mkOption {
type = lib.types.int; type = types.int;
default = 3000; default = 3000;
}; };
openFirewall = lib.mkOption { openFirewall = mkOption {
type = lib.types.bool; type = types.bool;
default = false; default = false;
}; };
settings = lib.mkOption { settings = mkOption {
inherit (settingsFormat) type; inherit (settingsFormat) type;
description = "See https://gethomepage.dev/configs/settings/"; description = "See https://gethomepage.dev/configs/settings/";
default = {}; default = {};
}; };
widgets = lib.mkOption { widgets = mkOption {
inherit (settingsFormat) type; inherit (settingsFormat) type;
description = "See https://gethomepage.dev/widgets/"; description = "See https://gethomepage.dev/widgets/";
default = []; default = [];
}; };
imagesDir = lib.mkOption { imagesDir = mkOption {
type = lib.types.path; type = types.path;
default = ""; default = "";
} };
}; };
config = lib.mkMerge [ config = mkMerge [
(import ./compose.nix { inherit pkgs lib; }) (import ./compose.nix { inherit pkgs lib; })
{ {
environment.etc = lib.mkIf cfg.enable { environment.etc = mkIf cfg.enable {
"homepage-dashboard/settings.yaml".source = settingsFormat.generate "settings.yaml" cfg.settings; "homepage-dashboard/settings.yaml".source = settingsFormat.generate "settings.yaml" cfg.settings;
"homepage-dashboard/widgets.yaml".source = settingsFormat.generate "widgets.yaml" cfg.widgets; "homepage-dashboard/widgets.yaml".source = settingsFormat.generate "widgets.yaml" cfg.widgets;
}; };
networking.firewall = lib.mkIf cfg.openFirewall { networking.firewall = mkIf cfg.openFirewall {
allowedTCPPorts = [ builtins.toString cfg.listenPort ]; allowedTCPPorts = [ builtins.toString cfg.listenPort ];
}; };
virtualisation.oci-containers.containers.homepage = { virtualisation.oci-containers.containers.homepage = {
ports = [ builtins.toString cfg.listenPort + ":3000/tcp" ]; ports = [ (builtins.toString cfg.listenPort + ":3000/tcp") ];
volumes = lib.mkIf cfg.imagesDir [ builtins.toString cfg.imagesDir + ":/app/public/images:rw" ]; volumes = mkIf cfg.imagesDir [ (builtins.toString cfg.imagesDir + ":/app/public/images:rw") ];
}; };
} }
]; ];