From b1d987763cf6d850eb0d335a526a9f0ce44a38b9 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Sun, 26 Feb 2023 03:53:55 +0100 Subject: [PATCH] merge docs, add yagcd --- README.md | 2 + base.nix | 1 + hosts/noximilien/default.nix | 3 ++ profiles/web/docs/default.nix | 48 +++++++++++++++++++++++ profiles/web/docs/pdoc/default.nix | 18 ++++++++- profiles/web/docs/python-docs/default.nix | 26 ++++-------- profiles/web/docs/yagcd/default.nix | 23 +++++++++++ profiles/web/index/default.nix | 1 + 8 files changed, 101 insertions(+), 21 deletions(-) create mode 100644 profiles/web/docs/default.nix create mode 100644 profiles/web/docs/yagcd/default.nix diff --git a/README.md b/README.md index 6e69256..2b7e95c 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ * [x] Split stuff into multiple files * [x] Make a flake +* [x] merge hosted docs into a single subdomain +* [ ] pre-commit hook with 'nix eval' * [ ] Setup some remote-development flow * [ ] users/pbsds: Support multiple profiles, like headless, nixpkgs-dev, various desktops, hpc, pvv, etc * [ ] nixos-generate-config instructions diff --git a/base.nix b/base.nix index 2bc32eb..0d4d83b 100644 --- a/base.nix +++ b/base.nix @@ -32,6 +32,7 @@ "-L" # print build logs ]; }; + # TODO: this doesn't work during 'nix eval' on a non-nixos machine #assertions = [ # { assertion = builtins.pathExists "/etc/nixos/flake.nix"; message = "You have yet to test systems without a flake in /etc/nixos"; } #]; diff --git a/hosts/noximilien/default.nix b/hosts/noximilien/default.nix index bdd6319..564404e 100644 --- a/hosts/noximilien/default.nix +++ b/hosts/noximilien/default.nix @@ -47,8 +47,11 @@ #../../profiles/web/services/censordodge #../../profiles/web/services/openspeedtest + ../../profiles/web/docs ../../profiles/web/docs/pdoc ../../profiles/web/docs/python-docs + ../../profiles/web/docs/yagcd + ../../profiles/web/sites/linktree-pbsds ../../profiles/web/sites/refleksjon-no ../../profiles/web/sites/roroslyd-no diff --git a/profiles/web/docs/default.nix b/profiles/web/docs/default.nix new file mode 100644 index 0000000..eed40b2 --- /dev/null +++ b/profiles/web/docs/default.nix @@ -0,0 +1,48 @@ +{ config, pkgs, lib, mkDomain, ... }: +{ + options = with lib; { + #services.docs-to-host.enable = mkEnable "docs-to-host"; + services.docs-to-host.docs = mkOption { + type = types.listOf (types.submodule { + options = { + subdir = mkOption { + type = types.str; + example = "pdoc"; + description = lib.mdDoc "The path at which the documentation will be linked"; + }; + path = mkOption { + type = types.path; + example = lib.literalExpression "pkgs.fetchzip {...}"; + description = lib.mdDoc "The static html documentation to host"; + }; + desc = mkOption { + type = types.str; + #description = "A short decription about the hosted documentation in markdown."; + description = "A short decription about the hosted documentation."; + }; + }; + }); + default = [ ]; + #description = lib.mdDoc ''TODO''; + }; + }; + + config = let + cfg = config.services.docs-to-host; + mkRow = {subdir, path, desc}: ''${subdir}/${desc}''; + mkEntry = {subdir, path, desc}: { name = subdir; path = path; }; + in { + services.nginx.virtualHosts.${mkDomain "docs"} = { + forceSSL = true; # addSSL = true; + enableACME = true; #useACMEHost = acmeDomain; + root = pkgs.linkFarm "docs-html" ([{name = "index.html"; path = pkgs.writeText "docs-index.html" '' + + +
URLDesc + ${lib.concatStringsSep "\n" ( builtins.map mkRow cfg.docs ) } +
+ ''; + }] ++ (builtins.map mkEntry cfg.docs)); + }; + }; +} diff --git a/profiles/web/docs/pdoc/default.nix b/profiles/web/docs/pdoc/default.nix index 0ec7a60..cc159da 100644 --- a/profiles/web/docs/pdoc/default.nix +++ b/profiles/web/docs/pdoc/default.nix @@ -252,11 +252,24 @@ let in { - # lib.filter (x: lib.isDerivation x && (builtins.tryEval x.outPath).success) (lib.attrValues linuxPackages_latest)) - # Pdoc # Auto-generate API documentation for Python projects. + services.docs-to-host.docs = [ + { + subdir = "pdoc-docs"; + path = mkPdocs false; + desc = "Documentation for various python modules, generated with pdoc"; + } + { + subdir = "pdoc3-docs"; + path = mkPdocs true; + desc = "Documentation for various python modules, generated with pdoc"; + } + ]; + + + /** / services.nginx.virtualHosts.${mkDomain "pdoc"} = { forceSSL = true; # addSSL = true; enableACME = true; #useACMEHost = acmeDomain; @@ -267,5 +280,6 @@ in { enableACME = true; #useACMEHost = acmeDomain; root = mkPdocs true; }; + /**/ } diff --git a/profiles/web/docs/python-docs/default.nix b/profiles/web/docs/python-docs/default.nix index 56c5853..c0bb43c 100644 --- a/profiles/web/docs/python-docs/default.nix +++ b/profiles/web/docs/python-docs/default.nix @@ -1,24 +1,12 @@ -{ config, pkgs, lib, mkDomain, ... }: +{ config, pkgs, lib, ... }: let - python-versions = (lib.attrNames pkgs.pythonDocs.html); - mkLinkFarmEntry = python-version: { - name = python-version; - path = "${builtins.toString pkgs.pythonDocs.html.${python-version}}/share/doc/${python-version}/html"; + python-versions = lib.attrNames (lib.filterAttrs (k: v: lib.isDerivation v) pkgs.pythonDocs.html); + mkDocsEntry = python-version: { + subdir = "${python-version}"; + path = "${builtins.toString pkgs.pythonDocs.html.${python-version}}/share/doc/${python-version}/html"; + desc = "Documentation for Python ${pkgs.${python-version}.version}"; }; in { - services.nginx.virtualHosts.${mkDomain "python-docs"} = { - forceSSL = true; # addSSL = true; - enableACME = true; #useACMEHost = acmeDomain; - root = pkgs.linkFarm "python-docs" ([ - { name = "index.html"; path = pkgs.writeText "my-file" '' - - - ''; } - ] ++ (builtins.map mkLinkFarmEntry python-versions)); - }; + services.docs-to-host.docs = builtins.map mkDocsEntry python-versions; } diff --git a/profiles/web/docs/yagcd/default.nix b/profiles/web/docs/yagcd/default.nix new file mode 100644 index 0000000..2d6581d --- /dev/null +++ b/profiles/web/docs/yagcd/default.nix @@ -0,0 +1,23 @@ +{ config, pkgs, lib, mkDomain, ... }: +let + yagcd = pkgs.fetchzip { + url = "http://hitmen.c02.at/files/yagcd/yagcd.tar.gz"; + hash = "sha256-6/0oh7Xvbq1eAk2fCtKU+IXm0FbmgXIwAUjXuUKicus="; + stripRoot = false; + }; +in +{ + services.docs-to-host.docs = [{ + desc = "Yet another Gamecube Documentation"; + subdir = "yagcd"; + path = "${yagcd}/yagcd"; + }]; + + /** / + services.nginx.virtualHosts.${mkDomain "yagcd"} = { + forceSSL = true; # addSSL = true; + enableACME = true; #useACMEHost = acmeDomain; + root = yagcd; + }; + /**/ +} diff --git a/profiles/web/index/default.nix b/profiles/web/index/default.nix index e7d336c..00740de 100644 --- a/profiles/web/index/default.nix +++ b/profiles/web/index/default.nix @@ -10,6 +10,7 @@ let www = "wwwwwwwwwwwwwww"; ${config.networking.hostName} = www; shlink = "Url shortener"; + docs = "Various documentation"; }; in {