From a06c4cd93a970142bd8d120487340362aefbe385 Mon Sep 17 00:00:00 2001 From: Archit Gupta Date: Sat, 17 May 2025 23:41:46 -0700 Subject: [PATCH] Enable prettier prose-wrap by default --- API_GUIDE.md | 27 +++++++++++++-------------- README.md | 14 ++++++++------ builtinModules/builtinFormatters.nix | 4 +++- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/API_GUIDE.md b/API_GUIDE.md index 9067b8e..466389a 100644 --- a/API_GUIDE.md +++ b/API_GUIDE.md @@ -6,8 +6,8 @@ This section covers important functions available in Flakelight's lib attribute. ### mkFlake -The outputs of a flake using Flakelight are created using the `mkFlake` function. -When called directly, Flakelight invokes `mkFlake`, as follows: +The outputs of a flake using Flakelight are created using the `mkFlake` +function. When called directly, Flakelight invokes `mkFlake`, as follows: ```nix { @@ -203,8 +203,8 @@ To enable using a directory for an attrset that includes a `default` attribute, attr names can be escaped with an underscore. For example, `${nixDir}/nix/packages/_default.nix` will be loaded as `packages.default`. -Aliases for options can be set with the `nixDirAliases` option. For example, -by default `nixDirAliases.nixosConfigurations = [ "nixos" ];` is set which means +Aliases for options can be set with the `nixDirAliases` option. For example, by +default `nixDirAliases.nixosConfigurations = [ "nixos" ];` is set which means "nixos" can be used instead of "nixosConfigurations" for loading the files as described above. @@ -360,8 +360,8 @@ Types: ``` The `package` and `packages` options allow you to add packages. These are -exported in the `packages.${system}` outputs, are included in `overlays.default`, -and have build checks in `checks.${system}`. +exported in the `packages.${system}` outputs, are included in +`overlays.default`, and have build checks in `checks.${system}`. `package` can be set to a package definition, and will set `packages.default`. @@ -369,10 +369,10 @@ and have build checks in `checks.${system}`. will additionally get a `system` arg in addition to module args, to allow conditionally including package definitions depending on the system. -By default, the `packages.default` package's name (its attribute name in -the package set and overlay) is automatically determined from the derivation's -`pname`. In order to use a different attribute name from the package pname, -to set it in cases where it cannot be automatically determined, or to speed up +By default, the `packages.default` package's name (its attribute name in the +package set and overlay) is automatically determined from the derivation's +`pname`. In order to use a different attribute name from the package pname, to +set it in cases where it cannot be automatically determined, or to speed up uncached evaluation, the flakelight `pname` option can be set. To set the default package, you can set the options as follows: @@ -768,8 +768,7 @@ Types: (ModuleArgs -> (AttrsOf (Template | (ModuleArgs -> Template)))) ``` -The `template` and `templates` options allow you to set `templates` -outputs. +The `template` and `templates` options allow you to set `templates` outputs. `templates` is an attribute set to template values. @@ -1172,8 +1171,8 @@ Types: This option has options for configuring Flakelight's defaults. -`flakelight.editorconfig` can be set to false to disable the editorconfig -check that is added if editorconfig configuration is detected. +`flakelight.editorconfig` can be set to false to disable the editorconfig check +that is added if editorconfig configuration is detected. `flakelight.builtinFormatters` can be set to false to disable the default formatting configuration. diff --git a/README.md b/README.md index 2ae4914..8076c4f 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ A modular Nix flake framework for simplifying flake definitions. - Handles generating per-system attributes - Extensible using the module system - Given package definitions, generates package and overlay outputs -- Automatically import attributes from nix files in a directory (default `./nix`) +- Automatically import attributes from nix files in a directory (default + `./nix`) - Builds formatter outputs that can format multiple file types - Provides outputs/perSystem options for easy migration @@ -84,8 +85,8 @@ To use a different nixpkgs, you can instead use: ### Rust package The following is an example flake for a Rust project using `flakelight-rust`, -invoked by using `flakelight-rust`'s wrapper. -Package metadata is taken from the project's `Cargo.toml`. +invoked by using `flakelight-rust`'s wrapper. Package metadata is taken from the +project's `Cargo.toml`. ```nix { @@ -100,8 +101,8 @@ The above flake exports the following: - `packages.${system}.default` attributes for each system - `overlays.default` providing an overlay with the package (built with the applied pkg set's dependencies) -- `devShells.${system}.default` that provides `rust-analyzer`, `cargo`, `clippy`, - `rustc`, and `rustfmt` as well as sets `RUST_SRC_PATH` +- `devShells.${system}.default` that provides `rust-analyzer`, `cargo`, + `clippy`, `rustc`, and `rustfmt` as well as sets `RUST_SRC_PATH` - `checks.${system}.${check}` attributes for build, test, clippy, and formatting checks - `formatter.${system}` with additional support for formatting Rust files @@ -123,7 +124,8 @@ Equivalently, you can just import the `flakelight-rust` module as follows: See [flakelight-rust.nix][flakelight-rust] to see how you could configure it without the module. -[flakelight-rust]: https://github.com/accelbread/flakelight-rust/blob/master/flakelight-rust.nix +[flakelight-rust]: + https://github.com/accelbread/flakelight-rust/blob/master/flakelight-rust.nix ### C application diff --git a/builtinModules/builtinFormatters.nix b/builtinModules/builtinFormatters.nix index 2410583..cc39c2b 100644 --- a/builtinModules/builtinFormatters.nix +++ b/builtinModules/builtinFormatters.nix @@ -20,8 +20,10 @@ in formatters = pkgs: let nixpkgs-fmt = "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt"; + # prefer-file would be better but does not work with prose-wrap prettier = "${pkgs.nodePackages.prettier}/bin/prettier --write" - + " --cache-location=.prettiercache"; + + " --cache-location=.prettiercache" + + " --config-precedence file-override --prose-wrap always"; in { "*.nix" = mkDefault nixpkgs-fmt;