From daef51e92086a5b4d6a7756ad495dfd34353b7cb Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Wed, 26 Mar 2025 14:58:03 +0100 Subject: [PATCH] doc: format and polish Nix code according to our formatter (#1025) Link: https://github.com/danth/stylix/pull/1025 Reviewed-by: Daniel Thwaites --- docs/src/configuration.md | 11 ++- docs/src/installation.md | 96 +++++++++++++++------- docs/src/modules.md | 21 +++-- docs/src/options/platforms/home_manager.md | 8 +- docs/src/testbeds.md | 8 +- docs/src/tricks.md | 14 ++-- 6 files changed, 100 insertions(+), 58 deletions(-) diff --git a/docs/src/configuration.md b/docs/src/configuration.md index ba121c5a..c55bcfa7 100644 --- a/docs/src/configuration.md +++ b/docs/src/configuration.md @@ -206,16 +206,19 @@ extension of it. For example: ```nix -{ inputs, config, pkgs, ... }: +{ + inputs, + config, + pkgs, + ... +}: let inherit (pkgs.stdenv.hostPlatform) system; nixvim-package = inputs.nixvim-config.packages.${system}.default; extended-nixvim = nixvim-package.extend config.lib.stylix.nixvim.config; in { - environment.systemPackages = [ - extended-nixvim - ]; + environment.systemPackages = [ extended-nixvim ]; } ``` diff --git a/docs/src/installation.md b/docs/src/installation.md index 0ca42e04..dcbf286e 100644 --- a/docs/src/installation.md +++ b/docs/src/installation.md @@ -13,12 +13,17 @@ screens, and display managers. stylix.url = "github:danth/stylix"; }; - outputs = { nixpkgs, stylix, ... }: { - nixosConfigurations."«hostname»" = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ stylix.nixosModules.stylix ./configuration.nix ]; + outputs = + { nixpkgs, stylix, ... }: + { + nixosConfigurations."«hostname»" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + stylix.nixosModules.stylix + ./configuration.nix + ]; + }; }; - }; } ``` Minimal `flake.nix` for a NixOS configuration. @@ -64,12 +69,21 @@ to NixOS via [Flakes][nix-flakes]. stylix.url = "github:danth/stylix"; }; - outputs = { darwin, nixpkgs, stylix, ... }: { - darwinConfigurations."«hostname»" = darwin.lib.darwinSystem { - system = "aarch64-darwin"; - modules = [ stylix.darwinModules.stylix ./configuration.nix ]; + outputs = + { + darwin, + stylix, + ... + }: + { + darwinConfigurations."«hostname»" = darwin.lib.darwinSystem { + system = "aarch64-darwin"; + modules = [ + stylix.darwinModules.stylix + ./configuration.nix + ]; + }; }; - }; } ``` Minimal `flake.nix` for a nix-darwin configuration. @@ -95,12 +109,22 @@ a similar fashion to NixOS via [Flakes][nix-flakes]. stylix.url = "github:danth/stylix"; }; - outputs = { nix-on-droid, nixpkgs, stylix, ... }: { - nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration { - pkgs = nixpkgs.legacyPackages."aarch64-linux"; - modules = [ stylix.nixOnDroidModules.stylix ./nix-on-droid.nix ]; + outputs = + { + nix-on-droid, + nixpkgs, + stylix, + ... + }: + { + nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration { + pkgs = nixpkgs.legacyPackages."aarch64-linux"; + modules = [ + stylix.nixOnDroidModules.stylix + ./nix-on-droid.nix + ]; + }; }; - }; } ``` Minimal `flake.nix` for a Nix-on-Droid configuration. @@ -127,12 +151,22 @@ is managed by someone else. stylix.url = "github:danth/stylix"; }; - outputs = { nixpkgs, home-manager, stylix, ... }: { - homeConfigurations."«username»" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; - modules = [ stylix.homeManagerModules.stylix ./home.nix ]; + outputs = + { + nixpkgs, + home-manager, + stylix, + ... + }: + { + homeConfigurations."«username»" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.x86_64-linux; + modules = [ + stylix.homeManagerModules.stylix + ./home.nix + ]; + }; }; - }; } ``` Minimal `flake.nix` for a Home Manager configuration. @@ -164,20 +198,20 @@ module as the `homeManagerModules.stylix` attribute. ```nix let stylix = pkgs.fetchFromGitHub { - owner = "danth"; - repo = "stylix"; - rev = "..."; - sha256 = "..."; + owner = "danth"; + repo = "stylix"; + rev = "..."; + sha256 = "..."; }; -in { - imports = [ (import stylix).homeManagerModules.stylix ]; +in +{ + imports = [ (import stylix).homeManagerModules.stylix ]; - stylix = { - enable = true; - image = ./wallpaper.jpg; - }; + stylix = { + enable = true; + image = ./wallpaper.jpg; + }; } - ``` Example usage of the Home Manager module without flakes. diff --git a/docs/src/modules.md b/docs/src/modules.md index c49684d2..8da82730 100644 --- a/docs/src/modules.md +++ b/docs/src/modules.md @@ -46,14 +46,15 @@ A general format for modules is shown below. ```nix { config, lib, ... }: - { options.stylix.targets.«name».enable = config.lib.stylix.mkEnableTarget "«human readable name»" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.«name».enable) { - programs.«name».backgroundColor = config.lib.stylix.colors.base00; - }; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.«name».enable) + { + programs.«name».backgroundColor = config.lib.stylix.colors.base00; + }; } ``` @@ -94,11 +95,13 @@ it as a function. This returns a derivation which builds the template. ```nix { environment.variables.MY_APPLICATION_CONFIG_FILE = - let configFile = config.lib.stylix.colors { - template = ./config.toml.mustache; - extension = ".toml"; - }; - in "${configFile}"; + let + configFile = config.lib.stylix.colors { + template = ./config.toml.mustache; + extension = ".toml"; + }; + in + "${configFile}"; } ``` diff --git a/docs/src/options/platforms/home_manager.md b/docs/src/options/platforms/home_manager.md index cb37d2e3..6790c58c 100644 --- a/docs/src/options/platforms/home_manager.md +++ b/docs/src/options/platforms/home_manager.md @@ -6,9 +6,11 @@ If you combined Home Manager with your NixOS configuration, write these options within a Home Manager section, either for all users: ```nix -home-manager.sharedModules = [{ - stylix.targets.xyz.enable = false; -}]; +home-manager.sharedModules = [ + { + stylix.targets.xyz.enable = false; + } +]; ``` Or for a specific user: diff --git a/docs/src/testbeds.md b/docs/src/testbeds.md index 03ea0a6a..5114ab58 100644 --- a/docs/src/testbeds.md +++ b/docs/src/testbeds.md @@ -27,9 +27,11 @@ Home Manager module within the NixOS module using the following format: ```nix { - home-manager.sharedModules = [{ - # Write Home Manager options here - }]; + home-manager.sharedModules = [ + { + # Write Home Manager options here + } + ]; } ``` diff --git a/docs/src/tricks.md b/docs/src/tricks.md index aef9bae0..042a2750 100644 --- a/docs/src/tricks.md +++ b/docs/src/tricks.md @@ -8,12 +8,11 @@ Here's an example Nix expression that takes an input image, applies a brightness ```nix { pkgs, ... }: - let inputImage = ./path/to/image.jpg; brightness = -30; contrast = 0; - fillColor = "black" + fillColor = "black"; in { stylix.image = pkgs.runCommand "dimmed-background.png" { } '' @@ -29,14 +28,14 @@ Similarly, you can use a template image and repaint it for the current theme. ```nix { pkgs, ... }: - let theme = "${pkgs.base16-schemes}/share/themes/catppuccin-latte.yaml"; - wallpaper = pkgs.runCommand "image.png" {} '' - COLOR=$(${pkgs.yq}/bin/yq -r .palette.base00 ${theme}) - ${pkgs.imagemagick}/bin/magick -size 1920x1080 xc:$COLOR $out + wallpaper = pkgs.runCommand "image.png" { } '' + COLOR=$(${pkgs.yq}/bin/yq -r .palette.base00 ${theme}) + ${pkgs.imagemagick}/bin/magick -size 1920x1080 xc:$COLOR $out ''; -in { +in +{ stylix = { image = wallpaper; base16Scheme = theme; @@ -48,7 +47,6 @@ Which is neatly implemented as a single function in `lib.stylix.pixel`: ```nix { pkgs, config, ... }: - { stylix = { image = config.lib.stylix.pixel "base0A";