nixos-config/configs/home-manager/foo-dogsquared/modules/programs/custom-homepage.nix
Gabriel Arazas f544f3b93f
users/foo-dogsquared/programs/custom-homepage: init
YOOOOOOOOO! This is cool, a Nix-configurable homepage (made with Hugo)
by taking advantage of the way how data are merged within the virtual
filesystem, hell yeah.

Aaaaaand... its novelty wears off a minute later in my setup because
Tridactyl needs to override the tab. :/
2024-09-03 18:08:10 +08:00

71 lines
1.9 KiB
Nix

{ config, lib, pkgs, ... }:
let
userCfg = config.users.foo-dogsquared;
cfg = userCfg.programs.custom-homepage;
settingsFormat = pkgs.formats.toml { };
in
{
options.users.foo-dogsquared.programs.custom-homepage = {
enable = lib.mkEnableOption "addition of custom homepage";
sections = lib.mkOption {
type = with lib.types; attrsOf settingsFormat.type;
description = ''
List of additional sections with their settings to be configured
alongside the hardcoded sections.
'';
default = { };
example = lib.literalExpression ''
{
services = {
name = "Local services";
flavorText = "for the local productivity";
textOnly = true;
links = lib.singleton {
url = "localhost:''${builtins.toString config.services.mopidy.settings.port}";
text = "Music streaming server";
};
};
}
'';
};
package = lib.mkOption {
type = lib.types.package;
description = ''
The package derivation of the website.
'';
default = pkgs.callPackage ../../files/homepage/package.nix { };
};
finalPackage = lib.mkOption {
type = lib.types.package;
description = ''
Output derivation containing the website with all of its modifications.
'';
readOnly = true;
};
};
config = {
users.foo-dogsquared.programs.custom-homepage.finalPackage =
let
data = lib.mapAttrs (n: v:
settingsFormat.generate "fds-homepage-section-${n}" v) cfg.sections;
installDataDir = lib.foldlAttrs (acc: n: v: ''
${acc}
install -Dm0644 ${v} './data/foodogsquared-homepage/links/${n}.toml'
'') "" data;
in
cfg.package.overrideAttrs (prevAttrs: {
preBuild = (prevAttrs.preBuild or "") + ''
${installDataDir}
'';
});
};
}