tvl-depot/web/todolist/default.nix
Vincent Ambo 473604f567 refactor: Move nixpkgs attribute to third_party.nixpkgs
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
2021-04-10 21:18:55 +00:00

110 lines
2.7 KiB
Nix

# Generates a simple web view of open TODOs in the depot.
#
# Only TODOs that match the form 'TODO($username)' are considered, and
# only for users that are known to us.
{ depot, lib, pkgs, ... }:
with depot.nix.yants;
let
inherit (pkgs)
jq
ripgrep
runCommandNoCC
writeText
;
inherit (builtins)
elem
filter
fromJSON
head
readFile
map
;
inherit (lib) concatStringsSep;
knownUsers = map (u: u.username) depot.ops.users;
todo = struct {
file = string;
line = int;
todo = string;
user = string;
};
allTodos = fromJSON (readFile (runCommandNoCC "depot-todos.json" {} ''
${ripgrep}/bin/rg --json 'TODO\(\w+\):.*$' ${depot.depotPath} | \
${jq}/bin/jq -s -f ${./extract-todos.jq} > $out
''));
knownUserTodos = filter (todos: elem (head todos).user knownUsers) allTodos;
fileLink = defun [ todo string ] (t:
''<a style="color: inherit;"
href="https://cs.tvl.fyi/depot/-/blob/${t.file}#L${toString t.line}">
//${t.file}:${toString t.line}</a>'');
todoElement = defun [ todo string ] (t: ''
<p>${fileLink t}:</p>
<blockquote>${t.todo}</blockquote>
'');
userParagraph = todos:
let user = (head todos).user;
in ''
<p>
<h3>
<a style="color:inherit; text-decoration: none;"
name="${user}"
href="#${user}">${user}</a>
</h3>
${concatStringsSep "\n" (map todoElement todos)}
</p>
<hr>
'';
todoPage = writeText "index.html" ''
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="TVL's todo-list">
<link rel="stylesheet" type="text/css" href="static/tazjin.css" media="all">
<link rel="icon" type="image/webp" href="static/favicon.webp">
<title>TVL's todo-list</title>
<style>
svg {
max-width: inherit;
height: auto;
}
</style>
</head>
<body class="dark">
<header>
<h1><a class="blog-title" href="/">The Virus Lounge's todo-list</a> </h1>
<hr>
</header>
<main>
${concatStringsSep "\n" (map userParagraph knownUserTodos)}
</main>
<footer>
<p class="footer">
<a class="uncoloured-link" href="https://tvl.fyi">homepage</a>
|
<a class="uncoloured-link" href="https://cs.tvl.fyi/depot/-/blob/README.md">code</a>
|
<a class="uncoloured-link" href="https://cl.tvl.fyi">reviews</a>
</p>
<p class="lod">_</p>
</footer>
</body>
'';
in runCommandNoCC "tvl-todos" {} ''
mkdir $out
cp ${todoPage} $out/index.html
ln -s ${depot.web.tvl}/static $out/static
''