Split documentation into each file

This commit is contained in:
DashieTM 2024-08-28 22:04:46 +02:00
parent dfc4b5cf94
commit 4cd9e462d8
16 changed files with 205 additions and 187 deletions

View file

@ -1,32 +1,41 @@
# with friendly help by stylix: https://github.com/danth/stylix/blob/master/docs/default.nix # with friendly help by stylix: https://github.com/danth/stylix/blob/master/docs/default.nix
{ pkgs, build_systems, ... }: {
pkgs,
build_systems,
lib,
...
}:
let let
makeOptionsDoc = makeOptionsDoc = configuration: pkgs.nixosOptionsDoc { options = configuration; };
configuration: generateDocs = obj: ''
pkgs.nixosOptionsDoc { touch src/${obj.fst}.md
inherit (configuration) options; sed '/*Declared by:*/,/^$/d' <${obj.snd.optionsCommonMark} >> src/${obj.fst}.md
'';
# Filter out any options not beginning with `stylix` summaryAppend = name: ''
transformOptions = echo "- [${name}](${name}.md)" >> src/SUMMARY.md
option: '';
option system = (build_systems [ "example" ] ../example/.)."example".options;
// { makeOptionsDocPrograms = name: pkgs.nixosOptionsDoc { options = system.mods.${name}; };
visible = conf = makeOptionsDoc system.conf;
builtins.elemAt option.loc 0 != "kernel" paths = builtins.readDir ../modules/programs;
&& option.visible names = lib.lists.remove "default" (
&& (builtins.elemAt option.loc 0 == "conf" || builtins.elemAt option.loc 0 == "mods"); map (name: lib.strings.removeSuffix ".nix" name) (lib.attrsets.mapAttrsToList (name: _: name) paths)
}; );
}; mods = map makeOptionsDocPrograms names;
example = makeOptionsDoc (build_systems [ "example" ] ../example/.)."example"; docs = lib.strings.concatLines (map generateDocs (lib.lists.zipLists names mods));
summary = lib.strings.concatStringsSep " " (map summaryAppend names);
in in
pkgs.stdenvNoCC.mkDerivation { pkgs.stdenvNoCC.mkDerivation {
name = "dashNix-book"; name = "dashNix-book";
src = ./.; src = ./.;
patchPhase = '' patchPhase = ''
sed '/*Declared by:*/,/^$/d' <${example.optionsCommonMark} >> src/dashNix.md sed '/*Declared by:*/,/^$/d' <${conf.optionsCommonMark} >> src/conf.md
${docs}
echo "[README](README.md)\n # Options\n - [Base Config](conf.md)" >> src/SUMMARY.md
${summary}
''; '';
buildPhase = '' buildPhase = ''
${pkgs.mdbook}/bin/mdbook build --dest-dir $out ${pkgs.mdbook}/bin/mdbook build --dest-dir $out
''; '';

View file

@ -74,25 +74,27 @@ Here is a minimal required configuration.nix (the TODOs mention a required chang
# modules # modules
mods = { mods = {
# default disk config has root home boot and swap partition, overwrite if you want something different # default disk config has root home boot and swap partition, overwrite if you want something different
defaultDrives.enable = false; drives = {
extraDrives = [ defaultDrives.enable = false;
{ extraDrives = [
name = "boot"; {
drive = { name = "boot";
device = "/dev/disk/by-label/BOOT"; drive = {
fsType = "vfat"; device = "/dev/disk/by-label/BOOT";
options = [ "rw" "fmask=0022" "dmask=0022" "noatime" ]; fsType = "vfat";
}; options = [ "rw" "fmask=0022" "dmask=0022" "noatime" ];
} };
{ }
name = ""; {
drive = { name = "";
device = "/dev/disk/by-label/ROOT"; drive = {
fsType = "ext4"; device = "/dev/disk/by-label/ROOT";
options = [ "noatime" "nodiratime" "discard" ]; fsType = "ext4";
}; options = [ "noatime" "nodiratime" "discard" ];
} };
]; }
];
};
sops.enable = false; sops.enable = false;
nextcloud.enable = false; nextcloud.enable = false;
hyprland.monitor = [ hyprland.monitor = [
@ -103,7 +105,7 @@ Here is a minimal required configuration.nix (the TODOs mention a required chang
",highrr,auto,1" ",highrr,auto,1"
]; ];
# or amd, whatever you have # or amd, whatever you have
nvidia.enable = true; gpu.nvidia.enable = true;
kde_connect.enable = true; kde_connect.enable = true;
# TODO change this to your main resolution # TODO change this to your main resolution
# -> this will be your login manager # -> this will be your login manager

View file

@ -1,6 +0,0 @@
[README](README.md)
# Options
- [Options](dashNix.md)

0
docs/src/dashNix.md → docs/src/coding.md Executable file → Normal file
View file

1
docs/src/conf.md Executable file
View file

@ -0,0 +1 @@
# This file handles the basic configuration for settings like language, timezone, input, cpu etc.

1
docs/src/mods.md Executable file
View file

@ -0,0 +1 @@
# This file handles configuration of individual modules.

View file

@ -17,34 +17,36 @@
# modules # modules
mods = { mods = {
# default disk config has root home boot and swap partition, overwrite if you want something different # default disk config has root home boot and swap partition, overwrite if you want something different
defaultDrives.enable = false; drives = {
extraDrives = [ defaultDrives.enable = false;
{ extraDrives = [
name = "boot"; {
drive = { name = "boot";
device = "/dev/disk/by-label/BOOT"; drive = {
fsType = "vfat"; device = "/dev/disk/by-label/BOOT";
options = [ fsType = "vfat";
"rw" options = [
"fmask=0022" "rw"
"dmask=0022" "fmask=0022"
"noatime" "dmask=0022"
]; "noatime"
}; ];
} };
{ }
name = ""; {
drive = { name = "";
device = "/dev/disk/by-label/ROOT"; drive = {
fsType = "ext4"; device = "/dev/disk/by-label/ROOT";
options = [ fsType = "ext4";
"noatime" options = [
"nodiratime" "noatime"
"discard" "nodiratime"
]; "discard"
}; ];
} };
]; }
];
};
sops.enable = false; sops.enable = false;
nextcloud.enable = false; nextcloud.enable = false;
hyprland.monitor = [ hyprland.monitor = [
@ -55,7 +57,7 @@
",highrr,auto,1" ",highrr,auto,1"
]; ];
# or amd, whatever you have # or amd, whatever you have
nvidia.enable = true; gpu.nvidia.enable = true;
kde_connect.enable = true; kde_connect.enable = true;
# TODO change this to your main resolution # TODO change this to your main resolution
# -> this will be your login manager # -> this will be your login manager

View file

@ -70,6 +70,7 @@
dashNixLib = import ./lib { inherit inputs pkgs; }; dashNixLib = import ./lib { inherit inputs pkgs; };
docs = import ./docs { docs = import ./docs {
inherit inputs pkgs; inherit inputs pkgs;
lib = inputs.nixpkgs.lib;
build_systems = dashNixLib.build_systems; build_systems = dashNixLib.build_systems;
}; };
dashNixInputs = inputs; dashNixInputs = inputs;

View file

@ -8,32 +8,34 @@
}: }:
{ {
options.mods = { options.mods = {
default_base_packages = { base_packages = {
enable = lib.mkOption { default_base_packages = {
default = true; enable = lib.mkOption {
example = false; default = true;
type = lib.types.bool; example = false;
description = '' type = lib.types.bool;
Enables default system packages. description = ''
''; Enables default system packages.
}; '';
additional_packages = lib.mkOption { };
default = [ ]; additional_packages = lib.mkOption {
example = [ pkgs.openssl ]; default = [ ];
type = with lib.types; listOf package; example = [ pkgs.openssl ];
description = '' type = with lib.types; listOf package;
Additional packages to install. description = ''
Note that these are installed even if base packages is disabled, e.g. you can also use this as the only packages to install. Additional packages to install.
''; Note that these are installed even if base packages is disabled, e.g. you can also use this as the only packages to install.
'';
};
}; };
}; };
}; };
config = ( config = (
lib.optionalAttrs (options ? environment.systemPackages) { lib.optionalAttrs (options ? environment.systemPackages) {
environment.systemPackages = config.mods.default_base_packages.additional_packages; environment.systemPackages = config.mods.base_packages.default_base_packages.additional_packages;
} }
// (lib.mkIf config.mods.default_base_packages.enable ( // (lib.mkIf config.mods.base_packages.default_base_packages.enable (
lib.optionalAttrs (options ? environment.systemPackages) { lib.optionalAttrs (options ? environment.systemPackages) {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
adwaita-icon-theme adwaita-icon-theme

View file

@ -18,7 +18,7 @@
./kde_connect.nix ./kde_connect.nix
./keepassxc.nix ./keepassxc.nix
./kitty.nix ./kitty.nix
./layout.nix ./xkb.nix
./media.nix ./media.nix
./ncspot.nix ./ncspot.nix
./nextcloud.nix ./nextcloud.nix

View file

@ -36,50 +36,52 @@ let
in in
{ {
options.mods = { options.mods = {
useSwap = { drives = {
enable = lib.mkOption { useSwap = {
default = true; enable = lib.mkOption {
example = false; default = true;
type = lib.types.bool; example = false;
description = '' type = lib.types.bool;
Use default drive config description = ''
''; Use default drive config
'';
};
}; };
}; defaultDrives = {
defaultDrives = { enable = lib.mkOption {
enable = lib.mkOption { default = true;
default = true; example = false;
example = false; type = lib.types.bool;
type = lib.types.bool; description = ''
description = '' Use default drive config
Use default drive config '';
''; };
}; };
}; extraDrives = lib.mkOption {
extraDrives = lib.mkOption { default = [
default = [
]; ];
example = [ example = [
{ {
name = "drive2"; name = "drive2";
drive = { drive = {
device = "/dev/disk/by-label/DRIVE2"; device = "/dev/disk/by-label/DRIVE2";
fsType = "ext4"; fsType = "ext4";
options = [ options = [
"noatime" "noatime"
"nodiratime" "nodiratime"
"discard" "discard"
]; ];
}; };
} }
]; ];
# TODO: how to make this work # TODO: how to make this work
# type = with lib.types; listOf (attrsOf driveModule); # type = with lib.types; listOf (attrsOf driveModule);
type = with lib.types; listOf (attrsOf anything); type = with lib.types; listOf (attrsOf anything);
description = '' description = ''
Extra drives to add. Extra drives to add.
''; '';
};
}; };
}; };
@ -93,9 +95,9 @@ in
name = "/" + name; name = "/" + name;
value = drive; value = drive;
} }
) config.mods.extraDrives ) config.mods.drives.extraDrives
) )
// (lib.optionalAttrs config.mods.defaultDrives.enable) { // (lib.optionalAttrs config.mods.drives.defaultDrives.enable) {
"/" = { "/" = {
device = "/dev/disk/by-label/ROOT"; device = "/dev/disk/by-label/ROOT";
fsType = "btrfs"; fsType = "btrfs";
@ -128,7 +130,7 @@ in
}; };
}; };
# TODO make this convert to choice of drives -> thanks to funny types this doesn't work... # TODO make this convert to choice of drives -> thanks to funny types this doesn't work...
swapDevices = lib.mkIf config.mods.useSwap.enable [ { device = "/dev/disk/by-label/SWAP"; } ]; swapDevices = lib.mkIf config.mods.drives.useSwap.enable [ { device = "/dev/disk/by-label/SWAP"; } ];
} }
); );
} }

