2021-05-16 23:23:08 +03:00
|
|
|
{
|
|
|
|
inputs = {
|
|
|
|
htmlNix = {
|
|
|
|
url = "github:yusdacra/html.nix";
|
|
|
|
inputs.flakeUtils.follows = "flakeUtils";
|
2021-05-17 04:05:29 +03:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
2021-05-16 23:23:08 +03:00
|
|
|
};
|
2021-05-17 04:05:29 +03:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2021-05-16 23:23:08 +03:00
|
|
|
flakeUtils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
|
2021-05-17 04:05:29 +03:00
|
|
|
outputs = { htmlNix, flakeUtils, nixpkgs, ... }@inputs:
|
2021-05-16 23:23:08 +03:00
|
|
|
with flakeUtils.lib;
|
|
|
|
eachDefaultSystem (system:
|
|
|
|
let
|
2021-05-17 04:05:29 +03:00
|
|
|
pkgs = import nixpkgs { inherit system; };
|
2021-05-17 04:23:57 +03:00
|
|
|
inherit (pkgs.lib) mapAttrsRecursive hasSuffix last pipe;
|
2021-05-17 04:05:29 +03:00
|
|
|
|
2021-05-16 23:23:08 +03:00
|
|
|
lib = htmlNix.lib.${system};
|
2021-05-17 04:05:29 +03:00
|
|
|
ownTemplater = context: context // {
|
|
|
|
site =
|
|
|
|
let
|
|
|
|
headerStyle = with lib.css; css {
|
|
|
|
"div.botheader" = {
|
|
|
|
position = "fixed";
|
|
|
|
padding-bottom = "0.5%";
|
|
|
|
bottom = 0;
|
|
|
|
left = 0;
|
|
|
|
right = 0;
|
|
|
|
margin-left = "auto";
|
|
|
|
margin-right = "auto";
|
|
|
|
text-align = "center";
|
|
|
|
background = "#111111";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
header = with lib.tags; div { class = "botheader"; }
|
2021-05-17 04:36:20 +03:00
|
|
|
(a { href = "https://github.com/yusdacra/html.nix"; } "❄ made with Nix in html.nix");
|
2021-05-17 04:05:29 +03:00
|
|
|
in
|
|
|
|
(
|
|
|
|
mapAttrsRecursive
|
|
|
|
(path: value:
|
|
|
|
if hasSuffix ".html" (last path) then "${value}\n${header}" else value)
|
|
|
|
context.site
|
|
|
|
) // { "site.css" = "${context.site."site.css"}\n${headerStyle}"; };
|
|
|
|
};
|
2021-05-17 04:23:57 +03:00
|
|
|
site = local: lib.pkgsLib.mkSiteFrom { inherit local; src = ./.; templater = context: pipe context [ lib.templaters.basic ownTemplater ]; };
|
2021-05-16 23:23:08 +03:00
|
|
|
in
|
|
|
|
rec {
|
|
|
|
apps = {
|
|
|
|
website = mkApp {
|
2021-05-17 00:34:46 +03:00
|
|
|
drv = lib.pkgsLib.mkServeFromSite (site true);
|
2021-05-16 23:23:08 +03:00
|
|
|
name = "serve";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
packages = {
|
2021-05-17 00:34:46 +03:00
|
|
|
website = lib.pkgsLib.mkSitePath (site false);
|
2021-05-16 23:23:08 +03:00
|
|
|
};
|
|
|
|
defaultPackage = packages.website;
|
|
|
|
defaultApp = apps.website;
|
|
|
|
});
|
|
|
|
}
|