Skip to content

Commit

Permalink
docs: a generator to generate all caps files (closes unionlabs#114) (u…
Browse files Browse the repository at this point in the history
…nionlabs#126)

* feat(tools): add mdx

* chore: cleanup

* feat: add tera to tools

* ci(docgen): add check to verify docs are up to date

* feat(docs): add nix to supported languages

* fix(tera): set the name field in the tera derivation

* fix(tera): set both name and pname

* fix: remove pname and add version

* feat(docs): switch to yarn with workspace

* fix: remove unused self binding

* ci(spellcheck): add chevdor

* chore: attempt to appease ci gods

* docs: do not emit node_modules in /Users/k/union/union/docs/outputs/out

* ci(docs): unnest artifacts from build folder

* chore: run docgen
  • Loading branch information
KaiserKarel authored Jun 5, 2023
1 parent 2aaea05 commit 2c1bb1b
Show file tree
Hide file tree
Showing 17 changed files with 15,664 additions and 69 deletions.
5 changes: 5 additions & 0 deletions dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ cdctypes
cdylib
chainid
chainsafe
chevdor
clippy
clippy
clsx
Expand Down Expand Up @@ -174,6 +175,7 @@ devshell
dirchange
distrkeeper
distrtypes
docgen
doctest
dont
drawio
Expand Down Expand Up @@ -277,6 +279,7 @@ libiconv
libmuslc
libwasmvm
libwasmvmstatic
lifecycles
lightclient
lightclients
linkmode
Expand Down Expand Up @@ -441,6 +444,7 @@ teku
tempdir
tempfile
tendermint
tera
testdata
testkeeper
testkey
Expand Down Expand Up @@ -473,6 +477,7 @@ unbond
unbonded
unbonding
undelegations
unionbundle
uniond
unionfi
unionmodule
Expand Down
53 changes: 30 additions & 23 deletions docs/docs.nix
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
{ ... }: {
perSystem = { pkgs, lib, ... }:
let
npmDepsHash = "sha256-Xj8s7tNjZcbq474jitfq0sII50gy6nj9Bwrs09+9Zqc=";
npmDepsHash = "sha256-MNirXlfRS+3C9TDf80n8Mtf04a3caac38MklFcZ1HrA=";
src = ../.;
pname = "docs";
version = "0.0.1";
in
{
checks =
{
docs = pkgs.buildNpmPackage {
name = "docs";
src = ./.;
buildPhase = ''
npm run build
'';
npmDepsHash = npmDepsHash;
packages = {

docs = pkgs.mkYarnPackage rec {
inherit pname version src;
name = pname;
packageJSON = src + "/package.json";

offlineCache = pkgs.fetchYarnDeps {
yarnLock = src + "/yarn.lock";
sha256 = npmDepsHash;
};

};
nativeBuildInputs = [
pkgs.fixup_yarn_lock
];

packages = {
docs = pkgs.buildNpmPackage {
name = "docs";
src = ./.;
buildPhase = ''
npm run build
configurePhase = ''
export HOME=$NIX_BUILD_TOP
yarn config --offline set yarn-offline-mirror ${offlineCache}
fixup_yarn_lock yarn.lock
yarn install --offline --ignore-optional --frozen-lockfile --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules/
'';
npmDepsHash = npmDepsHash;

postBuild = "yarn workspace docs --offline build";

installPhase = ''
mkdir -p $out
cp -dR ./build/* $out
echo "built docs"
cp -r ./docs/build/* $out
'';

doDist = false;
};
};

Expand All @@ -40,9 +49,7 @@
name = "docs-dev-server";
runtimeInputs = [ pkgs.nodejs ];
text = ''
cd docs
npm install
npm run start
yarn workspace docs run start
'';
};
};
Expand Down
48 changes: 3 additions & 45 deletions docs/docs/validators/nixos.md → docs/docs/validators/nixos.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,10 @@ Below is an example configuration.nix which can be used in production.
The example currently uses `git+ssh://` syntax rather than `github:` syntax because our repository is not public yet. Once it is, this will be simplified. When this happens, `GIT_LFS_SKIP_SMUDGE` will also no longer be required.
:::

```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
union.url = "git+ssh://[email protected]/unionfi/union";
};
outputs = inputs@{self, nixpkgs, union,... }:
{
nixosConfigurations.testnet-validator =
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in
nixpkgs.lib.nixosSystem {
inherit system;
modules = [
union.nixosModules.unionvisor
{
system.stateVersion = "23.11";
# Base configuration for openstack-based VPSs
imports = [ "${nixpkgs}/nixos/modules/virtualisation/openstack-config.nix" ];
import Configuration from "!!raw-loader!../../../unionvisor/usage.nix";
import CodeBlock from "@theme/CodeBlock";

# Allow other validators to reach you
networking.firewall.allowedTCPPorts = [ 80 443 26656 26657 ];
# Unionvisor module configuration
services.unionvisor = {
enable = true;
moniker = "your-testnet-moniker";
};
# OPTIONAL: Some useful inspection tools for when you SSH into your validator
environment.systemPackages = with pkgs; [
bat
bottom
helix
jq
neofetch
tree
];
}
];
};
};
}
```
<CodeBlock language="nix">{Configuration}</CodeBlock>

You can then deploy the configuration by running

Expand Down
1 change: 1 addition & 0 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const config = {
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
additionalLanguages: ["nix"],
},
}),
};
Expand Down
37 changes: 37 additions & 0 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@mdx-js/react": "^1.6.22",
"clsx": "^1.2.1",
"prism-react-renderer": "^1.3.5",
"raw-loader": "^4.0.2",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
Expand Down
Loading

0 comments on commit 2c1bb1b

Please sign in to comment.