From 6854d3756058d3b8d0d2053e2bd7d5200e2a1e41 Mon Sep 17 00:00:00 2001 From: Alex David Date: Sat, 7 Jun 2025 12:45:48 -0700 Subject: [PATCH] Add initial docs website --- website/.gitignore | 1 + website/flake.lock | 27 +++++++++++++++++++++++++++ website/flake.nix | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 website/.gitignore create mode 100644 website/flake.lock create mode 100644 website/flake.nix diff --git a/website/.gitignore b/website/.gitignore new file mode 100644 index 0000000..c4a847d --- /dev/null +++ b/website/.gitignore @@ -0,0 +1 @@ +/result diff --git a/website/flake.lock b/website/flake.lock new file mode 100644 index 0000000..159d169 --- /dev/null +++ b/website/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1749024892, + "narHash": "sha256-OGcDEz60TXQC+gVz5sdtgGJdKVYr6rwdzQKuZAJQpCA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8f1b52b04f2cb6e5ead50bd28d76528a2f0380ef", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/website/flake.nix b/website/flake.nix new file mode 100644 index 0000000..420b16c --- /dev/null +++ b/website/flake.nix @@ -0,0 +1,42 @@ +{ + # This is a separate flake file from the one at the root because we don't + # want to depend on nixpkgs + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; + + outputs = { nixpkgs, ... }: let + pkgs = import nixpkgs { system = "x86_64-linux"; }; + lib = pkgs.lib; + + combinatorDocs = lib.pipe + { + pkgs = throw "Docs must not depend on pkgs"; + lib = throw "Docs must not depend on lib"; + helpers = throw "Docs must not depend on helpers"; + } + [ + (import ../combinators.nix) + (lib.filterAttrs (_: v: !(v ? deprecated && v.deprecated))) + (lib.mapAttrsToList (k: v: "## ${k}\n**${k} :: ${v.sig}**\n\n${v.doc}")) + (lib.concatStringsSep "\n\n") + (docs: "# Combinators\n\n${docs}") + ]; + + mkdocsSettings = { + site_name = "jail-nix"; + repo_url = "https://git.sr.ht/~alexdavid/jail.nix"; + theme = { + name = "readthedocs"; + hljs_languages = [ "nix" ]; + }; + }; + in { + packages.x86_64-linux.default = pkgs.runCommand "website" { buildInputs = [ pkgs.mkdocs ]; } '' + mkdir -p docs + cp ${../README.md} docs/index.md + echo ${lib.escapeShellArg combinatorDocs} > docs/combinators.md + echo ${lib.escapeShellArg (builtins.toJSON mkdocsSettings)} > mkdocs.yml + mkdocs build + mv site $out + ''; + }; +}