Skip to content

Commit b77cf8a

Browse files
committed
fix(genemichaels): remove default values from config file, don't include if empty
1 parent c6d459f commit b77cf8a

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

examples/formatter-genemichaels.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
command = "genemichaels"
44
excludes = []
55
includes = ["*.rs"]
6-
options = ["--config", "genemichaels.json"]
6+
options = []

programs/genemichaels.nix

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
}:
88
let
99
cfg = config.programs.genemichaels;
10+
opt = options.programs.genemichaels;
1011
configFormat = pkgs.formats.json { };
1112

1213
inherit (lib)
@@ -123,10 +124,14 @@ in
123124

124125
settingsFile = mkOption {
125126
description = "The configuration file used by `genemichaels`.";
126-
type = types.path;
127+
type = types.nullOr types.path;
127128
example = lib.literalExpression ''./.genemichaels.json'';
128-
default = configFormat.generate ".genemichaels.json" cfg.settings;
129-
defaultText = lib.literalMD "Generated JSON file from `${showOptionParent options.programs.genemichaels.settings.max_width 1}`";
129+
default =
130+
let
131+
settings = lib.filterAttrs (key: value: value != opt.settings.${key}.default) cfg.settings;
132+
in
133+
if settings != { } then configFormat.generate ".genemichaels.json" settings else null;
134+
defaultText = lib.literalMD "Generated JSON file from `${showOptionParent opt.settings.max_width 1}`";
130135
};
131136

132137
threadCount = mkOption {
@@ -166,10 +171,10 @@ in
166171
"--thread-count"
167172
(toString cfg.threadCount)
168173
])
169-
++ [
174+
++ (optionals (cfg.settingsFile != null) [
170175
"--config"
171176
(toString cfg.settingsFile)
172-
];
177+
]);
173178
includes = cfg.includes;
174179
excludes = cfg.excludes;
175180
};

0 commit comments

Comments
 (0)