diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..fc5ac254 --- /dev/null +++ b/.github/workflows/docs.yml @@ -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 diff --git a/docs/default.nix b/docs/default.nix new file mode 100644 index 00000000..687e222a --- /dev/null +++ b/docs/default.nix @@ -0,0 +1,68 @@ +{ pkgs, pkgsLib, coricamuLib, config, inputs, ... }: + +{ + baseUrl = "https://danth.github.io/stylix/"; + siteTitle = "Stylix"; + language = "en-gb"; + + header.html = '' +

Stylix

+ + ''; + + 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; + }; +} diff --git a/flake.lock b/flake.lock index b42de92d..ef2a7999 100644 --- a/flake.lock +++ b/flake.lock @@ -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", diff --git a/flake.nix b/flake.nix index e79ea806..7261b479 100644 --- a/flake.nix +++ b/flake.nix @@ -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; - }; } ); diff --git a/stylix/palette.nix b/stylix/palette.nix index b72f9d4e..124a765a 100644 --- a/stylix/palette.nix +++ b/stylix/palette.nix @@ -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 stylix.palette. Those are automatically selected from the background image by default, diff --git a/stylix/target.nix b/stylix/target.nix index 7b63c3ec..db515c22 100644 --- a/stylix/target.nix +++ b/stylix/target.nix @@ -25,7 +25,7 @@ with lib; mkOption { description = "Whether to style ${humanName}."; type = types.bool; - defaultText = '' + defaultText = literalDocBook '' When stylix.autoEnable is true: Enabled when ${humanName} is installed.