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
{ pkgs, build_systems, ... }:
{
pkgs,
build_systems,
lib,
...
}:
let
makeOptionsDoc =
configuration:
pkgs.nixosOptionsDoc {
inherit (configuration) options;
# Filter out any options not beginning with `stylix`
transformOptions =
option:
option
// {
visible =
builtins.elemAt option.loc 0 != "kernel"
&& option.visible
&& (builtins.elemAt option.loc 0 == "conf" || builtins.elemAt option.loc 0 == "mods");
};
};
example = makeOptionsDoc (build_systems [ "example" ] ../example/.)."example";
makeOptionsDoc = configuration: pkgs.nixosOptionsDoc { options = configuration; };
generateDocs = obj: ''
touch src/${obj.fst}.md
sed '/*Declared by:*/,/^$/d' <${obj.snd.optionsCommonMark} >> src/${obj.fst}.md
'';
summaryAppend = name: ''
echo "- [${name}](${name}.md)" >> src/SUMMARY.md
'';
system = (build_systems [ "example" ] ../example/.)."example".options;
makeOptionsDocPrograms = name: pkgs.nixosOptionsDoc { options = system.mods.${name}; };
conf = makeOptionsDoc system.conf;
paths = builtins.readDir ../modules/programs;
names = lib.lists.remove "default" (
map (name: lib.strings.removeSuffix ".nix" name) (lib.attrsets.mapAttrsToList (name: _: name) paths)
);
mods = map makeOptionsDocPrograms names;
docs = lib.strings.concatLines (map generateDocs (lib.lists.zipLists names mods));
summary = lib.strings.concatStringsSep " " (map summaryAppend names);
in
pkgs.stdenvNoCC.mkDerivation {
name = "dashNix-book";
src = ./.;
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 = ''
${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
mods = {
# default disk config has root home boot and swap partition, overwrite if you want something different
defaultDrives.enable = false;
extraDrives = [
{
name = "boot";
drive = {
device = "/dev/disk/by-label/BOOT";
fsType = "vfat";
options = [ "rw" "fmask=0022" "dmask=0022" "noatime" ];
};
}
{
name = "";
drive = {
device = "/dev/disk/by-label/ROOT";
fsType = "ext4";
options = [ "noatime" "nodiratime" "discard" ];
};
}
];
drives = {
defaultDrives.enable = false;
extraDrives = [
{
name = "boot";
drive = {
device = "/dev/disk/by-label/BOOT";
fsType = "vfat";
options = [ "rw" "fmask=0022" "dmask=0022" "noatime" ];
};
}
{
name = "";
drive = {
device = "/dev/disk/by-label/ROOT";
fsType = "ext4";
options = [ "noatime" "nodiratime" "discard" ];
};
}
];
};
sops.enable = false;
nextcloud.enable = false;
hyprland.monitor = [
@ -103,7 +105,7 @@ Here is a minimal required configuration.nix (the TODOs mention a required chang
",highrr,auto,1"
];
# or amd, whatever you have
nvidia.enable = true;
gpu.nvidia.enable = true;
kde_connect.enable = true;
# TODO change this to your main resolution
# -> 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
mods = {
# default disk config has root home boot and swap partition, overwrite if you want something different
defaultDrives.enable = false;
extraDrives = [
{
name = "boot";
drive = {
device = "/dev/disk/by-label/BOOT";
fsType = "vfat";
options = [
"rw"
"fmask=0022"
"dmask=0022"
"noatime"
];
};
}
{
name = "";
drive = {
device = "/dev/disk/by-label/ROOT";
fsType = "ext4";
options = [
"noatime"
"nodiratime"
"discard"
];
};
}
];
drives = {
defaultDrives.enable = false;
extraDrives = [
{
name = "boot";
drive = {
device = "/dev/disk/by-label/BOOT";
fsType = "vfat";
options = [
"rw"
"fmask=0022"
"dmask=0022"
"noatime"
];
};
}
{
name = "";
drive = {
device = "/dev/disk/by-label/ROOT";
fsType = "ext4";
options = [
"noatime"
"nodiratime"
"discard"
];
};
}
];
};
sops.enable = false;
nextcloud.enable = false;
hyprland.monitor = [
@ -55,7 +57,7 @@
",highrr,auto,1"
];
# or amd, whatever you have
nvidia.enable = true;
gpu.nvidia.enable = true;
kde_connect.enable = true;
# TODO change this to your main resolution
# -> this will be your login manager

View file

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

View file

@ -8,32 +8,34 @@
}:
{
options.mods = {
default_base_packages = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = ''
Enables default system packages.
'';
};
additional_packages = lib.mkOption {
default = [ ];
example = [ pkgs.openssl ];
type = with lib.types; listOf package;
description = ''
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.
'';
base_packages = {
default_base_packages = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = ''
Enables default system packages.
'';
};
additional_packages = lib.mkOption {
default = [ ];
example = [ pkgs.openssl ];
type = with lib.types; listOf package;
description = ''
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 = (
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) {
environment.systemPackages = with pkgs; [
adwaita-icon-theme

View file

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

View file

@ -36,50 +36,52 @@ let
in
{
options.mods = {
useSwap = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = ''
Use default drive config
'';
drives = {
useSwap = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = ''
Use default drive config
'';
};
};
};
defaultDrives = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = ''
Use default drive config
'';
defaultDrives = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = ''
Use default drive config
'';
};
};
};
extraDrives = lib.mkOption {
default = [
extraDrives = lib.mkOption {
default = [
];
example = [
{
name = "drive2";
drive = {
device = "/dev/disk/by-label/DRIVE2";
fsType = "ext4";
options = [
"noatime"
"nodiratime"
"discard"
];
};
}
];
# TODO: how to make this work
# type = with lib.types; listOf (attrsOf driveModule);
type = with lib.types; listOf (attrsOf anything);
description = ''
Extra drives to add.
'';
];
example = [
{
name = "drive2";
drive = {
device = "/dev/disk/by-label/DRIVE2";
fsType = "ext4";
options = [
"noatime"
"nodiratime"
"discard"
];
};
}
];
# TODO: how to make this work
# type = with lib.types; listOf (attrsOf driveModule);
type = with lib.types; listOf (attrsOf anything);
description = ''
Extra drives to add.
'';
};
};
};
@ -93,9 +95,9 @@ in
name = "/" + name;
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";
fsType = "btrfs";
@ -128,7 +130,7 @@ in
};
};
# 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 = {
nvidia.enable = lib.mkOption {
default = false;
example = true;
type = lib.types.bool;
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;
gpu = {
nvidia.enable = lib.mkOption {
default = false;
example = true;
type = lib.types.bool;
description = ''
Enables vapi.
Enables nvidia support.
'';
};
rocm.enable = lib.mkOption {
amdgpu.enable = lib.mkOption {
default = false;
type = lib.types.bool;
example = true;
type = lib.types.bool;
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 =
let
amdPackages = [
(lib.mkIf (config.mods.intelgpu && lib.mkIf config.mods.vapi.enable) pkgs.vpl-gpu-rt)
(lib.mkIf (config.mods.intelgpu && lib.mkIf config.mods.vapi.enable) pkgs.intel-media-driver)
(lib.mkIf config.mods.vapi.enable pkgs.libvdpau-va-gl)
(lib.mkIf config.mods.vapi.enable pkgs.vaapiVdpau)
(lib.mkIf (config.mods.intelgpu || config.mods.amdgpu) pkgs.mesa.drivers)
(lib.mkIf (config.mods.gpu.intelgpu && lib.mkIf config.mods.gpu.vapi.enable) pkgs.vpl-gpu-rt)
(lib.mkIf (
config.mods.gpu.intelgpu && lib.mkIf config.mods.gpu.vapi.enable
) pkgs.intel-media-driver)
(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 = [
pkgs.rocmPackages.clr.icd
@ -80,12 +84,12 @@
enable32Bit = lib.mkDefault true;
extraPackages =
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.mkIf config.mods.nvidia.enable {
lib.mkIf config.mods.gpu.nvidia.enable {
hardware.nvidia = {
modesetting.enable = true;
# powerManagement.enable = false;

View file

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

View file

@ -6,7 +6,7 @@
...
}:
{
options.mods.media_packages = {
options.mods.media = {
useBasePackages = lib.mkOption {
default = true;
example = false;
@ -24,9 +24,9 @@
};
config = (
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) {
home.packages = with pkgs; [
# base audio

2
result
View file

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