diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..2ab3e7d --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,43 @@ +name: Deploy Documentation + +on: + push: + branches: [main] + paths: + - ./.github/workflows/deploy.yaml # this workflow + - ./docs/** # Docs generation code + - ./options.nix # module options + # Nix files + - flake.lock + - flake.nix + +jobs: + build-website: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: DeterminateSystems/nix-installer-action@v9 + - uses: DeterminateSystems/magic-nix-cache-action@v2 + - name: Build documentation + run: nix build .#docs --print-build-logs + - name: Adjust permissions + run: | + chown -R "$(id -u):$(id -g)" ./result + chmod -R a+rwx ./result + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: ./result + deploy: + needs: build + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..7585238 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +book diff --git a/docs/book.toml b/docs/book.toml new file mode 100644 index 0000000..7e97869 --- /dev/null +++ b/docs/book.toml @@ -0,0 +1,6 @@ +[book] +authors = ["Jalil David Salamé Messina"] +language = "en" +multilingual = false +src = "src" +title = "Jalil's NixOS configuration module" diff --git a/docs/default.nix b/docs/default.nix new file mode 100644 index 0000000..5b3b0bd --- /dev/null +++ b/docs/default.nix @@ -0,0 +1,16 @@ +{ pkgs, lib, ... }: +let + eval = lib.evalModules { modules = [ ../options.nix ]; }; + doc = (pkgs.nixosOptionsDoc { inherit (eval) options; }).optionsCommonMark; +in +pkgs.stdenvNoCC.mkDerivation { + name = "nixos-configuration-book"; + src = ./.; + + patchPhase = '' + # copy generated options removing the declared by statement + sed '/^\*Declared by:\*$/,/^$/d' <${doc} >> src/options.md + ''; + + buildPhase = "${pkgs.mdbook}/bin/mdbook build --dest-dir $out"; +} diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md new file mode 100644 index 0000000..4a96554 --- /dev/null +++ b/docs/src/SUMMARY.md @@ -0,0 +1,3 @@ +# Summary + +- [Module Options](./options.md) diff --git a/docs/src/options.md b/docs/src/options.md new file mode 100644 index 0000000..e809c5f --- /dev/null +++ b/docs/src/options.md @@ -0,0 +1,3 @@ +# Module Options + +Here you will find the module options and their default values (if they have any). diff --git a/flake.nix b/flake.nix index 1677ccf..c5ae810 100644 --- a/flake.nix +++ b/flake.nix @@ -15,22 +15,25 @@ # Flake outputs that other flakes can use outputs = { flake-schemas, nixpkgs, stylix, ... }: let + inherit (nixpkgs) lib; # Helpers for producing system-specific outputs supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; - forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { - pkgs = import nixpkgs { inherit system; }; - }); + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { pkgs = import nixpkgs { inherit system; }; }); + # Module documentation + doc = forEachSupportedSystem ({ pkgs }: { doc = import ./docs { inherit pkgs lib; }; }); in { # Schemas tell Nix about the structure of your flake's outputs schemas = flake-schemas.schemas; + packages = doc; + # Nix files formatter (run `nix fmt`) formatter = forEachSupportedSystem ({ pkgs }: pkgs.nixpkgs-fmt); nixosModules = rec { default = nixosModule; - nixosModule = import ./configuration { inherit stylix; }; + nixosModule = import ./module { inherit stylix; }; }; }; } diff --git a/configuration/default.nix b/module/default.nix similarity index 53% rename from configuration/default.nix rename to module/default.nix index a530414..f0254fa 100644 --- a/configuration/default.nix +++ b/module/default.nix @@ -1,46 +1,11 @@ { stylix }: { config, pkgs, lib, ... }: let - inherit (lib) types; cfg = config.jconfig; - mkDisableOption = option: lib.mkOption { - description = lib.mdDoc "Whether to enable ${option}."; - type = types.bool; - default = true; - example = false; - }; in { - imports = [ ./gui ] ++ lib.optional (cfg.enable && cfg.styling.enable) stylix.homeManagerModules.stylix; + imports = [ ./gui ] ++ lib.optional (cfg.enable && cfg.styling.enable) stylix.nixosModules.stylix; - options.jconfig = lib.mkOption { - description = lib.mdDoc "Jalil's default NixOS configuration."; - type = types.submodule { - options.enable = lib.mkEnableOption "jalil's default configuration."; - options.styling = lib.mkOption { - description = "Jalil's styling options"; - type = types.submodule { - options.enable = mkDisableOption "jalil's default styling"; - options.wallpaper = lib.mkOption { - description = "The wallpaper to use."; - type = types.str; - default = builtins.fetchurl { - url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png"; - sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc"; - }; - }; - options.bootLogo = lib.mkOption { - description = "The logo used by plymouth at boot."; - type = types.str; - # http://xenia-linux-site.glitch.me/images/cathodegaytube-splash.png - default = builtins.fetchurl { - url = "https://efimero.github.io/xenia-images/cathodegaytube-splash.png"; - sha256 = "qKugUfdRNvMwSNah+YmMepY3Nj6mWlKFh7jlGlAQDo8="; - }; - }; - }; - }; - }; - }; + options = import ../options.nix; config = lib.optionalAttrs cfg.enable { boot.plymouth.enable = cfg.styling.enable; diff --git a/configuration/gui/default.nix b/module/gui/default.nix similarity index 70% rename from configuration/gui/default.nix rename to module/gui/default.nix index e66af52..d00c5d9 100644 --- a/configuration/gui/default.nix +++ b/module/gui/default.nix @@ -1,37 +1,9 @@ { config, lib, pkgs, ... }: let - inherit (lib) types; cfg = config.jconfig.gui; - enable = config.jconfig.enable && cfg.enable; - # Like lib.mkEnableOption but default to true - mkDisableOption = option: lib.mkOption { - description = lib.mdDoc "Whether to enable ${option}."; - type = types.bool; - default = true; - example = false; - }; in { - options.jhome.gui = lib.mkOption { - description = lib.mdDoc "Jalil's default configuration for a NixOS gui."; - type = types.submodule { - options.enable = lib.mkEnableOption "jalil's default gui configuration."; - # Fix for using Xinput mode on 8bitdo Ultimate C controller - # Inspired by https://aur.archlinux.org/packages/8bitdo-ultimate-controller-udev - # Adapted from: https://gist.github.com/interdependence/28452fbfbe692986934fbe1e54c920d4 - options."8bitdoFix" = mkDisableOption "a fix for 8bitdo controllers"; - options.steamHardwareSupport = mkDisableOption "steam hardware support"; - options.ydotool = lib.mkOption { - description = lib.mdDoc "Jalil's default ydotool configuration."; - type = types.submodule { - options.enable = mkDisableOption "ydotool"; - options.autoStart = mkDisableOption "autostarting ydotool at login"; - }; - }; - }; - }; - - config = lib.optionalAttrs enable + config = lib.optionalAttrs (config.jconfig.enable && cfg.enable) { environment.systemPackages = [ pkgs.gnome.adwaita-icon-theme diff --git a/configuration/stylix-config.nix b/module/stylix-config.nix similarity index 100% rename from configuration/stylix-config.nix rename to module/stylix-config.nix diff --git a/options.nix b/options.nix new file mode 100644 index 0000000..7b9f58c --- /dev/null +++ b/options.nix @@ -0,0 +1,62 @@ +{ lib, ... }: +let + inherit (lib) types; + # Like mkEnableOption but defaults to true + mkDisableOption = option: lib.mkOption { + description = lib.mdDoc "Whether to enable ${option}."; + type = types.bool; + default = true; + example = false; + }; +in +{ + options.jconfig = lib.mkOption { + description = lib.mdDoc "Jalil's default NixOS configuration."; + type = types.submodule { + options = { + enable = lib.mkEnableOption "jalil's default configuration."; + gui = lib.mkOption { + description = lib.mdDoc "Jalil's default configuration for a NixOS gui."; + type = types.submodule { + options.enable = lib.mkEnableOption "jalil's default gui configuration."; + # Fix for using Xinput mode on 8bitdo Ultimate C controller + # Inspired by https://aur.archlinux.org/packages/8bitdo-ultimate-controller-udev + # Adapted from: https://gist.github.com/interdependence/28452fbfbe692986934fbe1e54c920d4 + options."8bitdoFix" = mkDisableOption "a fix for 8bitdo controllers"; + options.steamHardwareSupport = mkDisableOption "steam hardware support"; + options.ydotool = lib.mkOption { + description = lib.mdDoc "Jalil's default ydotool configuration."; + type = types.submodule { + options.enable = mkDisableOption "ydotool"; + options.autoStart = mkDisableOption "autostarting ydotool at login"; + }; + }; + }; + }; + styling = lib.mkOption { + description = "Jalil's styling options"; + type = types.submodule { + options.enable = mkDisableOption "jalil's default styling"; + options.wallpaper = lib.mkOption { + description = "The wallpaper to use."; + type = types.str; + default = builtins.fetchurl { + url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png"; + sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc"; + }; + }; + options.bootLogo = lib.mkOption { + description = "The logo used by plymouth at boot."; + type = types.str; + # http://xenia-linux-site.glitch.me/images/cathodegaytube-splash.png + default = builtins.fetchurl { + url = "https://efimero.github.io/xenia-images/cathodegaytube-splash.png"; + sha256 = "qKugUfdRNvMwSNah+YmMepY3Nj6mWlKFh7jlGlAQDo8="; + }; + }; + }; + }; + }; + }; + }; +}