4
4
cfg = config ;
5
5
inherit ( lib ) flatten mapAttrs mapAttrsToList mkDefault mkOption mkRemovedOptionModule mkRenamedOptionModule types ;
6
6
7
+ toml = pkgs . formats . toml { } ;
8
+
7
9
cargoManifestPathArg =
8
10
lib . optionalString
9
11
( settings . rust . cargoManifestPath != null )
@@ -1797,19 +1799,14 @@ in
1797
1799
} ;
1798
1800
configuration =
1799
1801
mkOption {
1800
- type = types . str ;
1801
- description = "Multiline-string configuration passed as config file. If set, config set in `typos.settings.configPath` gets ignored." ;
1802
- default = "" ;
1803
- example = ''
1804
- [files]
1805
- ignore-dot = true
1806
-
1807
- [default]
1808
- binary = false
1809
-
1810
- [type.py]
1811
- extend-glob = []
1812
- '' ;
1802
+ type = toml . type ;
1803
+ description = "Configuration passed as config file. If set, config set in `typos.settings.configPath` gets ignored." ;
1804
+ default = { } ;
1805
+ example = {
1806
+ files . ignore-dot = true ;
1807
+ default . binary = false ;
1808
+ type . py . extend-glob = [ ] ;
1809
+ } ;
1813
1810
} ;
1814
1811
1815
1812
configPath =
@@ -3988,16 +3985,15 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.fourm
3988
3985
package = tools . typos ;
3989
3986
entry =
3990
3987
let
3991
- # Concatenate config in config file with section for ignoring words generated from list of words to ignore
3992
- configuration = "${ hooks . typos . settings . configuration } " + lib . strings . optionalString ( hooks . typos . settings . ignored-words != [ ] ) "\n \[ default.extend-words\] " + lib . strings . concatMapStrings ( x : "\n ${ x } = \" ${ x } \" " ) hooks . typos . settings . ignored-words ;
3993
- configFile = builtins . toFile "typos-config.toml" configuration ;
3988
+ inherit ( hooks . typos . settings ) configuration ;
3989
+ configFile = toml . generate "typos-config.toml" configuration ;
3994
3990
cmdArgs =
3995
3991
mkCmdArgs
3996
3992
( with hooks . typos . settings ; [
3997
3993
[ binary "--binary" ]
3998
3994
[ ( color != "auto" ) "--color ${ color } " ]
3999
- [ ( configuration != "" ) "--config ${ configFile } " ]
4000
- [ ( configPath != "" && configuration == "" ) "--config ${ configPath } " ]
3995
+ [ true "--config ${ configFile } " ]
3996
+ [ ( configPath != "" && configuration == { } ) "--config ${ configPath } " ]
4001
3997
[ diff "--diff" ]
4002
3998
[ ( exclude != "" ) "--exclude ${ exclude } --force-exclude" ]
4003
3999
[ ( format != "long" ) "--format ${ format } " ]
@@ -4012,6 +4008,9 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.fourm
4012
4008
] ) ;
4013
4009
in
4014
4010
"${ hooks . typos . package } /bin/typos ${ cmdArgs } " ;
4011
+ settings . configuration = {
4012
+ default . extend-words = lib . genAttrs hooks . typos . settings . ignored-words lib . id ;
4013
+ } ;
4015
4014
types = [ "text" ] ;
4016
4015
} ;
4017
4016
typstfmt = {
0 commit comments