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,6 +74,7 @@ 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
drives = {
defaultDrives.enable = false; defaultDrives.enable = false;
extraDrives = [ extraDrives = [
{ {
@ -93,6 +94,7 @@ Here is a minimal required configuration.nix (the TODOs mention a required chang
}; };
} }
]; ];
};
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,6 +17,7 @@
# 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
drives = {
defaultDrives.enable = false; defaultDrives.enable = false;
extraDrives = [ extraDrives = [
{ {
@ -45,6 +46,7 @@
}; };
} }
]; ];
};
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,6 +8,7 @@
}: }:
{ {
options.mods = { options.mods = {
base_packages = {
default_base_packages = { default_base_packages = {
enable = lib.mkOption { enable = lib.mkOption {
default = true; default = true;
@ -28,12 +29,13 @@
}; };
}; };
}; };
};
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,6 +36,7 @@ let
in in
{ {
options.mods = { options.mods = {
drives = {
useSwap = { useSwap = {
enable = lib.mkOption { enable = lib.mkOption {
default = true; default = true;
@ -82,6 +83,7 @@ in
''; '';
}; };
}; };
};
config = ( config = (
lib.optionalAttrs (options ? fileSystems) { lib.optionalAttrs (options ? fileSystems) {
@ -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,6 +8,7 @@
{ {
options.mods = { options.mods = {
gpu = {
nvidia.enable = lib.mkOption { nvidia.enable = lib.mkOption {
default = false; default = false;
example = true; example = true;
@ -51,6 +52,7 @@
}; };
}; };
}; };
};
config = config =
(lib.optionalAttrs (options ? hardware.graphics) { (lib.optionalAttrs (options ? hardware.graphics) {
@ -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