473604f567
Please read b/108 to make sense of this. This gets rid of the explicit list of exposed packages from nixpkgs, and instead makes the entire package set available at `third_party.nixpkgs`. To accommodate this, a LOT of things have to be very slightly shuffled around. Some of this was done in already submitted CLs, but this change is unfortunately still quite noisy. Pay extra attention to: * overlay-like functionality that was partially moved to actual overlays (partially as in, the minimum required to get a green build) * modified uses of the package set path, esp. in NixOS systems Special notes: * xanthous has been disabled in CI because of issues with the Haskell overlay * //third_party/nix has been disabled because of other unclear dependency issues Both of these will be tackled in a followup CL. Change-Id: I2f9c60a4d275fdb5209264be0addfd7e06c53118 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2910 Reviewed-by: glittershark <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
75 lines
2.3 KiB
Nix
75 lines
2.3 KiB
Nix
# Assembles the website index and configures an nginx instance to
|
|
# serve it.
|
|
#
|
|
# The website is made up of a simple header&footer and content
|
|
# elements for things such as blog posts and projects.
|
|
#
|
|
# Content for the blog is in //users/tazjin/blog instead of here.
|
|
{ depot, lib, pkgs, ... }@args:
|
|
|
|
with depot;
|
|
with nix.yants;
|
|
|
|
let
|
|
inherit (builtins) readFile replaceStrings sort;
|
|
inherit (pkgs) writeFile runCommandNoCC;
|
|
|
|
# The different types of entries on the homepage.
|
|
entryClass = enum "entryClass" [ "blog" "project" "misc" ];
|
|
|
|
# The definition of a single entry.
|
|
entry = struct "entry" {
|
|
class = entryClass;
|
|
title = string;
|
|
url = string;
|
|
date = int; # epoch
|
|
description = option string;
|
|
};
|
|
|
|
escape = replaceStrings [ "<" ">" "&" "'" ] [ "<" ">" "&" "'" ];
|
|
|
|
postToEntry = defun [ users.tazjin.blog.post entry ] (post: {
|
|
class = "blog";
|
|
title = post.title;
|
|
url = "/blog/${post.key}";
|
|
date = post.date;
|
|
});
|
|
|
|
formatDate = defun [ int string ] (date: readFile (runCommandNoCC "date" {} ''
|
|
date --date='@${toString date}' '+%Y-%m-%d' > $out
|
|
''));
|
|
|
|
formatEntryDate = defun [ entry string ] (entry: entryClass.match entry.class {
|
|
blog = "Blog post from ${formatDate entry.date}";
|
|
project = "Project from ${formatDate entry.date}";
|
|
misc = "Posted on ${formatDate entry.date}";
|
|
});
|
|
|
|
entryToDiv = defun [ entry string ] (entry: ''
|
|
<a href="${entry.url}" class="entry ${entry.class}">
|
|
<div>
|
|
<p class="entry-title">${escape entry.title}</p>
|
|
${
|
|
lib.optionalString ((entry ? description) && (entry.description != null))
|
|
"<p class=\"entry-description\">${escape entry.description}</p>"
|
|
}
|
|
<p class="entry-date">${formatEntryDate entry}</p>
|
|
</div>
|
|
</a>
|
|
'');
|
|
|
|
index = entries: pkgs.writeText "index.html" (lib.concatStrings (
|
|
[ (builtins.readFile ./header.html) ]
|
|
++ (map entryToDiv (sort (a: b: a.date > b.date) entries))
|
|
++ [ (builtins.readFile ./footer.html) ]
|
|
));
|
|
|
|
pageEntries = import ./entries.nix;
|
|
homepage = index ((map postToEntry users.tazjin.blog.posts) ++ pageEntries);
|
|
atomFeed = import ./feed.nix (args // { inherit entry pageEntries; });
|
|
in runCommandNoCC "website" {} ''
|
|
mkdir $out
|
|
cp ${homepage} $out/index.html
|
|
cp ${atomFeed} $out/feed.atom
|
|
cp -r ${./static} $out/static
|
|
''
|