{ # 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 = { self, nixpkgs, ... }: let pkgs = import nixpkgs { system = "x86_64-linux"; }; lib = pkgs.lib; repo = rec { rev = if self ? rev then self.rev else lib.warn "Repo is dirty, links will not work!" "???"; shortRev = lib.substring 0 8 rev; urls = { base = "https://git.sr.ht/~alexdavid/jail.nix"; commit = "https://git.sr.ht/~alexdavid/jail.nix/commit/${rev}"; file = file: lineNr: "https://git.sr.ht/~alexdavid/jail.nix/tree/${rev}${file}#L${toString lineNr}"; }; }; formatCombinatorDoc = name: combinatorObj: let attrPos = builtins.unsafeGetAttrPos "__functor" combinatorObj; file = lib.removePrefix (toString ./..) attrPos.file; in '' ### ${name} **${name} :: ${combinatorObj.sig}** [Source](${repo.urls.file file attrPos.line}) ${combinatorObj.doc} ''; combinatorDocs = let allCombinators = import ../lib/combinators.nix (throw "Docs must not depend on args") ( throw "Docs must not depend on args" ); formatSection = filter: lib.pipe allCombinators [ (lib.filterAttrs (_: filter)) (lib.mapAttrsToList formatCombinatorDoc) (lib.concatStringsSep "\n\n---\n") ]; hr = ''
tag. # Concatenating with
here is super janky, but good enough for # now. copyright = lib.concatStringsSep "
" [
''
Copyright © 2025 Alex David ///
CC BY-NC-SA 4.0.
''
''
This documentation was generated from the jail.nix repo,
commit ${repo.shortRev}.
''
];
};
in
{
packages.x86_64-linux.default = pkgs.runCommand "website" { buildInputs = [ pkgs.mkdocs ]; } ''
cp -r ${./static-docs} docs
chmod -R +w docs
echo ${lib.escapeShellArg combinatorDocs} > docs/combinators.md
echo ${lib.escapeShellArg (builtins.toJSON mkdocsSettings)} > mkdocs.yml
mkdocs build
mv site $out
'';
};
}