diff --git a/docs/default.nix b/docs/default.nix index fd0b6f5..ba2bfdd 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -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 ''; diff --git a/docs/src/README.md b/docs/src/README.md index 23c3b22..813c0c0 100644 --- a/docs/src/README.md +++ b/docs/src/README.md @@ -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 diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index dc12eda..e69de29 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -1,6 +0,0 @@ -[README](README.md) - -# Options - -- [Options](dashNix.md) - diff --git a/docs/src/dashNix.md b/docs/src/coding.md old mode 100755 new mode 100644 similarity index 100% rename from docs/src/dashNix.md rename to docs/src/coding.md diff --git a/docs/src/conf.md b/docs/src/conf.md new file mode 100755 index 0000000..aa51f0b --- /dev/null +++ b/docs/src/conf.md @@ -0,0 +1 @@ +# This file handles the basic configuration for settings like language, timezone, input, cpu etc. diff --git a/docs/src/mods.md b/docs/src/mods.md new file mode 100755 index 0000000..df7fe4f --- /dev/null +++ b/docs/src/mods.md @@ -0,0 +1 @@ +# This file handles configuration of individual modules. diff --git a/example/hosts/example/configuration.nix b/example/hosts/example/configuration.nix index e1ca701..f1db2e5 100644 --- a/example/hosts/example/configuration.nix +++ b/example/hosts/example/configuration.nix @@ -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 diff --git a/flake.nix b/flake.nix index c87e619..290d194 100644 --- a/flake.nix +++ b/flake.nix @@ -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; diff --git a/modules/programs/base_packages.nix b/modules/programs/base_packages.nix index f0eb012..690af93 100644 --- a/modules/programs/base_packages.nix +++ b/modules/programs/base_packages.nix @@ -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 diff --git a/modules/programs/default.nix b/modules/programs/default.nix index 6d15d00..9195271 100644 --- a/modules/programs/default.nix +++ b/modules/programs/default.nix @@ -18,7 +18,7 @@ ./kde_connect.nix ./keepassxc.nix ./kitty.nix - ./layout.nix + ./xkb.nix ./media.nix ./ncspot.nix ./nextcloud.nix diff --git a/modules/programs/drives.nix b/modules/programs/drives.nix index 66206c4..579ed70 100644 --- a/modules/programs/drives.nix +++ b/modules/programs/drives.nix @@ -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"; } ]; } ); } diff --git a/modules/programs/gpu.nix b/modules/programs/gpu.nix index bfd4964..69592a2 100644 --- a/modules/programs/gpu.nix +++ b/modules/programs/gpu.nix @@ -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; diff --git a/modules/programs/hyprland/hyprland.nix b/modules/programs/hyprland/hyprland.nix index d85b771..09d822b 100644 --- a/modules/programs/hyprland/hyprland.nix +++ b/modules/programs/hyprland/hyprland.nix @@ -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 = [ diff --git a/modules/programs/media.nix b/modules/programs/media.nix index 6fcbf4f..fcb5e10 100644 --- a/modules/programs/media.nix +++ b/modules/programs/media.nix @@ -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 diff --git a/modules/programs/layout.nix b/modules/programs/xkb.nix similarity index 100% rename from modules/programs/layout.nix rename to modules/programs/xkb.nix diff --git a/result b/result index b09d584..8a559a9 120000 --- a/result +++ b/result @@ -1 +1 @@ -/nix/store/cp42vzpzj6jls43xf40m6hp7w07sg1xr-dashNix-book \ No newline at end of file +/nix/store/djp5gc4jd0g7p2waxhhcaliakn9irh7l-dashNix-book \ No newline at end of file