Add custom module documentation
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
			
		||||
{ lib, extendModules, modulesPath, baseModules, options, config, ... }:
 | 
			
		||||
let
 | 
			
		||||
  inherit (lib) recursiveUpdate mkOption;
 | 
			
		||||
  inherit (lib.my) mkBoolOpt;
 | 
			
		||||
  inherit (lib.my) mkBoolOpt';
 | 
			
		||||
 | 
			
		||||
  cfg = config.my.build;
 | 
			
		||||
 | 
			
		||||
@@ -18,12 +18,13 @@ let
 | 
			
		||||
in
 | 
			
		||||
{
 | 
			
		||||
  options.my = with lib.types; {
 | 
			
		||||
    boot.isDevVM = mkBoolOpt false;
 | 
			
		||||
    boot.isDevVM = mkBoolOpt' false "Whether the system is a development VM.";
 | 
			
		||||
    build = options.system.build;
 | 
			
		||||
    asDevVM = mkOption {
 | 
			
		||||
      inherit (asDevVM) type;
 | 
			
		||||
      default = { };
 | 
			
		||||
      visible = "shallow";
 | 
			
		||||
      description = "Configuration as a development VM";
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,12 @@
 | 
			
		||||
{ lib, pkgs, inputs, system, config, options, ... }:
 | 
			
		||||
let
 | 
			
		||||
  inherit (lib) mkIf mkDefault mkAliasDefinitions;
 | 
			
		||||
  inherit (lib.my) mkOpt;
 | 
			
		||||
  inherit (lib.my) mkOpt';
 | 
			
		||||
in
 | 
			
		||||
{
 | 
			
		||||
  options.my = with lib.types; {
 | 
			
		||||
    user = mkOpt (attrsOf anything) { };
 | 
			
		||||
    # Pretty hacky but too lazy to figure out if there's a better way to alias the options
 | 
			
		||||
    user = mkOpt' (attrsOf anything) { } "User definition (as `users.users.*`).";
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  config =
 | 
			
		||||
@@ -40,13 +41,15 @@ in
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
      nix = {
 | 
			
		||||
        package = inputs.nix.defaultPackage.${system};
 | 
			
		||||
        extraOptions =
 | 
			
		||||
          ''
 | 
			
		||||
            experimental-features = nix-command flakes ca-derivations
 | 
			
		||||
          '';
 | 
			
		||||
      };
 | 
			
		||||
      nixpkgs = {
 | 
			
		||||
        overlays = [
 | 
			
		||||
          inputs.nix.overlay
 | 
			
		||||
        ];
 | 
			
		||||
        config = {
 | 
			
		||||
          allowUnfree = true;
 | 
			
		||||
        };
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
{ lib, pkgs, config, ... }:
 | 
			
		||||
let
 | 
			
		||||
  inherit (lib) optionalAttrs filterAttrs genAttrs mkIf mkDefault;
 | 
			
		||||
  inherit (lib.my) mkOpt mkBoolOpt;
 | 
			
		||||
  inherit (lib.my) mkOpt' mkBoolOpt';
 | 
			
		||||
 | 
			
		||||
  cfg = config.my.dynamic-motd;
 | 
			
		||||
 | 
			
		||||
@@ -9,9 +9,9 @@ let
 | 
			
		||||
in
 | 
			
		||||
{
 | 
			
		||||
  options.my.dynamic-motd = with lib.types; {
 | 
			
		||||
    enable = mkBoolOpt true;
 | 
			
		||||
    services = mkOpt (listOf str) [ "login" "ssh" ];
 | 
			
		||||
    script = mkOpt (nullOr lines) null;
 | 
			
		||||
    enable = mkBoolOpt' true "Whether to enable the dynamic message of the day PAM module.";
 | 
			
		||||
    services = mkOpt' (listOf str) [ "login" "ssh" ] "PAM services to enable the dynamic message of the day module for.";
 | 
			
		||||
    script = mkOpt' (nullOr lines) null "Script that generates message of the day.";
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  config = mkIf (cfg.enable && cfg.script != null) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,24 +1,24 @@
 | 
			
		||||
{ lib, options, config, ... }:
 | 
			
		||||
let
 | 
			
		||||
  inherit (lib) optionalString concatStringsSep concatMapStringsSep optionalAttrs mkIf mkDefault mkMerge mkOverride;
 | 
			
		||||
  inherit (lib.my) parseIPPort mkOpt mkBoolOpt dummyOption;
 | 
			
		||||
  inherit (lib.my) parseIPPort mkOpt' mkBoolOpt' dummyOption;
 | 
			
		||||
 | 
			
		||||
  cfg = config.my.firewall;
 | 
			
		||||
in
 | 
			
		||||
{
 | 
			
		||||
  options.my.firewall = with lib.types; {
 | 
			
		||||
    enable = mkBoolOpt true;
 | 
			
		||||
    enable = mkBoolOpt' true "Whether to enable the nftables-based firewall.";
 | 
			
		||||
    trustedInterfaces = options.networking.firewall.trustedInterfaces;
 | 
			
		||||
    tcp = {
 | 
			
		||||
      allowed = mkOpt (listOf (either port str)) [ "ssh" ];
 | 
			
		||||
      allowed = mkOpt' (listOf (either port str)) [ "ssh" ] "TCP ports to open.";
 | 
			
		||||
    };
 | 
			
		||||
    udp = {
 | 
			
		||||
      allowed = mkOpt (listOf (either port str)) [ ];
 | 
			
		||||
      allowed = mkOpt' (listOf (either port str)) [ ] "UDP ports to open.";
 | 
			
		||||
    };
 | 
			
		||||
    extraRules = mkOpt lines "";
 | 
			
		||||
    extraRules = mkOpt' lines "" "Arbitrary additional nftables rules.";
 | 
			
		||||
 | 
			
		||||
    nat = with options.networking.nat; {
 | 
			
		||||
      enable = mkBoolOpt true;
 | 
			
		||||
      enable = mkBoolOpt' true "Whether to enable IP forwarding and NAT.";
 | 
			
		||||
      inherit externalInterface forwardPorts;
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,13 @@
 | 
			
		||||
{ config, lib, ... }:
 | 
			
		||||
let
 | 
			
		||||
  inherit (lib) mkIf;
 | 
			
		||||
  inherit (lib.my) mkBoolOpt;
 | 
			
		||||
  inherit (lib.my) mkBoolOpt';
 | 
			
		||||
 | 
			
		||||
  cfg = config.my.server;
 | 
			
		||||
in
 | 
			
		||||
{
 | 
			
		||||
  options.my.server.enable = mkBoolOpt false;
 | 
			
		||||
  config = mkIf config.my.server.enable {
 | 
			
		||||
  options.my.server.enable = mkBoolOpt' false "Whether to enable common configuration for servers.";
 | 
			
		||||
  config = mkIf cfg.enable {
 | 
			
		||||
    services.getty.autologinUser = config.my.user.name;
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,7 @@
 | 
			
		||||
{ lib, pkgs, inputs, config, ... }:
 | 
			
		||||
{ lib, pkgs, config, ... }:
 | 
			
		||||
let
 | 
			
		||||
  inherit (builtins) elem;
 | 
			
		||||
  inherit (lib) concatStringsSep concatMap concatMapStringsSep mkIf mkDefault mkMerge mkForce mkVMOverride;
 | 
			
		||||
  inherit (lib.my) mkOpt mkBoolOpt mkVMOverride' dummyOption;
 | 
			
		||||
  inherit (lib) concatStringsSep concatMap concatMapStringsSep mkIf mkDefault mkMerge mkVMOverride;
 | 
			
		||||
  inherit (lib.my) mkOpt' mkBoolOpt' mkVMOverride' dummyOption;
 | 
			
		||||
 | 
			
		||||
  cfg = config.my.tmproot;
 | 
			
		||||
 | 
			
		||||
@@ -54,16 +53,14 @@ let
 | 
			
		||||
  };
 | 
			
		||||
in
 | 
			
		||||
{
 | 
			
		||||
  imports = [ inputs.impermanence.nixosModule ];
 | 
			
		||||
 | 
			
		||||
  options = with lib.types; {
 | 
			
		||||
    my.tmproot = {
 | 
			
		||||
      enable = mkBoolOpt true;
 | 
			
		||||
      persistDir = mkOpt str "/persist";
 | 
			
		||||
      size = mkOpt str "2G";
 | 
			
		||||
      enable = mkBoolOpt' true "Whether to enable tmproot.";
 | 
			
		||||
      persistDir = mkOpt' str "/persist" "Path where persisted files are stored.";
 | 
			
		||||
      size = mkOpt' str "2G" "Size of tmpfs root";
 | 
			
		||||
      unsaved = {
 | 
			
		||||
        showMotd = mkBoolOpt true;
 | 
			
		||||
        ignore = mkOpt (listOf str) [ ];
 | 
			
		||||
        showMotd = mkBoolOpt' true "Whether to show unsaved files with `dynamic-motd`.";
 | 
			
		||||
        ignore = mkOpt' (listOf str) [ ] "Path prefixes to ignore if unsaved.";
 | 
			
		||||
      };
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user