From 9c13923c2e5d67d2748a8e3df5acd7cf9d8a7dbe Mon Sep 17 00:00:00 2001 From: Grey Jones Date: Wed, 2 Sep 2026 00:05:28 +0100 Subject: [PATCH] move options back out to their config files, improve documentation --- flake.lock | 8 +- modules/components/boot-loaders/grub.nix | 6 +- modules/components/boot-loaders/limine.nix | 7 +- modules/docs.nix | 115 +++++++++++++----- .../applications/cli/color-converter.nix | 4 + .../features/applications/cli/fastfetch.nix | 4 + modules/features/applications/cli/nh.nix | 36 ++++-- modules/features/applications/gui/equibop.nix | 28 ++++- modules/features/applications/gui/floorp.nix | 4 + modules/features/applications/gui/fluxer.nix | 7 ++ modules/features/applications/gui/kitty.nix | 4 + .../features/applications/gui/nautilus.nix | 4 + modules/features/applications/gui/remmina.nix | 4 + modules/features/applications/gui/spotify.nix | 32 ++++- modules/features/applications/gui/vscode.nix | 4 + .../features/hardware/steam-controller.nix | 4 + modules/features/nixos/home-manager.nix | 4 + modules/features/nixos/stylix.nix | 4 + modules/features/services/easyeffects.nix | 4 + modules/features/shells.nix | 10 +- modules/features/shells/zsh.nix | 11 +- modules/global/home.nix | 1 + modules/hosts/kitagawa/kitagawa.nix | 7 +- modules/hosts/sakamoto/sakamoto.nix | 30 +++++ modules/hosts/takamaki/takamaki.nix | 5 +- modules/options/audio.nix | 5 - modules/options/gaming.nix | 17 --- modules/options/global.nix | 97 ++++++--------- modules/options/graphics.nix | 93 +++----------- modules/options/options.nix | 18 --- 30 files changed, 344 insertions(+), 233 deletions(-) create mode 100644 modules/hosts/sakamoto/sakamoto.nix delete mode 100644 modules/options/audio.nix delete mode 100644 modules/options/gaming.nix delete mode 100644 modules/options/options.nix diff --git a/flake.lock b/flake.lock index 6820c9b..24ec274 100644 --- a/flake.lock +++ b/flake.lock @@ -187,11 +187,11 @@ ] }, "locked": { - "lastModified": 1788129603, - "narHash": "sha256-NIj3G63MeCajZr70RGl1xNsdsAa+0QgH+lq00doGjDY=", + "lastModified": 1788303756, + "narHash": "sha256-KwDkCX7JBWVjDCoP1CqF3HCMpM8Uy1anD0pKzAZ2Aaw=", "ref": "refs/heads/main", - "rev": "3131ebbfcdbbf49f073d0f81ea987300cf422a2e", - "revCount": 12, + "rev": "fef3a464ef4db019bd654446b15eca1f9b31fd44", + "revCount": 48, "type": "git", "url": "https://git.greyweather.dev/greyweather/nix-helper-flake" }, diff --git a/modules/components/boot-loaders/grub.nix b/modules/components/boot-loaders/grub.nix index e600c44..6af8aba 100644 --- a/modules/components/boot-loaders/grub.nix +++ b/modules/components/boot-loaders/grub.nix @@ -1,8 +1,12 @@ { inputs, self, ... }: { flake.nixosModules.global = { pkgs, config, lib, ... }: { - boot.loader.grub = lib.mkIf (config.components.bootLoader == "grub") { + boot.loader.grub = lib.mkIf (config.components.bootLoader.selection == "grub") { enable = true; useOSProber = true; + configurationLimit = config.components.bootLoader.maxGenerations; + extraConfig = '' + timeout ${config.components.bootLoader.timeout} + ''; }; }; } \ No newline at end of file diff --git a/modules/components/boot-loaders/limine.nix b/modules/components/boot-loaders/limine.nix index 5018a6b..ac8cd79 100644 --- a/modules/components/boot-loaders/limine.nix +++ b/modules/components/boot-loaders/limine.nix @@ -1,8 +1,11 @@ { inputs, self, ... }: { flake.nixosModules.global = { pkgs, config, lib, ... }: { - boot.loader.limine = lib.mkIf (config.components.bootLoader == "limine") { + boot.loader.limine = lib.mkIf (config.components.bootLoader.selection == "limine") { enable = true; - maxGenerations = 10; + maxGenerations = config.components.bootLoader.maxGenerations; + extraConfig = '' + timeout: ${if config.components.bootLoader.timeout == -1 then "no" else builtins.toString (config.components.bootLoader.timeout)} + ''; }; }; } \ No newline at end of file diff --git a/modules/docs.nix b/modules/docs.nix index a8ae979..62d0ddb 100644 --- a/modules/docs.nix +++ b/modules/docs.nix @@ -2,6 +2,15 @@ mkDocsDerivation = { pkgs, doBuild ? true }: let inherit (pkgs) lib stdenv mkdocs python314Packages; + indexMd = let + rawText = '' + ## Welcome! + This site is rebuilt with every generation, and holds a complete record of all options declared within this flake. + ''; + in pkgs.runCommand "index.md" {} '' + echo "${rawText}" >> $out + ''; + mkOptionsDocFromModule = commandName: module: let eval = lib.evalModules { modules = [ module ]; @@ -9,49 +18,63 @@ }; optionsDoc = pkgs.nixosOptionsDoc { - inherit (eval) options; + options = builtins.removeAttrs eval.options ["_module"]; }; in pkgs.runCommand commandName {} '' cat ${optionsDoc.optionsCommonMark} >> $out ''; - indexMd = let - rawText = '' - ## Welcome! - This site is rebuilt with every generation, and holds a complete record of all options declared within this flake. - Visit [NixOS](nixos-options.md) or [Home Manager](home-options.md) to see the available options. - ''; - in pkgs.runCommand "index.md" {} '' - echo "${rawText}" >> $out - ''; + nixos-global-options = mkOptionsDocFromModule "nixos-global-options.md" self.nixosModules.globalOptions; + nixos-graphics-options = mkOptionsDocFromModule "nixos-graphics-options.md" self.nixosModules.graphicsOptions; + nixos-gaming-options = mkOptionsDocFromModule "nixos-gaming-options.md" self.nixosModules.gamingOptions; - nixosOptionsMd = mkOptionsDocFromModule "nixos-options.md" self.nixosModules.options; - homeOptionsMd = mkOptionsDocFromModule "home-options.md" self.homeModules.options; + home-global-options = mkOptionsDocFromModule "home-global-options.md" self.homeModules.globalOptions; + home-audio-options = mkOptionsDocFromModule "home-audio-options.md" self.homeModules.audioOptions; + home-graphics-options = mkOptionsDocFromModule "home-graphics-options.md" self.homeModules.graphicsOptions; + home-gaming-options = mkOptionsDocFromModule "home-gaming-options.md" self.homeModules.gamingOptions; mkDocsConfig = '' site_name: flake options nav: - Home: 'index.md' - Options: - - NixOS: 'nixos-options.md' - - Home Manager: 'home-options.md' + - NixOS: + - Global: 'nixos-global-options.md' + - Capabilities: + - Graphics: 'nixos-graphics-options.md' + - Gaming: 'nixos-gaming-options.md' + - Home Manager: + - Global: 'home-global-options.md' + - Capabilities: + - Audio: 'home-audio-options.md' + - Graphics: 'home-graphics-options.md' + - Gaming: 'home-gaming-options.md' theme: name: material palette: scheme: slate + markdown_extensions: + - admonition + - pymdownx.details + - pymdownx.superfences ''; mkDocsYml = pkgs.runCommand "mkdocs.yml" {} '' echo "${mkDocsConfig}" >> $out ''; in stdenv.mkDerivation { - src = self; + unpackPhase = "true"; name = if doBuild then "docs" else "docs-md"; buildInput = [ mkDocsYml indexMd - nixosOptionsMd - homeOptionsMd + nixos-global-options + nixos-graphics-options + nixos-gaming-options + home-global-options + home-audio-options + home-graphics-options + home-gaming-options ]; nativeBuildInputs = [ mkdocs @@ -64,8 +87,13 @@ ln -s ${mkDocsYml} "./mkdocs.yml" mkdir docs ln -s ${indexMd} "./docs/index.md" - ln -s ${nixosOptionsMd} "./docs/nixos-options.md" - ln -s ${homeOptionsMd} "./docs/home-options.md" + ln -s ${nixos-global-options} "./docs/nixos-global-options.md" + ln -s ${nixos-graphics-options} "./docs/nixos-graphics-options.md" + ln -s ${nixos-gaming-options} "./docs/nixos-gaming-options.md" + ln -s ${home-global-options} "./docs/home-global-options.md" + ln -s ${home-audio-options} "./docs/home-audio-options.md" + ln -s ${home-graphics-options} "./docs/home-graphics-options.md" + ln -s ${home-gaming-options} "./docs/home-gaming-options.md" # generate the site ${if doBuild then "mkdocs build" else ""} ''; @@ -75,24 +103,51 @@ cp -r . $out ''; }; + + containerAttrs = { pkgs, port }: { + image = "docker.io/library/nginx:latest"; + volumes = [ + "${mkDocsDerivation { inherit pkgs; }}:/usr/share/nginx/html" + ]; + ports = [ + "${port}:80" + ]; + }; in { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "graphicsOptions" ({ lib, ... }: { + options.features.documentation = let + defaultPort = "8080"; + in { + enable = lib.mkOption { + type = lib.types.bool; + description = "This option enables documentation for the flake, which is generated with Material for mkDocs and hosted by nginx at localhost:${defaultPort} by default."; + default = true; + }; + + port = lib.mkOption { + type = lib.types.str; + description = "This option sets the port used by the nginx server hosting the local documentation site."; + default = defaultPort; + }; + }; + })) ]; + perSystem = { pkgs, ... }: { packages.docs = mkDocsDerivation { inherit pkgs; }; packages.docs-md = mkDocsDerivation { inherit pkgs; doBuild = false; }; }; - flake.homeModules.graphics = { pkgs, ... }: { - services.podman = { + flake.nixosModules.graphics = { pkgs, config, lib, ... }: { + virtualisation.oci-containers = lib.mkIf (config.features.documentation.enable && !config.features.nixos.home-manager.enable) { + backend = "docker"; + containers.flake-docs-nginx = containerAttrs { inherit (config.features.documentation) port; inherit pkgs; }; + }; + }; + + flake.homeModules.graphics = { pkgs, config, lib, ... }: { + services.podman = lib.mkIf (config.features.documentation.enable) { enable = true; - containers.flake-docs-nginx = { - image = "docker.io/library/nginx:latest"; - volumes = [ - "${mkDocsDerivation { inherit pkgs; }}:/usr/share/nginx/html" - ]; - ports = [ - "8080:80" - ]; - }; + containers.flake-docs-nginx = containerAttrs { inherit (config.features.documentation) port; inherit pkgs; }; }; }; } \ No newline at end of file diff --git a/modules/features/applications/cli/color-converter.nix b/modules/features/applications/cli/color-converter.nix index aeb1c54..5a4bad9 100644 --- a/modules/features/applications/cli/color-converter.nix +++ b/modules/features/applications/cli/color-converter.nix @@ -29,6 +29,10 @@ }; }; in { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "globalOptions" ({ lib, ... }: { + options.features.applications.cli.color-converter.enable = lib.mkEnableOption "`color-converter`"; + })) ]; + flake.nixosModules.global = { pkgs, lib, config, ... }: { config = lib.mkIf (config.features.applications.cli.color-converter.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.cli.color-converter.enable = lib.mkDefault true; diff --git a/modules/features/applications/cli/fastfetch.nix b/modules/features/applications/cli/fastfetch.nix index a28350e..5ba3015 100644 --- a/modules/features/applications/cli/fastfetch.nix +++ b/modules/features/applications/cli/fastfetch.nix @@ -1,4 +1,8 @@ { inputs, self, ... }: { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "globalOptions" ({ lib, ... }: { + options.features.applications.cli.fastfetch.enable = lib.mkEnableOption "`fastfetch`"; + })) ]; + flake.nixosModules.global = { pkgs, lib, config, ... }: { config = lib.mkIf (config.features.applications.cli.fastfetch.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.cli.fastfetch.enable = lib.mkDefault true; diff --git a/modules/features/applications/cli/nh.nix b/modules/features/applications/cli/nh.nix index fbbdf84..9567430 100644 --- a/modules/features/applications/cli/nh.nix +++ b/modules/features/applications/cli/nh.nix @@ -1,27 +1,43 @@ { inputs, self, ... }: let - mkNhAttrs = flake: { + mkNhAttrs = config: { enable = true; - inherit flake; - clean = { - enable = true; - dates = "Sun 05:00"; - extraArgs = "--keep 5 --keep-since 3d"; - }; + flake = config.info.rootPath; + clean = config.features.applications.cli.nh.clean; }; in { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "globalOptions" ({ lib, ... }: { + options.features.applications.cli.nh = { + enable = lib.mkEnableOption "NH: Yet another Nix CLI helper"; + clean = { + enable = lib.mkEnableOption "automatic cleaning of the system with `nh clean`"; + dates = lib.mkOption { + type = lib.types.str; + description = "This option defines when the cleaning job should run, in the format of [`systemd.time` calendar events](https://www.man7.org/linux/man-pages/man7/systemd.time.7.html#CALENDAR_EVENTS)."; + default = "daily"; + example = "Sun 05:00"; + }; + extraArgs = lib.mkOption { + type = lib.types.str; + description = "This option sets any extra arguments that should be passed to the `nh clean` command when it is called by this automated service."; + default = "--keep 10 --keep-since 7d"; + }; + }; + }; + })) ]; + flake.nixosModules.global = { pkgs, config, lib, ... }: { config = lib.mkIf (config.features.applications.cli.nh.enable) { - programs.nh = mkNhAttrs config.info.rootPath; + programs.nh = mkNhAttrs config; home-manager.users.grey = lib.mkIf (config.features.nixos.home-manager.enable) { - features.applications.cli.nh.enable = lib.mkDefault true; + features.applications.cli.nh = lib.mkDefault config.features.applications.cli.nh; }; }; }; flake.homeModules.global = { pkgs, config, lib, ... }: { config = lib.mkIf (config.features.applications.cli.nh.enable && config.info.isStandalone) { - programs.nh = mkNhAttrs config.info.rootPath; + programs.nh = mkNhAttrs config; }; }; } diff --git a/modules/features/applications/gui/equibop.nix b/modules/features/applications/gui/equibop.nix index c39a752..d562b39 100644 --- a/modules/features/applications/gui/equibop.nix +++ b/modules/features/applications/gui/equibop.nix @@ -1,4 +1,26 @@ -{ inputs, self, ... }: { +{ inputs, self, ... }: let + autostartOptionAttrs = { lib }: { + type = lib.types.bool; + description = "Controls whether an `equibop.desktop` file is generated and placed into `$XDG_CONFIG_HOME/autostart`."; + default = false; + }; +in { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "graphicsOptions" ({ lib, ... }: { + options.features.applications.gui.equibop.enable = lib.mkEnableOption "Equibop"; + })) ]; + + flake.nixosModules.graphicsOption = { lib, ... }: { + options.features.applications.gui.equibop.autostart = let + attrs = autostartOptionAttrs { inherit lib; }; + in lib.mkOption { + inherit (attrs) type default; + description = '' + ${attrs.description} + ${inputs.helpers.mkRedundantOptionDescription "features.nixos.home-manager.enable" "true"} + ''; + }; + }; + flake.nixosModules.graphics = { pkgs, lib, config, ...}: { config = inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.gui.equibop = lib.mkDefault config.features.applications.gui.equibop; @@ -7,6 +29,10 @@ }; }; + flake.homeModules.graphicsOptions = { lib, ... }: { + options.features.applications.gui.equibop.autostart = lib.mkOption (autostartOptionAttrs { inherit lib; }); + }; + flake.homeModules.graphics = { pkgs, lib, config, ... }: { config = lib.mkIf (config.features.applications.gui.equibop.enable) { programs.equibop.enable = true; diff --git a/modules/features/applications/gui/floorp.nix b/modules/features/applications/gui/floorp.nix index 6a56589..246487c 100644 --- a/modules/features/applications/gui/floorp.nix +++ b/modules/features/applications/gui/floorp.nix @@ -1,4 +1,8 @@ { inputs, self, ... }: { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "graphicsOptions" ({ lib, ... }: { + options.features.applications.gui.floorp.enable = lib.mkEnableOption "Floorp Browser"; + })) ]; + flake.nixosModules.graphics = { pkgs, lib, config, ... }: { config = lib.mkIf (config.features.applications.gui.floorp.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.gui.floorp.enable = lib.mkDefault true; diff --git a/modules/features/applications/gui/fluxer.nix b/modules/features/applications/gui/fluxer.nix index 20ed205..8ff6c0e 100644 --- a/modules/features/applications/gui/fluxer.nix +++ b/modules/features/applications/gui/fluxer.nix @@ -64,6 +64,13 @@ }; }; in { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "graphicsOptions" ({ lib, ... }: { + options.features.applications.gui = { + fluxer.enable = lib.mkEnableOption "Fluxer"; + fluxer-canary.enable = lib.mkEnableOption "Fluxer Canary"; + }; + })) ]; + flake.nixosModules.graphics = { pkgs, config, lib, ... }: { config = lib.mkIf (config.features.applications.gui.fluxer.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.gui.fluxer.enable = lib.mkDefault true; diff --git a/modules/features/applications/gui/kitty.nix b/modules/features/applications/gui/kitty.nix index edb800a..4503ace 100644 --- a/modules/features/applications/gui/kitty.nix +++ b/modules/features/applications/gui/kitty.nix @@ -1,4 +1,8 @@ { inputs, self, ... }: { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "graphicsOptions" ({ lib, ... }: { + options.features.applications.gui.kitty.enable = lib.mkEnableOption "Kitty Terminal"; + }))]; + flake.nixosModules.graphics = { pkgs, config, lib, ... }: { config = let in lib.mkIf (config.features.applications.gui.kitty.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { diff --git a/modules/features/applications/gui/nautilus.nix b/modules/features/applications/gui/nautilus.nix index 03c040a..8fd2c82 100644 --- a/modules/features/applications/gui/nautilus.nix +++ b/modules/features/applications/gui/nautilus.nix @@ -1,4 +1,8 @@ { inputs, self, ... }: { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "graphicsOptions" ({ lib, ... }: { + options.features.applications.gui.nautilus.enable = lib.mkEnableOption "Nautilus"; + })) ]; + flake.nixosModules.graphics = { pkgs, config, lib, ... }: { config = lib.mkIf (config.features.applications.gui.nautilus.enable) { environment.systemPackages = with pkgs; [ diff --git a/modules/features/applications/gui/remmina.nix b/modules/features/applications/gui/remmina.nix index cf8bb24..8c266de 100644 --- a/modules/features/applications/gui/remmina.nix +++ b/modules/features/applications/gui/remmina.nix @@ -1,4 +1,8 @@ { inputs, self, ... }: { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "graphicsOptions" ({ lib, ... }: { + options.features.applications.gui.remmina.enable = lib.mkEnableOption "Remmina"; + })) ]; + flake.nixosModules.graphics = { pkgs, config, lib, ... }: { config = lib.mkIf (config.features.applications.gui.remmina.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.gui.remmina.enable = lib.mkDefault true; diff --git a/modules/features/applications/gui/spotify.nix b/modules/features/applications/gui/spotify.nix index 4f299b9..59f99ec 100644 --- a/modules/features/applications/gui/spotify.nix +++ b/modules/features/applications/gui/spotify.nix @@ -1,4 +1,27 @@ -{ inputs, self, ... }: { +{ inputs, self, ... }: let + spicetifyEnableOptionAttrs = { lib }: { + type = lib.types.bool; + description = "Whether to enable Spicetify, a modified version of Spotify that supports plugins and themes."; + default = false; + }; + + spicetifyThemeOptionAttrs = { pkgs, lib }: { + type = inputs.nixpkgs.lib.types.nullOr (inputs.nixpkgs.lib.types.enum (builtins.attrNames inputs.spicetify.legacyPackages.${pkgs.stdenv.hostPlatform.system}.themes)); + description = "This option is used to select a theme for Spicetify to use, from the list of available packages themes."; + default = null; + }; +in { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "graphicsOptions" ({ lib, ... }: { + options.features.applications.gui.spotify.enable = lib.mkEnableOption "Spotify"; + })) ]; + + flake.nixosModules.graphicsOptions = { lib, pkgs, ... }: { + options.features.applications.gui.spotify.spicetify = { + enable = inputs.helpers.mkRedundantOption "features.nixos.home-manager.enable" "true" (spicetifyEnableOptionAttrs { inherit lib; }); + theme = inputs.helpers.mkRedundantOption "features.nixos.home-manager.enable" "true" (spicetifyThemeOptionAttrs { inherit pkgs lib; }); + }; + }; + flake.nixosModules.graphics = { pkgs, config, lib, ... }: let spicePkgs = inputs.spicetify.legacyPackages.${pkgs.stdenv.hostPlatform.system}; in { @@ -12,6 +35,13 @@ }); }; + flake.homeModules.graphicsOptions = { lib, pkgs, ... }: { + options.features.applications.gui.spotify.spicetify = { + enable = lib.mkOption (spicetifyEnableOptionAttrs { inherit lib; }); + theme = lib.mkOption (spicetifyThemeOptionAttrs { inherit pkgs lib; }); + }; + }; + flake.homeModules.graphics = { pkgs, config, lib, ... }: let spicePkgs = inputs.spicetify.legacyPackages.${pkgs.stdenv.hostPlatform.system}; in { diff --git a/modules/features/applications/gui/vscode.nix b/modules/features/applications/gui/vscode.nix index 1f7f452..969a827 100644 --- a/modules/features/applications/gui/vscode.nix +++ b/modules/features/applications/gui/vscode.nix @@ -1,4 +1,8 @@ { inputs, self, ... }: { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "graphicsOptions" ({ lib, ... }: { + options.features.applications.gui.vscode.enable = lib.mkEnableOption "VS Code"; + })) ]; + flake.nixosModules.graphics = { config, pkgs, lib, ... }: { config = lib.mkIf (config.features.applications.gui.vscode.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.gui.vscode.enable = lib.mkDefault true; diff --git a/modules/features/hardware/steam-controller.nix b/modules/features/hardware/steam-controller.nix index 21e1be7..b085fcc 100644 --- a/modules/features/hardware/steam-controller.nix +++ b/modules/features/hardware/steam-controller.nix @@ -1,4 +1,8 @@ { inputs, self, ... }: { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "gamingOptions" ({ lib, ... }: { + options.features.hardware.steam-controller.enable = lib.mkEnableOption "tweaks and configurations that assist when using Valve's Steam Controller"; + })) ]; + flake.nixosModules.gaming = { pkgs, config, lib, ... }: { config = lib.mkIf (config.features.hardware.steam-controller.enable) { home-manager.users.grey = lib.mkIf (config.features.nixos.home-manager.enable) { diff --git a/modules/features/nixos/home-manager.nix b/modules/features/nixos/home-manager.nix index e03b835..ab78c26 100644 --- a/modules/features/nixos/home-manager.nix +++ b/modules/features/nixos/home-manager.nix @@ -3,6 +3,10 @@ inputs.home-manager.flakeModules.home-manager ]; + flake.nixosModules.globalOptions = { lib, ... }: { + options.features.nixos.home-manager.enable = lib.mkEnableOption "Home Manager (as a NixOS module)"; + }; + flake.nixosModules.global = { pkgs, lib, config, ... }: { imports = [ inputs.home-manager.nixosModules.default diff --git a/modules/features/nixos/stylix.nix b/modules/features/nixos/stylix.nix index f9d7db0..c5b9cef 100644 --- a/modules/features/nixos/stylix.nix +++ b/modules/features/nixos/stylix.nix @@ -1,4 +1,8 @@ { inputs, self, ... }: { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "graphicsOptions" ({ lib, ... }: { + options.features.nixos.stylix.enable = lib.mkEnableOption "Stylix"; + })) ]; + flake.nixosModules.graphics = { pkgs, lib, config, ... }: { imports = [ inputs.stylix.nixosModules.stylix diff --git a/modules/features/services/easyeffects.nix b/modules/features/services/easyeffects.nix index 0536e07..3490fb0 100644 --- a/modules/features/services/easyeffects.nix +++ b/modules/features/services/easyeffects.nix @@ -1,4 +1,8 @@ { inputs, self, ... }: { + flake.homeModules.audioOptions = { lib, ...}: { + options.features.services.easyeffects.enable = lib.mkEnableOption "Easy Effects"; + }; + flake.homeModules.audio = { pkgs, config, lib, ...}: { config = lib.mkIf (config.features.services.easyeffects.enable) { services.easyeffects.enable = true; diff --git a/modules/features/shells.nix b/modules/features/shells.nix index 5ba6103..a5b835f 100644 --- a/modules/features/shells.nix +++ b/modules/features/shells.nix @@ -1,10 +1,16 @@ { inputs, self, ... }: { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "globalOptions" ({ lib, ... }: { + options.features.shells.defaultShell = lib.mkOption { + type = inputs.helpers.mkEnumFromDirContents "${self}/modules/features/shells"; + description = "This option controls the shell that should be used as the default, enabling that shell in the process."; + default = "zsh"; + }; + })) ]; + flake.nixosModules.global = { config, pkgs, lib, ... }: { programs.${config.features.shells.defaultShell}.enable = true; users.defaultUserShell = pkgs.${config.features.shells.defaultShell}; users.users."grey".shell = pkgs.${config.features.shells.defaultShell}; - - features.shells.${config.features.shells.defaultShell}.enable = true; }; } \ No newline at end of file diff --git a/modules/features/shells/zsh.nix b/modules/features/shells/zsh.nix index bc4aecb..0265da4 100644 --- a/modules/features/shells/zsh.nix +++ b/modules/features/shells/zsh.nix @@ -1,6 +1,13 @@ { inputs, self, ... }: { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "globalOptions" ({ lib, ... }: { + options.features.shells.zsh = { + enable = lib.mkEnableOption "`zsh`"; + antidote.enable = lib.mkEnableOption "Antidote, a plugin manager for `zsh`"; + }; + })) ]; + flake.nixosModules.global = { config, pkgs, lib, ... }: { - config = lib.mkIf (config.features.shells.zsh.enable) { + config = lib.mkIf (config.features.shells.zsh.enable || config.features.shells.defaultShell == "zsh") { programs.zsh.enable = true; home-manager.users.grey = lib.mkIf (config.features.nixos.home-manager.enable) { @@ -11,7 +18,7 @@ }; flake.homeModules.global = { pkgs, config, lib, ... }: { - config = lib.mkIf (config.features.shells.zsh.enable) { + config = lib.mkIf (config.features.shells.zsh.enable || config.features.shells.defaultShell == "zsh") { home.shell.enableZshIntegration = true; programs.kitty.shellIntegration.enableZshIntegration = true; diff --git a/modules/global/home.nix b/modules/global/home.nix index 9da0af5..0490f63 100644 --- a/modules/global/home.nix +++ b/modules/global/home.nix @@ -17,6 +17,7 @@ packages = with pkgs; [ speedtest-go + bitwarden-cli ] ++ config.features.applications.extraPackages ++ (if config.info.isStandalone then [ pkgs.home-manager diff --git a/modules/hosts/kitagawa/kitagawa.nix b/modules/hosts/kitagawa/kitagawa.nix index e830207..be91e1f 100644 --- a/modules/hosts/kitagawa/kitagawa.nix +++ b/modules/hosts/kitagawa/kitagawa.nix @@ -14,7 +14,7 @@ }; components = { - bootLoader = "limine"; + bootLoader.selection = "limine"; displayManager = "ly"; windowManagers = "niri"; shells = "noctalia"; @@ -26,10 +26,7 @@ stylix.enable = true; }; - shells.zsh = { - enable = true; - antidote.enable = true; - }; + shells.zsh.antidote.enable = true; applications = { gui = { diff --git a/modules/hosts/sakamoto/sakamoto.nix b/modules/hosts/sakamoto/sakamoto.nix new file mode 100644 index 0000000..2e0abdb --- /dev/null +++ b/modules/hosts/sakamoto/sakamoto.nix @@ -0,0 +1,30 @@ +{ inputs, self, ... }: { + flake.nixosConfigurations.sakamoto = inputs.nixpkgs.lib.nixosSystem { + modules = with self.nixosModules; [ + global + sakamoto + ]; + }; + + flake.nixosModules.sakamoto = { pkgs, config, lib, ... }: { + info = { + hostName = "sakamoto"; + stateVersion = "26.11"; + }; + + components.bootLoader = { + selection = "grub"; + timeout = 0; + }; + + features = { + shells.defaultShell = "bash"; + + applications = { + cli = { + nh.enable = true; + }; + }; + }; + }; +} \ No newline at end of file diff --git a/modules/hosts/takamaki/takamaki.nix b/modules/hosts/takamaki/takamaki.nix index 82744ee..9c21919 100644 --- a/modules/hosts/takamaki/takamaki.nix +++ b/modules/hosts/takamaki/takamaki.nix @@ -35,10 +35,7 @@ }; features = { - shells.zsh = { - enable = true; - antidote.enable = true; - }; + shells.zsh.antidote.enable = true; services = { easyeffects.enable = true; diff --git a/modules/options/audio.nix b/modules/options/audio.nix deleted file mode 100644 index 210e800..0000000 --- a/modules/options/audio.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ inputs, self, ... }: { - flake.homeModules.audioOptions = { lib, ...}: { - options.features.services.easyeffects.enable = lib.mkEnableOption "easyeffects"; - }; -} \ No newline at end of file diff --git a/modules/options/gaming.nix b/modules/options/gaming.nix deleted file mode 100644 index b9f7e97..0000000 --- a/modules/options/gaming.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ inputs, self, ... }: { - flake.nixosModules.gamingOptions = { lib, ... }: { - options.features.hardware.steam-controller.enable = lib.mkOption { - type = lib.types.bool; - default = false; - description = "Enable tweaks and configurations that assist when using Valve's Steam Controller"; - }; - }; - - flake.homeModules.gamingOptions = { lib, ... }: { - options.features.hardware.steam-controller.enable = lib.mkOption { - type = lib.types.bool; - default = false; - description = "Enable tweaks and configurations that assist when using Valve's Steam Controller"; - }; - }; -} \ No newline at end of file diff --git a/modules/options/global.nix b/modules/options/global.nix index da91efe..2a78c1d 100644 --- a/modules/options/global.nix +++ b/modules/options/global.nix @@ -1,6 +1,8 @@ { inputs, self, ... }: let - mkSharedGlobalOptions = { lib }: { - info = { + mkExtraPackagesDescription = optionName: "This option is equivalent to `${optionName}`, and exists purely for convenience."; +in { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "globalOptions" ({ lib, ... }: { + options.info = { rootPath = lib.mkOption { type = lib.types.str; description = "This option is used to tell the config the global path to the flake's root directory, in order to perform impure actions (in a Nix sense, not morally impure, I promise)."; @@ -20,80 +22,61 @@ default = ""; }; }; + })) ]; - features = { - applications = { - cli = { - color-converter.enable = lib.mkEnableOption "color-converter"; - fastfetch.enable = lib.mkEnableOption "fastfetch"; - nh.enable = lib.mkEnableOption "nh"; - }; - - extraPackages = lib.mkOption { - type = lib.types.listOf (lib.types.package); - default = []; - }; - }; - - shells = { - zsh = { - enable = lib.mkEnableOption "zsh"; - antidote.enable = lib.mkEnableOption "antidote"; - }; - }; - }; - }; - - mkExtraPackagesDescription = optionName: "This options is equivalent to `${optionName}`, and exists purely for convenience."; -in { flake.nixosModules.globalOptions = { lib, ... }: { - options = (mkSharedGlobalOptions { inherit lib; }) // { + options = { components = { - bootLoader = lib.mkOption { - type = inputs.helpers.mkEnumFromDirContents "${self}/modules/components/boot-loaders"; - description = "This option defines the bootloader that should be used, enabling any config associated with it in the process."; - default = "grub"; + bootLoader = { + selection = lib.mkOption { + type = inputs.helpers.mkEnumFromDirContents "${self}/modules/components/boot-loaders"; + description = "This option defines the bootloader that should be used, enabling any config associated with it in the process."; + default = "grub"; + }; + + timeout = lib.mkOption { + type = lib.types.int; + description = "This option defines the timeout length that the bootloader should use, which controls the wait time for keyboard input before selecting the default entry."; + default = 5; + }; + + maxGenerations = lib.mkOption { + type = lib.types.int; + description = "This option defines how many entries should be displayed in the bootloader, which can be useful when there are many NixOS generations present before garbage-collection."; + default = 10; + }; }; }; - features = (mkSharedGlobalOptions { inherit lib; }).features // { - shells = { - defaultShell = lib.mkOption { - type = inputs.helpers.mkEnumFromDirContents "${self}/modules/features/shells"; - description = "This option controls the shell that should be used as the default, enabling that shell in the process."; - default = "zsh"; - }; - } // (mkSharedGlobalOptions { inherit lib; }).features.shells; - - nixos.home-manager.enable = lib.mkEnableOption "home-manager"; - - applications = (mkSharedGlobalOptions { inherit lib; }).features.applications // { - extraPackages = (mkSharedGlobalOptions { inherit lib; }).features.applications.extraPackages // { description = mkExtraPackagesDescription "environment.systemPackages"; }; - }; + features.applications.extraPackages = lib.mkOption { + type = lib.types.listOf (lib.types.package); + description = mkExtraPackagesDescription "environment.systemPackages"; + default = []; }; }; }; flake.homeModules.globalOptions = { lib, ... }: { - options = (mkSharedGlobalOptions { inherit lib; }) // { + options = { info = { isStandalone = lib.mkOption { type = lib.types.bool; description = "This option tells the config whether this home-manager config is part of a larger NixOS config or not, and is read-only."; default = true; - readOnly = true; }; - } // (mkSharedGlobalOptions { inherit lib; }).info; + }; - features = (mkSharedGlobalOptions { inherit lib; }).features // { - applications = (mkSharedGlobalOptions { inherit lib; }).features.applications // { - shellScripts = lib.mkOption { - type = lib.types.attrsOf (lib.types.str); - description = "This option is a set of multiline strings, which are processed into executable bash scripts in `$XDG_BIN_HOME`. The shebang (`#!/bin/bash`) is added afterwards, and shouldn't be included in definitions."; - default = {}; - }; + features.applications = { + extraPackages = lib.mkOption { + type = lib.types.listOf (lib.types.package); + description = mkExtraPackagesDescription "home.packages"; + default = []; + }; - extraPackages = (mkSharedGlobalOptions { inherit lib; }).features.applications.extraPackages // { description = mkExtraPackagesDescription "home.packages"; }; + shellScripts = lib.mkOption { + type = lib.types.attrsOf (lib.types.str); + description = "This option is a set of multiline strings, which are processed into executable bash scripts in `$XDG_BIN_HOME`. The shebang (`#!/bin/bash`) is added afterwards, and shouldn't be included in definitions."; + default = {}; }; }; }; diff --git a/modules/options/graphics.nix b/modules/options/graphics.nix index d5e7b37..70e5624 100644 --- a/modules/options/graphics.nix +++ b/modules/options/graphics.nix @@ -1,82 +1,27 @@ -{ inputs, self, ... }: let - mkSharedGraphicsOptions = { pkgs, lib }: { - components = { - windowManagers = lib.mkOption { - type = inputs.helpers.mkOptionalListOfType (inputs.helpers.mkEnumFromDirContents "${self}/modules/components/window-managers"); - description = "This option defines the window manager(s) that should be installed, enabling any config associated with it in the process. It can be either a list or just one value."; - default = []; - }; - - shells = lib.mkOption { - type = inputs.helpers.mkOptionalListOfType (inputs.helpers.mkEnumFromDirContents "${self}/modules/components/shells"); - description = "This option defines the graphical shell(s) that should be installed (e.g. Noctalia, DMS), enabling any config associated with it in the process. It can be either a list or just one value."; - default = []; - }; - }; - - features = { - applications.gui = { - equibop = { - enable = lib.mkEnableOption "equibop"; - autostart = lib.mkOption { - type = lib.types.bool; - description = "This option controls whether an `equibop.desktop` file is generated and placed into `$XDG_CONFIG_HOME/autostart`."; - default = false; - }; +{ inputs, self, ... }: { + imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "graphicsOptions" ({ lib, ... }: { + options = { + components = { + windowManagers = lib.mkOption { + type = inputs.helpers.mkOptionalListOfType (inputs.helpers.mkEnumFromDirContents "${self}/modules/components/window-managers"); + description = "This option defines the window manager(s) that should be installed, enabling any config associated with it in the process. It can be either a list or just one value."; + default = []; }; - floorp.enable = lib.mkEnableOption "floorp"; - - fluxer.enable = lib.mkEnableOption "fluxer"; - fluxer-canary.enable = lib.mkEnableOption "fluxer-canary"; - - kitty.enable = lib.mkEnableOption "kitty"; - - nautilus.enable = lib.mkEnableOption "nautilus"; - - remmina.enable = lib.mkEnableOption "remmina"; - - spotify = { - enable = lib.mkEnableOption "spotify"; - spicetify = { - enable = lib.mkEnableOption "spicetify"; - theme = lib.mkOption { - type = lib.types.nullOr (lib.types.enum (builtins.attrNames inputs.spicetify.legacyPackages.${pkgs.stdenv.hostPlatform.system}.themes)); - description = "This option is used to select a theme for Spicetify to use, from the list of available packages themes."; - default = null; - }; - }; - }; - - vscode.enable = lib.mkEnableOption "vscode"; - }; - - nixos.stylix.enable = lib.mkEnableOption "stylix"; - }; - }; - - redundantOptionWarn = name: value: "The functionality of this option completely depends on `${name}` being `${value}`, and will not be evaluated otherwise."; -in { - flake.nixosModules.graphicsOptions = { pkgs, lib, ... }: { - options = (mkSharedGraphicsOptions { inherit pkgs; inherit lib; }) // { - components = (mkSharedGraphicsOptions { inherit pkgs; inherit lib; }).components // { - displayManager = lib.mkOption { - type = inputs.helpers.mkEnumFromDirContents "${self}/modules/components/display-managers"; - description = "This option defines the bootloader that should be used, enabling any config associated with it in the process."; - default = "lightdm"; + shells = lib.mkOption { + type = inputs.helpers.mkOptionalListOfType (inputs.helpers.mkEnumFromDirContents "${self}/modules/components/shells"); + description = "This option defines the graphical shell(s) that should be installed (e.g. Noctalia, DMS), enabling any config associated with it in the process. It can be either a list or just one value."; + default = []; }; }; - - features = (mkSharedGraphicsOptions { inherit pkgs; inherit lib; }).features // { - applications.gui = { - equibop.enable.description = (mkSharedGraphicsOptions { inherit pkgs; inherit lib; }).features.applications.gui.equibop.enable.description + "\n" + (redundantOptionWarn "features.nixos.home-manager.enable" "true"); - spotify.spicetify.theme.description = (mkSharedGraphicsOptions { inherit pkgs; inherit lib; }).features.applications.gui.spotify.spicetify.theme.description + "\n" + (redundantOptionWarn "features.nixos.home-manager.enable" "true"); - } // (mkSharedGraphicsOptions { inherit pkgs; inherit lib; }).features.applications.gui; - }; }; - }; + })) ]; - flake.homeModules.graphicsOptions = { pkgs, lib, ... }: { - options = mkSharedGraphicsOptions { inherit pkgs; inherit lib; }; + flake.nixosModules.graphicsOptions = { lib, ... }: { + options.components.displayManager = lib.mkOption { + type = inputs.helpers.mkEnumFromDirContents "${self}/modules/components/display-managers"; + description = "This option defines the bootloader that should be used, enabling any config associated with it in the process."; + default = "lightdm"; + }; }; } \ No newline at end of file diff --git a/modules/options/options.nix b/modules/options/options.nix deleted file mode 100644 index 80084d5..0000000 --- a/modules/options/options.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ inputs, self, ... }: { - flake.nixosModules.options = { ... }: { - imports = with self.nixosModules; [ - globalOptions - graphicsOptions - gamingOptions - ]; - }; - - flake.homeModules.options = { ... }: { - imports = with self.homeModules; [ - globalOptions - audioOptions - graphicsOptions - gamingOptions - ]; - }; -} \ No newline at end of file