From 1f928e2a53d5c7659be63e7143d8b453e4d88ff5 Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Mon, 17 May 2021 04:05:29 +0300 Subject: [PATCH] feat: made with nix banner --- flake.lock | 13 ++++++++----- flake.nix | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index 4b52bec..e2a53f8 100644 --- a/flake.lock +++ b/flake.lock @@ -20,7 +20,9 @@ "flakeUtils": [ "flakeUtils" ], - "nixpkgs": "nixpkgs" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1621211208, @@ -38,11 +40,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1621084586, - "narHash": "sha256-raHuJ7ohDLDPqohJzZxhaER7sSh4/1xR6YcUYMj3c3E=", + "lastModified": 1621169420, + "narHash": "sha256-NKFX7QhxRQkaw0+NjcZ6N+cYpDs7gkpMHxNC8QHkprg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e83b3f3394834c41c0d25017f6808d65c3d6f880", + "rev": "c58b97674b12d238d9d21e8ab9ee9d7a6b81ae8f", "type": "github" }, "original": { @@ -55,7 +57,8 @@ "root": { "inputs": { "flakeUtils": "flakeUtils", - "htmlNix": "htmlNix" + "htmlNix": "htmlNix", + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 94d5871..ea446ab 100644 --- a/flake.nix +++ b/flake.nix @@ -3,16 +3,46 @@ htmlNix = { url = "github:yusdacra/html.nix"; inputs.flakeUtils.follows = "flakeUtils"; + inputs.nixpkgs.follows = "nixpkgs"; }; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flakeUtils.url = "github:numtide/flake-utils"; }; - outputs = { htmlNix, flakeUtils, ... }@inputs: + outputs = { htmlNix, flakeUtils, nixpkgs, ... }@inputs: with flakeUtils.lib; eachDefaultSystem (system: let + pkgs = import nixpkgs { inherit system; }; + inherit (pkgs.lib) mapAttrsRecursive hasSuffix last; + lib = htmlNix.lib.${system}; - ownTemplater = x: x; + 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"; } + (a { class = "botheader"; href = "https://github.com/yusdacra/html.nix"; } "made with Nix in html.nix"); + 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}"; }; + }; site = local: lib.pkgsLib.mkSiteFrom { inherit local; src = ./.; templater = context: ownTemplater (lib.templaters.basic context); }; in rec {