Publish list of NixOS options on GitHub Pages 📝

This commit is contained in:
Daniel Thwaites 2022-07-30 15:30:57 +01:00
parent 159048c15d
commit 0ea346a423
No known key found for this signature in database
GPG key ID: D8AFC4BF05670F9D
6 changed files with 182 additions and 19 deletions

14
.github/workflows/docs.yml vendored Normal file
View file

@ -0,0 +1,14 @@
name: Docs
on:
pull_request:
push:
branches:
- master
jobs:
pages:
name: Pages
uses: danth/coricamu/.github/workflows/pages.yml@755231f9591dd34d3d12fd508e76157f3edb7a89
with:
output_name: docs

68
docs/default.nix Normal file
View file

@ -0,0 +1,68 @@
{ pkgs, pkgsLib, coricamuLib, config, inputs, ... }:
{
baseUrl = "https://danth.github.io/stylix/";
siteTitle = "Stylix";
language = "en-gb";
header.html = ''
<h1>Stylix</h1>
<nav>
<a href="">Home</a>
<a href="options.html">Options list</a>
<a href="haddock/doc-index.html">Haskell internals</a>
<a href="https://github.com/danth/stylix">GitHub repository</a>
</nav>
'';
pages = [
{
path = "index.html";
title = "Stylix";
body.markdownFile = pkgs.runCommand "index.md" {} ''
# Remove the title line
tail -n+2 ${../README.md} >$out
'';
}
{
path = "options.html";
title = "NixOS Options";
body.docbook =
let
nixosSystem = pkgsLib.nixosSystem {
inherit (pkgs) system;
modules = [
inputs.home-manager.nixosModules.home-manager
inputs.self.nixosModules.stylix
];
};
in
coricamuLib.makeOptionsDocBook {
inherit (nixosSystem) options;
customFilter = option: pkgsLib.hasPrefix "stylix" option.name;
};
}
];
files.haddock =
let
ghc = pkgs.haskellPackages.ghcWithPackages
(ps: with ps; [ json JuicyPixels random ]);
in
pkgs.stdenvNoCC.mkDerivation {
name = "palette-generator-haddock";
src = ../palette-generator;
buildInputs = [ ghc ];
buildPhase = ''
haddock $src/**/*.hs \
--html \
--ignore-all-exports \
--use-contents '${config.baseUrl}' \
--odir $out
'';
dontInstall = true;
dontFixup = true;
};
}

80
flake.lock generated
View file

@ -20,13 +20,55 @@
"type": "github"
}
},
"coricamu": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"utils": "utils"
},
"locked": {
"lastModified": 1659186532,
"narHash": "sha256-CBezDi78i4PEGwks1XsHMIaHpi1G8d8oNlyQc/eMQbM=",
"owner": "danth",
"repo": "coricamu",
"rev": "755231f9591dd34d3d12fd508e76157f3edb7a89",
"type": "github"
},
"original": {
"owner": "danth",
"repo": "coricamu",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"utils": "utils_2"
},
"locked": {
"lastModified": 1658924727,
"narHash": "sha256-Fhh9FK9CvuCLxG1WkWJPoendDeXKI4gHYTfezo1n2Zg=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "0e2f7876d2f2ae98a67d89a8bef8c49332aae5af",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1633422745,
"narHash": "sha256-gA6Ok64nPbkjHk3Oanq4641EeYkjcKhisDF9wBjLxEk=",
"lastModified": 1659102345,
"narHash": "sha256-Vbzlz254EMZvn28BhpN8JOi5EuKqnHZ3ujFYgFcSGvk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8e1eab9eae4278c9bb1dcae426848a581943db5a",
"rev": "11b60e4f80d87794a2a4a8a256391b37c59a1ea7",
"type": "github"
},
"original": {
@ -39,8 +81,40 @@
"root": {
"inputs": {
"base16": "base16",
"coricamu": "coricamu",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
},
"utils": {
"locked": {
"lastModified": 1642700792,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"utils_2": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",

View file

@ -5,12 +5,30 @@
url = "github:SenchoPens/base16.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Used for documentation
coricamu = {
url = "github:danth/coricamu";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ nixpkgs, base16, self, ... }:
{ nixpkgs, base16, coricamu, self, ... }@inputs:
with nixpkgs.lib;
{
let
docsOutputs = coricamu.lib.generateFlakeOutputs {
outputName = "docs";
modules = [ ./docs/default.nix ];
specialArgs = { inherit inputs; };
};
in recursiveUpdate docsOutputs {
packages = genAttrs [ "aarch64-linux" "i686-linux" "x86_64-linux" ] (
system:
let
@ -32,17 +50,6 @@
install -D Stylix/Main $out/bin/palette-generator
'';
};
palette-generator-haddock = pkgs.stdenvNoCC.mkDerivation {
name = "palette-generator-haddock";
src = ./palette-generator;
buildInputs = [ ghc ];
buildPhase = ''
haddock $src/**/*.hs --html --ignore-all-exports --odir $out
'';
dontInstall = true;
dontFixup = true;
};
}
);

View file

@ -53,7 +53,7 @@ in {
'';
type = types.strMatching "[0-9a-fA-F]{6}";
default = generatedPalette.${base};
defaultText = "Automatically selected from the background image.";
defaultText = literalDocBook "Automatically selected from the background image.";
});
base16Scheme = mkOption {
@ -68,7 +68,7 @@ in {
scheme = "Stylix";
slug = "stylix";
};
defaultText = ''
defaultText = literalDocBook ''
The colors defined in <literal>stylix.palette</literal>.
Those are automatically selected from the background image by default,

View file

@ -25,7 +25,7 @@ with lib;
mkOption {
description = "Whether to style ${humanName}.";
type = types.bool;
defaultText = ''
defaultText = literalDocBook ''
When <literal>stylix.autoEnable</literal> is <literal>true</literal>:
Enabled when ${humanName} is installed.