mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-21 21:37:56 -04:00
feat(nix): generate module options docs and sync to website
- Add nix/generate-hm-options.nix to export HM and NixOS module options as JSON via nixosOptionsDoc - Expose hm-options-json and nixos-options-json packages in flake.nix - Add CI workflow to auto-build and push JSONs to mangowm.github.io on module changes - Add missing description to hm-modules enable option
This commit is contained in:
parent
129d3da44e
commit
0a687f808d
5 changed files with 97 additions and 0 deletions
59
.github/workflows/sync-nix-options.yml
vendored
Normal file
59
.github/workflows/sync-nix-options.yml
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
name: Sync Nix module options
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
paths:
|
||||||
|
- nix/hm-modules.nix
|
||||||
|
- nix/nixos-modules.nix
|
||||||
|
- nix/generate-options.nix
|
||||||
|
- flake.nix
|
||||||
|
- flake.lock
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: sync-nix-options
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync-nix-options:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- uses: cachix/install-nix-action@v30
|
||||||
|
with:
|
||||||
|
extra_nix_config: |
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
|
||||||
|
- name: Build options JSONs
|
||||||
|
run: |
|
||||||
|
HM_OUT=$(nix build .#hm-options-json --no-link --print-out-paths)
|
||||||
|
NIXOS_OUT=$(nix build .#nixos-options-json --no-link --print-out-paths)
|
||||||
|
cp "$HM_OUT/share/doc/nixos/options.json" /tmp/hm-options.json
|
||||||
|
cp "$NIXOS_OUT/share/doc/nixos/options.json" /tmp/nixos-options.json
|
||||||
|
|
||||||
|
- name: Checkout website
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: mangowm/mangowm.github.io
|
||||||
|
path: website
|
||||||
|
token: ${{ secrets.WEBSITE_SYNC_TOKEN }}
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Copy JSONs to website
|
||||||
|
run: |
|
||||||
|
cp /tmp/hm-options.json website/apps/web/src/hm-options.json
|
||||||
|
cp /tmp/nixos-options.json website/apps/web/src/nixos-options.json
|
||||||
|
|
||||||
|
- name: Commit and push
|
||||||
|
working-directory: website
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git add apps/web/src/hm-options.json apps/web/src/nixos-options.json
|
||||||
|
git diff --staged --quiet || git commit \
|
||||||
|
-m "nix: update module options JSON" \
|
||||||
|
-m "${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}"
|
||||||
|
git push
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,6 +1,7 @@
|
||||||
/.cache
|
/.cache
|
||||||
/.vscode
|
/.vscode
|
||||||
/result
|
/result
|
||||||
|
/result-*
|
||||||
config.h
|
config.h
|
||||||
mango
|
mango
|
||||||
mango.o
|
mango.o
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,14 @@
|
||||||
};
|
};
|
||||||
packages = {
|
packages = {
|
||||||
inherit mango;
|
inherit mango;
|
||||||
|
hm-options-json = pkgs.callPackage (import ./nix/generate-options.nix self) {
|
||||||
|
module = ./nix/hm-modules.nix;
|
||||||
|
optionPrefix = "wayland.windowManager.mango.";
|
||||||
|
};
|
||||||
|
nixos-options-json = pkgs.callPackage (import ./nix/generate-options.nix self) {
|
||||||
|
module = ./nix/nixos-modules.nix;
|
||||||
|
optionPrefix = "programs.mango.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
devShells.default = mango.overrideAttrs shellOverride;
|
devShells.default = mango.overrideAttrs shellOverride;
|
||||||
formatter = pkgs.alejandra;
|
formatter = pkgs.alejandra;
|
||||||
|
|
|
||||||
28
nix/generate-options.nix
Normal file
28
nix/generate-options.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
self:
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
lib ? pkgs.lib,
|
||||||
|
module,
|
||||||
|
optionPrefix,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
eval = lib.evalModules {
|
||||||
|
modules = [
|
||||||
|
(import module self)
|
||||||
|
{ _module.check = false; }
|
||||||
|
];
|
||||||
|
specialArgs = { inherit pkgs; };
|
||||||
|
};
|
||||||
|
|
||||||
|
optionsDoc = pkgs.nixosOptionsDoc {
|
||||||
|
options = eval.options;
|
||||||
|
transformOptions =
|
||||||
|
opt:
|
||||||
|
opt
|
||||||
|
// {
|
||||||
|
visible = opt.visible && !opt.internal;
|
||||||
|
name = lib.removePrefix optionPrefix opt.name;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
optionsDoc.optionsJSON
|
||||||
|
|
@ -22,6 +22,7 @@ in
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
description = "Whether to enable mangowm, a Wayland compositor based on dwl.";
|
||||||
};
|
};
|
||||||
package = lib.mkOption {
|
package = lib.mkOption {
|
||||||
type = lib.types.package;
|
type = lib.types.package;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue