-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move docs generation out of main flake
I do this to prevent every user to have to pull the nuschtos input
- Loading branch information
Showing
7 changed files
with
265 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,44 @@ | ||
{ | ||
pkgs, | ||
lib ? pkgs.lib, | ||
kubenix, | ||
mkSearch, | ||
}: let | ||
optionsMd = import ./build-options-doc.nix {inherit pkgs lib;}; | ||
|
||
buildSearch = import ./build-options-search.nix { | ||
inherit pkgs lib kubenix mkSearch; | ||
}; | ||
|
||
libraryMd = import ./build-library-doc.nix {inherit pkgs lib;}; | ||
|
||
docsHtml = pkgs.stdenv.mkDerivation { | ||
inherit optionsMd; | ||
|
||
passAsFile = ["optionsMd"]; | ||
|
||
name = "nixidy-html-docs"; | ||
|
||
src = lib.cleanSource ./..; | ||
|
||
buildInputs = with pkgs.python3.pkgs; [mkdocs-material mkdocs-material-extensions]; | ||
|
||
phases = ["unpackPhase" "patchPhase" "buildPhase"]; | ||
|
||
patchPhase = '' | ||
cat $optionsMdPath > docs/options.md | ||
cp ${libraryMd}/lib.md docs/library.md | ||
cp ${../README.md} docs/index.md | ||
cat <<EOF > mkdocs.yml | ||
site_name: nixidy | ||
site_url: https://arnarg.github.io/nixidy/ | ||
site_dir: $out | ||
repo_url: https://github.com/arnarg/nixidy/ | ||
exclude_docs: | | ||
*.nix | ||
theme: | ||
name: material | ||
palette: | ||
- media: "(prefers-color-scheme: light)" | ||
scheme: default | ||
toggle: | ||
icon: material/brightness-7 | ||
name: Switch to dark mode | ||
- media: "(prefers-color-scheme: dark)" | ||
scheme: slate | ||
toggle: | ||
icon: material/brightness-4 | ||
name: Switch to light mode | ||
features: | ||
- navigation.footer | ||
- content.tabs.link | ||
markdown_extensions: | ||
- def_list | ||
- toc: | ||
permalink: "#" | ||
toc_depth: 3 | ||
- admonition | ||
- pymdownx.highlight | ||
- pymdownx.inlinehilite | ||
- pymdownx.superfences | ||
- pymdownx.tabbed: | ||
alternate_style: true | ||
nav: | ||
- Home: index.md | ||
- 'User Guide': | ||
- 'Getting Started': user_guide/getting_started.md | ||
- 'Using Helm Charts': user_guide/helm_charts.md | ||
- 'Typed Resource Options': user_guide/typed_resources.md | ||
- 'GitHub Actions': user_guide/github_actions.md | ||
- 'Transformers': user_guide/transformers.md | ||
- 'Using nixhelm': user_guide/using_nixhelm.md | ||
- Reference: | ||
- 'Library Functions': library.md | ||
- 'Configuration Options': options.md | ||
EOF | ||
''; | ||
|
||
buildPhase = '' | ||
mkdir -p $out | ||
python -m mkdocs build | ||
cp -r ${buildSearch "/nixidy/options/search/"} $out/options/search | ||
''; | ||
let | ||
# Get some sources from npins. | ||
sources = import ./npins; | ||
pkgs = import sources.nixpkgs {}; | ||
|
||
# Some inputs from the root flake need | ||
# be available to the docs generation. | ||
# To make sure they are the same version | ||
# as is used by the flake I read the flake.lock | ||
# and fetch them below. | ||
flakeLock = builtins.fromJSON (builtins.readFile ../flake.lock); | ||
kubenix = let | ||
lock = flakeLock.nodes.kubenix.locked; | ||
in | ||
pkgs.fetchFromGitHub { | ||
inherit (lock) owner repo rev; | ||
hash = lock.narHash; | ||
}; | ||
kubelib = let | ||
lock = flakeLock.nodes.nix-kube-generators.locked; | ||
in | ||
pkgs.fetchFromGitHub { | ||
inherit (lock) owner repo rev; | ||
hash = lock.narHash; | ||
}; | ||
|
||
# Setup nuschtos without using a flake. | ||
nuschtos = sources.search; | ||
ixx = sources.ixx; | ||
ixxPkgs = { | ||
ixx = pkgs.callPackage "${ixx}/ixx/derivation.nix" {}; | ||
fixx = pkgs.callPackage "${ixx}/fixx/derivation.nix" {}; | ||
libixx = pkgs.callPackage "${ixx}/libixx/derivation.nix" {}; | ||
}; | ||
in { | ||
html = docsHtml; | ||
search = buildSearch "/"; | ||
} | ||
nuscht-search = pkgs.callPackage "${nuschtos}/nix/frontend.nix" {}; | ||
mkSearch = (pkgs.callPackage "${nuschtos}/nix/wrapper.nix" {inherit nuscht-search ixxPkgs;}).mkSearch; | ||
in | ||
# Build docs! | ||
import ./docs.nix { | ||
inherit pkgs kubenix mkSearch; | ||
lib = import ../lib { | ||
inherit pkgs kubelib; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
{ | ||
pkgs, | ||
lib ? pkgs.lib, | ||
kubenix, | ||
mkSearch, | ||
}: let | ||
optionsMd = import ./build-options-doc.nix {inherit pkgs lib;}; | ||
|
||
buildSearch = import ./build-options-search.nix { | ||
inherit pkgs lib kubenix mkSearch; | ||
}; | ||
|
||
libraryMd = import ./build-library-doc.nix {inherit pkgs lib;}; | ||
|
||
docsHtml = pkgs.stdenv.mkDerivation { | ||
inherit optionsMd; | ||
|
||
passAsFile = ["optionsMd"]; | ||
|
||
name = "nixidy-html-docs"; | ||
|
||
src = lib.cleanSource ./..; | ||
|
||
buildInputs = with pkgs.python3.pkgs; [mkdocs-material mkdocs-material-extensions]; | ||
|
||
phases = ["unpackPhase" "patchPhase" "buildPhase"]; | ||
|
||
patchPhase = '' | ||
cat $optionsMdPath > docs/options.md | ||
cp ${libraryMd}/lib.md docs/library.md | ||
cp ${../README.md} docs/index.md | ||
cat <<EOF > mkdocs.yml | ||
site_name: nixidy | ||
site_url: https://arnarg.github.io/nixidy/ | ||
site_dir: $out | ||
repo_url: https://github.com/arnarg/nixidy/ | ||
exclude_docs: | | ||
*.nix | ||
/npins/ | ||
theme: | ||
name: material | ||
palette: | ||
- media: "(prefers-color-scheme: light)" | ||
scheme: default | ||
toggle: | ||
icon: material/brightness-7 | ||
name: Switch to dark mode | ||
- media: "(prefers-color-scheme: dark)" | ||
scheme: slate | ||
toggle: | ||
icon: material/brightness-4 | ||
name: Switch to light mode | ||
features: | ||
- navigation.footer | ||
- content.tabs.link | ||
markdown_extensions: | ||
- def_list | ||
- toc: | ||
permalink: "#" | ||
toc_depth: 3 | ||
- admonition | ||
- pymdownx.highlight | ||
- pymdownx.inlinehilite | ||
- pymdownx.superfences | ||
- pymdownx.tabbed: | ||
alternate_style: true | ||
nav: | ||
- Home: index.md | ||
- 'User Guide': | ||
- 'Getting Started': user_guide/getting_started.md | ||
- 'Using Helm Charts': user_guide/helm_charts.md | ||
- 'Typed Resource Options': user_guide/typed_resources.md | ||
- 'GitHub Actions': user_guide/github_actions.md | ||
- 'Transformers': user_guide/transformers.md | ||
- 'Using nixhelm': user_guide/using_nixhelm.md | ||
- Reference: | ||
- 'Library Functions': library.md | ||
- 'Configuration Options': options.md | ||
EOF | ||
''; | ||
|
||
buildPhase = '' | ||
mkdir -p $out | ||
python -m mkdocs build | ||
cp -r ${buildSearch "/nixidy/options/search/"} $out/options/search | ||
''; | ||
}; | ||
in { | ||
html = docsHtml; | ||
search = buildSearch "/"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Generated by npins. Do not modify; will be overwritten regularly | ||
let | ||
data = builtins.fromJSON (builtins.readFile ./sources.json); | ||
version = data.version; | ||
|
||
mkSource = | ||
spec: | ||
assert spec ? type; | ||
let | ||
path = | ||
if spec.type == "Git" then | ||
mkGitSource spec | ||
else if spec.type == "GitRelease" then | ||
mkGitSource spec | ||
else if spec.type == "PyPi" then | ||
mkPyPiSource spec | ||
else if spec.type == "Channel" then | ||
mkChannelSource spec | ||
else | ||
builtins.throw "Unknown source type ${spec.type}"; | ||
in | ||
spec // { outPath = path; }; | ||
|
||
mkGitSource = | ||
{ | ||
repository, | ||
revision, | ||
url ? null, | ||
hash, | ||
branch ? null, | ||
... | ||
}: | ||
assert repository ? type; | ||
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository | ||
# In the latter case, there we will always be an url to the tarball | ||
if url != null then | ||
(builtins.fetchTarball { | ||
inherit url; | ||
sha256 = hash; # FIXME: check nix version & use SRI hashes | ||
}) | ||
else | ||
assert repository.type == "Git"; | ||
let | ||
urlToName = | ||
url: rev: | ||
let | ||
matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url; | ||
|
||
short = builtins.substring 0 7 rev; | ||
|
||
appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else ""; | ||
in | ||
"${if matched == null then "source" else builtins.head matched}${appendShort}"; | ||
name = urlToName repository.url revision; | ||
in | ||
builtins.fetchGit { | ||
url = repository.url; | ||
rev = revision; | ||
inherit name; | ||
# hash = hash; | ||
}; | ||
|
||
mkPyPiSource = | ||
{ url, hash, ... }: | ||
builtins.fetchurl { | ||
inherit url; | ||
sha256 = hash; | ||
}; | ||
|
||
mkChannelSource = | ||
{ url, hash, ... }: | ||
builtins.fetchTarball { | ||
inherit url; | ||
sha256 = hash; | ||
}; | ||
in | ||
if version == 3 then | ||
builtins.mapAttrs (_: mkSource) data.pins | ||
else | ||
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"pins": { | ||
"ixx": { | ||
"type": "GitRelease", | ||
"repository": { | ||
"type": "GitHub", | ||
"owner": "nuschtos", | ||
"repo": "ixx" | ||
}, | ||
"pre_releases": false, | ||
"version_upper_bound": null, | ||
"release_prefix": null, | ||
"version": "v0.0.5", | ||
"revision": "65c207c92befec93e22086da9456d3906a4e999c", | ||
"url": "https://api.github.com/repos/nuschtos/ixx/tarball/v0.0.5", | ||
"hash": "1sraly2kpi6jj0c4lcjpp6fj42rg1j5bv0hi225sndz6yhp8kk31" | ||
}, | ||
"nixpkgs": { | ||
"type": "Channel", | ||
"name": "nixpkgs-unstable", | ||
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-24.11pre697431.86e78d3d2084/nixexprs.tar.xz", | ||
"hash": "0wbmh3jc25xan6x6nndfidgkfigip49zqp0rivi6lsdv18sx9mvx" | ||
}, | ||
"search": { | ||
"type": "Git", | ||
"repository": { | ||
"type": "GitHub", | ||
"owner": "nuschtos", | ||
"repo": "search" | ||
}, | ||
"branch": "main", | ||
"revision": "e373332c1f8237fc1263901745b0fe747228c8ba", | ||
"url": "https://github.com/nuschtos/search/archive/e373332c1f8237fc1263901745b0fe747228c8ba.tar.gz", | ||
"hash": "02vqpp8k3aisnv34301lrcb0129kgnklpy6xf2bb94p1bpv9bg0d" | ||
} | ||
}, | ||
"version": 3 | ||
} |
Oops, something went wrong.