From c96bd537d588ca7af9165b1cfc0e105b69e81fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Mon, 15 Jan 2024 12:42:01 +0100 Subject: [PATCH] fix: Many many infinite recursion errors --- docs/default.nix | 2 +- flake.nix | 5 ++- {module => nixos}/default.nix | 14 +++--- {module => nixos}/gui/default.nix | 6 +-- nixos/options.nix | 66 +++++++++++++++++++++++++++++ {module => nixos}/stylix-config.nix | 21 ++++----- options.nix | 62 --------------------------- 7 files changed, 93 insertions(+), 83 deletions(-) rename {module => nixos}/default.nix (82%) rename {module => nixos}/gui/default.nix (93%) create mode 100644 nixos/options.nix rename {module => nixos}/stylix-config.nix (53%) delete mode 100644 options.nix diff --git a/docs/default.nix b/docs/default.nix index 5b3b0bd..78b6bd8 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -1,6 +1,6 @@ { pkgs, lib, ... }: let - eval = lib.evalModules { modules = [ ../options.nix ]; }; + eval = lib.evalModules { modules = [ ../nixos/options.nix ]; }; doc = (pkgs.nixosOptionsDoc { inherit (eval) options; }).optionsCommonMark; in pkgs.stdenvNoCC.mkDerivation { diff --git a/flake.nix b/flake.nix index c5ae810..0c9fc98 100644 --- a/flake.nix +++ b/flake.nix @@ -7,9 +7,12 @@ inputs.stylix.url = "https://flakehub.com/f/danth/stylix/0.1.282.tar.gz"; inputs.stylix.inputs.nixpkgs.follows = "nixpkgs"; inputs.stylix.inputs.home-manager.follows = "home-manager"; + inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz"; + inputs.home-manager.url = "https://flakehub.com/f/nix-community/home-manager/0.1.*.tar.gz"; inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/*.tar.gz"; # Flake outputs that other flakes can use @@ -33,7 +36,7 @@ nixosModules = rec { default = nixosModule; - nixosModule = import ./module { inherit stylix; }; + nixosModule = import ./nixos { inherit stylix; }; }; }; } diff --git a/module/default.nix b/nixos/default.nix similarity index 82% rename from module/default.nix rename to nixos/default.nix index f0254fa..01a6b1a 100644 --- a/module/default.nix +++ b/nixos/default.nix @@ -3,13 +3,15 @@ let cfg = config.jconfig; in { - imports = [ ./gui ] ++ lib.optional (cfg.enable && cfg.styling.enable) stylix.nixosModules.stylix; + imports = [ + ./options.nix + ./gui + stylix.nixosModules.stylix + ]; - options = import ../options.nix; - - config = lib.optionalAttrs cfg.enable { + config = lib.mkIf cfg.enable { boot.plymouth.enable = cfg.styling.enable; - stylix = lib.optionalAttrs cfg.styling.enable (import ./stylix-config.nix); + stylix = lib.mkIf cfg.styling.enable (import ./stylix-config.nix { inherit config pkgs; }); # Enable unlocking the gpg-agent at boot (configured through home.nix) security.pam.services.login.gnupg.enable = true; @@ -32,7 +34,7 @@ in # Shell prompt programs.starship.enable = true; - programs.starship.settings = lib.optionalAttrs cfg.styling.enable { + programs.starship.settings = lib.mkIf cfg.styling.enable { format = "$time$all"; add_newline = false; cmd_duration.min_time = 500; diff --git a/module/gui/default.nix b/nixos/gui/default.nix similarity index 93% rename from module/gui/default.nix rename to nixos/gui/default.nix index d00c5d9..befda04 100644 --- a/module/gui/default.nix +++ b/nixos/gui/default.nix @@ -3,7 +3,7 @@ let cfg = config.jconfig.gui; in { - config = lib.optionalAttrs (config.jconfig.enable && cfg.enable) + config = lib.mkIf (config.jconfig.enable && cfg.enable) { environment.systemPackages = [ pkgs.gnome.adwaita-icon-theme @@ -12,7 +12,7 @@ in pkgs.pinentry-qt ] ++ lib.optional cfg.ydotool.enable pkgs.ydotool; - systemd.user.services.ydotool = lib.optionalAttrs cfg.ydotool.enable { + systemd.user.services.ydotool = lib.mkIf cfg.ydotool.enable { enable = cfg.ydotool.autoStart; wantedBy = [ "default.target" ]; description = "Generic command-line automation tool"; @@ -56,7 +56,7 @@ in hardware.opengl.enable = true; hardware.uinput.enable = true; hardware.steam-hardware.enable = cfg.steamHardwareSupport; - } // lib.optionalAttrs cfg."8bitdoFix" { + } // lib.mkIf cfg."8bitdoFix" { # Udev rules to start or stop systemd service when controller is connected or disconnected services.udev.extraRules = '' # May vary depending on your controller model, find product id using 'lsusb' diff --git a/nixos/options.nix b/nixos/options.nix new file mode 100644 index 0000000..53f1895 --- /dev/null +++ b/nixos/options.nix @@ -0,0 +1,66 @@ +{ lib, ... }: +let + inherit (lib) types; + # Like mkEnableOption but defaults to true + mkDisableOption = option: lib.mkOption { + description = lib.mdDoc "Whether to enable ${option}."; + type = types.bool; + default = true; + example = false; + }; + + gui.options = { + enable = lib.mkEnableOption "jalil's default gui configuration."; + # Fix for using Xinput mode on 8bitdo Ultimate C controller + # Inspired by https://aur.archlinux.org/packages/8bitdo-ultimate-controller-udev + # Adapted from: https://gist.github.com/interdependence/28452fbfbe692986934fbe1e54c920d4 + "8bitdoFix" = mkDisableOption "a fix for 8bitdo controllers"; + steamHardwareSupport = mkDisableOption "steam hardware support"; + ydotool = lib.mkOption { + description = lib.mdDoc "Jalil's default ydotool configuration."; + type = types.submodule { + options.enable = mkDisableOption "ydotool"; + options.autoStart = mkDisableOption "autostarting ydotool at login"; + }; + }; + }; + + styling.options = { + enable = mkDisableOption "jalil's default styling"; + wallpaper = lib.mkOption { + description = "The wallpaper to use."; + type = types.str; + default = builtins.fetchurl { + url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png"; + sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc"; + }; + }; + bootLogo = lib.mkOption { + description = "The logo used by plymouth at boot."; + type = types.str; + # http://xenia-linux-site.glitch.me/images/cathodegaytube-splash.png + default = builtins.fetchurl { + url = "https://efimero.github.io/xenia-images/cathodegaytube-splash.png"; + sha256 = "qKugUfdRNvMwSNah+YmMepY3Nj6mWlKFh7jlGlAQDo8="; + }; + }; + }; + + config.options = { + enable = lib.mkEnableOption "jalil's default configuration."; + gui = lib.mkOption { + description = lib.mdDoc "Jalil's default configuration for a NixOS gui."; + type = types.submodule gui; + }; + styling = lib.mkOption { + description = "Jalil's styling options"; + type = types.submodule styling; + }; + }; +in +{ + options.jconfig = lib.mkOption { + description = lib.mdDoc "Jalil's default NixOS configuration."; + type = types.submodule config; + }; +} diff --git a/module/stylix-config.nix b/nixos/stylix-config.nix similarity index 53% rename from module/stylix-config.nix rename to nixos/stylix-config.nix index 7411910..779bb57 100644 --- a/module/stylix-config.nix +++ b/nixos/stylix-config.nix @@ -1,13 +1,14 @@ -{ config, pkgs, ... }: +{ config, pkgs }: let - cfg = config.jconfig.gui.styling; - nerdFontSymbols = pkgs.nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; }; - fallbackSymbols = { - name = "Symbols Nerd Font"; - package = nerdFontSymbols; - }; + cfg = config.jconfig.styling; + # nerdFontSymbols = pkgs.nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; }; + # fallbackSymbols = { + # name = "Symbols Nerd Font"; + # package = nerdFontSymbols; + # }; in { + autoEnable = cfg.enable; image = cfg.wallpaper; base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml"; polarity = "dark"; @@ -17,9 +18,9 @@ in fonts.sansSerif.package = pkgs.noto-fonts; fonts.serif.name = "Noto Serif"; fonts.serif.package = pkgs.noto-fonts; - fonts.fallbackFonts.monospace = [ fallbackSymbols ]; - fonts.fallbackFonts.sansSerif = [ fallbackSymbols ]; - fonts.fallbackFonts.serif = [ fallbackSymbols ]; + # fonts.fallbackFonts.monospace = [ fallbackSymbols ]; + # fonts.fallbackFonts.sansSerif = [ fallbackSymbols ]; + # fonts.fallbackFonts.serif = [ fallbackSymbols ]; fonts.sizes.popups = 12; targets.plymouth.logoAnimated = false; targets.plymouth.logo = cfg.bootLogo; diff --git a/options.nix b/options.nix deleted file mode 100644 index 7b9f58c..0000000 --- a/options.nix +++ /dev/null @@ -1,62 +0,0 @@ -{ lib, ... }: -let - inherit (lib) types; - # Like mkEnableOption but defaults to true - mkDisableOption = option: lib.mkOption { - description = lib.mdDoc "Whether to enable ${option}."; - type = types.bool; - default = true; - example = false; - }; -in -{ - options.jconfig = lib.mkOption { - description = lib.mdDoc "Jalil's default NixOS configuration."; - type = types.submodule { - options = { - enable = lib.mkEnableOption "jalil's default configuration."; - gui = lib.mkOption { - description = lib.mdDoc "Jalil's default configuration for a NixOS gui."; - type = types.submodule { - options.enable = lib.mkEnableOption "jalil's default gui configuration."; - # Fix for using Xinput mode on 8bitdo Ultimate C controller - # Inspired by https://aur.archlinux.org/packages/8bitdo-ultimate-controller-udev - # Adapted from: https://gist.github.com/interdependence/28452fbfbe692986934fbe1e54c920d4 - options."8bitdoFix" = mkDisableOption "a fix for 8bitdo controllers"; - options.steamHardwareSupport = mkDisableOption "steam hardware support"; - options.ydotool = lib.mkOption { - description = lib.mdDoc "Jalil's default ydotool configuration."; - type = types.submodule { - options.enable = mkDisableOption "ydotool"; - options.autoStart = mkDisableOption "autostarting ydotool at login"; - }; - }; - }; - }; - styling = lib.mkOption { - description = "Jalil's styling options"; - type = types.submodule { - options.enable = mkDisableOption "jalil's default styling"; - options.wallpaper = lib.mkOption { - description = "The wallpaper to use."; - type = types.str; - default = builtins.fetchurl { - url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png"; - sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc"; - }; - }; - options.bootLogo = lib.mkOption { - description = "The logo used by plymouth at boot."; - type = types.str; - # http://xenia-linux-site.glitch.me/images/cathodegaytube-splash.png - default = builtins.fetchurl { - url = "https://efimero.github.io/xenia-images/cathodegaytube-splash.png"; - sha256 = "qKugUfdRNvMwSNah+YmMepY3Nj6mWlKFh7jlGlAQDo8="; - }; - }; - }; - }; - }; - }; - }; -}