8 cfg = config.services.homepage-dashboard;
9 # Define the settings format used for this program
10 settingsFormat = pkgs.formats.yaml { };
14 services.homepage-dashboard = {
15 enable = lib.mkEnableOption "Homepage Dashboard, a highly customizable application dashboard";
17 package = lib.mkPackageOption pkgs "homepage-dashboard" { };
19 openFirewall = lib.mkOption {
20 type = lib.types.bool;
22 description = "Open ports in the firewall for Homepage.";
25 listenPort = lib.mkOption {
28 description = "Port for Homepage to bind to.";
31 environmentFile = lib.mkOption {
34 The path to an environment file that contains environment variables to pass
35 to the homepage-dashboard service, for the purpose of passing secrets to
38 See the upstream documentation:
40 https://gethomepage.dev/latest/installation/docker/#using-environment-secrets
45 customCSS = lib.mkOption {
46 type = lib.types.lines;
48 Custom CSS for styling Homepage.
50 See https://gethomepage.dev/latest/configs/custom-css-js/.
55 customJS = lib.mkOption {
56 type = lib.types.lines;
58 Custom Javascript for Homepage.
60 See https://gethomepage.dev/latest/configs/custom-css-js/.
65 bookmarks = lib.mkOption {
66 inherit (settingsFormat) type;
68 Homepage bookmarks configuration.
70 See https://gethomepage.dev/latest/configs/bookmarks/.
72 # Defaults: https://github.com/gethomepage/homepage/blob/main/src/skeleton/bookmarks.yaml
76 { Github = [{ abbr = "GH"; href = "https://github.com/"; }]; }
81 { YouTube = [{ abbr = "YT"; href = "https://youtube.com/"; }]; }
88 services = lib.mkOption {
89 inherit (settingsFormat) type;
91 Homepage services configuration.
93 See https://gethomepage.dev/latest/configs/services/.
95 # Defaults: https://github.com/gethomepage/homepage/blob/main/src/skeleton/services.yaml
100 "My First Service" = {
101 href = "http://localhost/";
102 description = "Homepage is awesome";
108 "My Second Group" = [
110 "My Second Service" = {
111 href = "http://localhost/";
112 description = "Homepage is the best";
121 widgets = lib.mkOption {
122 inherit (settingsFormat) type;
124 Homepage widgets configuration.
126 See https://gethomepage.dev/latest/configs/service-widgets/.
128 # Defaults: https://github.com/gethomepage/homepage/blob/main/src/skeleton/widgets.yaml
139 provider = "duckduckgo";
147 kubernetes = lib.mkOption {
148 inherit (settingsFormat) type;
150 Homepage kubernetes configuration.
152 See https://gethomepage.dev/latest/configs/kubernetes/.
157 docker = lib.mkOption {
158 inherit (settingsFormat) type;
160 Homepage docker configuration.
162 See https://gethomepage.dev/latest/configs/docker/.
167 settings = lib.mkOption {
168 inherit (settingsFormat) type;
172 See https://gethomepage.dev/latest/configs/settings/.
174 # Defaults: https://github.com/gethomepage/homepage/blob/main/src/skeleton/settings.yaml
182 # If homepage-dashboard is enabled, but none of the configuration values have been updated,
183 # then default to "unmanaged" configuration which is manually updated in
184 # var/lib/homepage-dashboard. This is to maintain backwards compatibility, and should be
185 # deprecated in a future release.
187 cfg.bookmarks == [ ] &&
188 cfg.customCSS == "" &&
189 cfg.customJS == "" &&
191 cfg.kubernetes == { } &&
192 cfg.services == [ ] &&
193 cfg.settings == { } &&
197 configDir = if managedConfig then "/etc/homepage-dashboard" else "/var/lib/homepage-dashboard";
199 msg = "using unmanaged configuration for homepage-dashboard is deprecated and will be removed"
200 + " in 24.05. please see the NixOS documentation for `services.homepage-dashboard' and add"
201 + " your bookmarks, services, widgets, and other configuration using the options provided.";
203 lib.mkIf cfg.enable {
204 warnings = lib.optional (!managedConfig) msg;
206 environment.etc = lib.mkIf managedConfig {
207 "homepage-dashboard/custom.css".text = cfg.customCSS;
208 "homepage-dashboard/custom.js".text = cfg.customJS;
210 "homepage-dashboard/bookmarks.yaml".source = settingsFormat.generate "bookmarks.yaml" cfg.bookmarks;
211 "homepage-dashboard/docker.yaml".source = settingsFormat.generate "docker.yaml" cfg.docker;
212 "homepage-dashboard/kubernetes.yaml".source = settingsFormat.generate "kubernetes.yaml" cfg.kubernetes;
213 "homepage-dashboard/services.yaml".source = settingsFormat.generate "services.yaml" cfg.services;
214 "homepage-dashboard/settings.yaml".source = settingsFormat.generate "settings.yaml" cfg.settings;
215 "homepage-dashboard/widgets.yaml".source = settingsFormat.generate "widgets.yaml" cfg.widgets;
218 systemd.services.homepage-dashboard = {
219 description = "Homepage Dashboard";
220 after = [ "network.target" ];
221 wantedBy = [ "multi-user.target" ];
224 HOMEPAGE_CONFIG_DIR = configDir;
225 HOMEPAGE_CACHE_DIR = "/var/cache/homepage-dashboard";
226 PORT = toString cfg.listenPort;
227 LOG_TARGETS = lib.mkIf managedConfig "stdout";
233 EnvironmentFile = lib.mkIf (cfg.environmentFile != null) cfg.environmentFile;
234 StateDirectory = lib.mkIf (!managedConfig) "homepage-dashboard";
235 CacheDirectory = "homepage-dashboard";
236 ExecStart = lib.getExe cfg.package;
237 Restart = "on-failure";
241 networking.firewall = lib.mkIf cfg.openFirewall {
242 allowedTCPPorts = [ cfg.listenPort ];