Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/formatter-biome.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ includes = [
"*.jsonc",
"*.css",
]
options = ["check", "--write", "--no-errors-on-unmatched", "--config-path", "config.json"]
options = ["check", "--write", "--no-errors-on-unmatched"]
2 changes: 1 addition & 1 deletion examples/formatter-genemichaels.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
command = "genemichaels"
excludes = []
includes = ["*.rs"]
options = ["--config", "genemichaels.json"]
options = []
2 changes: 1 addition & 1 deletion examples/formatter-php-cs-fixer.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
command = "php-cs-fixer"
excludes = []
includes = ["*.php"]
options = ["fix", "--config", "./.php-cs-fixer.php"]
options = ["fix"]
2 changes: 1 addition & 1 deletion programs/biome.nix
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ in
cp "$json" $out
'';
in
[
l.optionals (cfg.settings != { }) [
"--config-path"
"${if cfg.validate.enable then validatedConfig else jsonFile}"
]
Expand Down
15 changes: 10 additions & 5 deletions programs/genemichaels.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
}:
let
cfg = config.programs.genemichaels;
opt = options.programs.genemichaels;
configFormat = pkgs.formats.json { };

inherit (lib)
Expand Down Expand Up @@ -123,10 +124,14 @@ in

settingsFile = mkOption {
description = "The configuration file used by `genemichaels`.";
type = types.path;
type = types.nullOr types.path;
example = lib.literalExpression ''./.genemichaels.json'';
default = configFormat.generate ".genemichaels.json" cfg.settings;
defaultText = lib.literalMD "Generated JSON file from `${showOptionParent options.programs.genemichaels.settings.max_width 1}`";
default =
let
settings = lib.filterAttrs (key: value: value != opt.settings.${key}.default) cfg.settings;
in
if settings != { } then configFormat.generate ".genemichaels.json" settings else null;
defaultText = lib.literalMD "Generated JSON file from `${showOptionParent opt.settings.max_width 1}`";
};

threadCount = mkOption {
Expand Down Expand Up @@ -166,10 +171,10 @@ in
"--thread-count"
(toString cfg.threadCount)
])
++ [
++ (optionals (cfg.settingsFile != null) [
"--config"
(toString cfg.settingsFile)
];
]);
includes = cfg.includes;
excludes = cfg.excludes;
};
Expand Down
11 changes: 4 additions & 7 deletions programs/php-cs-fixer.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@ in
options.programs.php-cs-fixer = {
configFile = lib.mkOption {
description = "Path to php-cs-fixer config file.";
type = types.oneOf [
types.str
types.path
];
default = "./.php-cs-fixer.php";
example = "./.php-cs-fixer.dist.php";
type = types.nullOr (types.pathWith { });
default = null;
example = lib.literalExpression "./.php-cs-fixer.dist.php";
};
};

config = lib.mkIf cfg.enable {
settings.formatter.php-cs-fixer = {
options = [
options = lib.optionals (cfg.configFile != null) [
"--config"
"${cfg.configFile}"
];
Expand Down
4 changes: 3 additions & 1 deletion programs/statix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ in
# statix doesn't support multiple file targets
command = pkgs.writeShellScriptBin "statix-fix" ''
for file in "$@"; do
${lib.getExe cfg.package} fix --config '${toString settingsDir}/statix.toml' "$file"
${lib.getExe cfg.package} fix ${
lib.optionalString (cfg.disabled-lints != [ ]) "--config '${settingsDir}/statix.toml'"
} "$file"
done
'';
};
Expand Down