mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 16:57:55 +00:00
Gabriel Arazas
f544f3b93f
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. :/
71 lines
1.9 KiB
Nix
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}
|
|
'';
|
|
});
|
|
};
|
|
}
|