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. :/
This commit is contained in:
Gabriel Arazas 2024-09-03 18:08:10 +08:00
parent cff4e0de43
commit f544f3b93f
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
2 changed files with 71 additions and 0 deletions

View File

@ -11,6 +11,7 @@
./programs/jujutsu.nix
./programs/keys.nix
./programs/nixvim
./programs/custom-homepage.nix
./programs/research.nix
./programs/shell.nix
./programs/terminal-multiplexer.nix

View File

@ -0,0 +1,70 @@
{ 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}
'';
});
};
}