View file

@ -8,47 +8,49 @@
{ {
options.mods = { options.mods = {
nvidia.enable = lib.mkOption { gpu = {
default = false; nvidia.enable = lib.mkOption {
example = true; default = false;
type = lib.types.bool; example = true;
description = ''
Enables nvidia support.
'';
};
amdgpu.enable = lib.mkOption {
default = false;
example = true;
type = lib.types.bool;
description = ''
Enables amdgpu support.
'';
};
intelgpu.enable = lib.mkOption {
default = false;
example = true;
type = lib.types.bool;
description = ''
Enables intel support.
'';
};
vapi = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool; type = lib.types.bool;
description = '' description = ''
Enables vapi. Enables nvidia support.
''; '';
}; };
rocm.enable = lib.mkOption { amdgpu.enable = lib.mkOption {
default = false; default = false;
type = lib.types.bool;
example = true; example = true;
type = lib.types.bool;
description = '' description = ''
Enables rocm support. Enables amdgpu support.
''; '';
}; };
intelgpu.enable = lib.mkOption {
default = false;
example = true;
type = lib.types.bool;
description = ''
Enables intel support.
'';
};
vapi = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = ''
Enables vapi.
'';
};
rocm.enable = lib.mkOption {
default = false;
type = lib.types.bool;
example = true;
description = ''
Enables rocm support.
'';
};
};
}; };
}; };
@ -64,11 +66,13 @@
graphics = graphics =
let let
amdPackages = [ amdPackages = [
(lib.mkIf (config.mods.intelgpu && lib.mkIf config.mods.vapi.enable) pkgs.vpl-gpu-rt) (lib.mkIf (config.mods.gpu.intelgpu && lib.mkIf config.mods.gpu.vapi.enable) pkgs.vpl-gpu-rt)
(lib.mkIf (config.mods.intelgpu && lib.mkIf config.mods.vapi.enable) pkgs.intel-media-driver) (lib.mkIf (
(lib.mkIf config.mods.vapi.enable pkgs.libvdpau-va-gl) config.mods.gpu.intelgpu && lib.mkIf config.mods.gpu.vapi.enable
(lib.mkIf config.mods.vapi.enable pkgs.vaapiVdpau) ) pkgs.intel-media-driver)
(lib.mkIf (config.mods.intelgpu || config.mods.amdgpu) pkgs.mesa.drivers) (lib.mkIf config.mods.gpu.vapi.enable pkgs.libvdpau-va-gl)
(lib.mkIf config.mods.gpu.vapi.enable pkgs.vaapiVdpau)
(lib.mkIf (config.mods.gpu.intelgpu || config.mods.gpu.amdgpu) pkgs.mesa.drivers)
]; ];
rocmPackages = [ rocmPackages = [
pkgs.rocmPackages.clr.icd pkgs.rocmPackages.clr.icd
@ -80,12 +84,12 @@
enable32Bit = lib.mkDefault true; enable32Bit = lib.mkDefault true;
extraPackages = extraPackages =
amdPackages amdPackages
++ (lib.lists.optionals (config.mods.vapi.rocm.enable && config.mods.gpu.amdgpu) rocmPackages); ++ (lib.lists.optionals (config.mods.gpu.vapi.rocm.enable && config.mods.gpu.amdgpu) rocmPackages);
}; };
}; };
}) })
// lib.optionalAttrs (options ? hardware.graphics) ( // lib.optionalAttrs (options ? hardware.graphics) (
lib.mkIf config.mods.nvidia.enable { lib.mkIf config.mods.gpu.nvidia.enable {
hardware.nvidia = { hardware.nvidia = {
modesetting.enable = true; modesetting.enable = true;
# powerManagement.enable = false; # powerManagement.enable = false;

View file

@ -254,7 +254,7 @@
cursor = { cursor = {
# conversion seems to be borked right now, i want a smooth bibata :( # conversion seems to be borked right now, i want a smooth bibata :(
enable_hyprcursor = false; enable_hyprcursor = false;
no_hardware_cursors = lib.mkIf config.mods.nvidia.enable true; no_hardware_cursors = lib.mkIf config.mods.gpu.nvidia.enable true;
# no_break_fs_vrr = true; # no_break_fs_vrr = true;
}; };
@ -285,10 +285,10 @@
(lib.mkIf config.mods.hyprland.no_atomic "WLR_DRM_NO_ATOMIC,1") (lib.mkIf config.mods.hyprland.no_atomic "WLR_DRM_NO_ATOMIC,1")
"GTK_USE_PORTAL, 1" "GTK_USE_PORTAL, 1"
(lib.mkIf config.mods.nvidia.enable "LIBVA_DRIVER_NAME,nvidia") (lib.mkIf config.mods.gpu.nvidia.enable "LIBVA_DRIVER_NAME,nvidia")
(lib.mkIf config.mods.nvidia.enable "XDG_SESSION_TYPE,wayland") (lib.mkIf config.mods.gpu.nvidia.enable "XDG_SESSION_TYPE,wayland")
(lib.mkIf config.mods.nvidia.enable "GBM_BACKEND,nvidia-drm") (lib.mkIf config.mods.gpu.nvidia.enable "GBM_BACKEND,nvidia-drm")
(lib.mkIf config.mods.nvidia.enable "__GLX_VENDOR_LIBRARY_NAME,nvidia") (lib.mkIf config.mods.gpu.nvidia.enable "__GLX_VENDOR_LIBRARY_NAME,nvidia")
]; ];
layerrule = [ layerrule = [

View file

@ -6,7 +6,7 @@
... ...
}: }:
{ {
options.mods.media_packages = { options.mods.media = {
useBasePackages = lib.mkOption { useBasePackages = lib.mkOption {
default = true; default = true;
example = false; example = false;
@ -24,9 +24,9 @@
}; };
config = ( config = (
lib.optionalAttrs (options ? home.packages) { lib.optionalAttrs (options ? home.packages) {
home.packages = config.mods.media_packages.additionalPackages; home.packages = config.mods.media.additionalPackages;
} }
// (lib.mkIf config.mods.media_packages.useBasePackages ( // (lib.mkIf config.mods.media.useBasePackages (
lib.optionalAttrs (options ? home.packages) { lib.optionalAttrs (options ? home.packages) {
home.packages = with pkgs; [ home.packages = with pkgs; [
# base audio # base audio

2
result
View file

@ -1 +1 @@
/nix/store/cp42vzpzj6jls43xf40m6hp7w07sg1xr-dashNix-book /nix/store/djp5gc4jd0g7p2waxhhcaliakn9irh7l-dashNix-book