feat(wrapperModules.dprint): init#432
Conversation
add: Dprint is a code formatter built in rust. More detail in https://dprint.dev/
|
|
||
| config = { | ||
| package = lib.mkDefault pkgs.dprint; | ||
|
|
There was a problem hiding this comment.
How is the package actually learning about our config file?
We constructed it. But I don't see us doing anything with it?
There was a problem hiding this comment.
My bad. Fixed now.
initially missing `--config` flag
|
Sorry, failed to run check first. |
|
https://dprint.dev/cli/#using-a-custom-config-file-path-or-url They have some kind of warning, and some resolution variable. Maybe we should make some kind of enum option for this other variable, and/or make setting I need to sleep but, look into that, otherwise seems like a good thing to wrap, could be quite useful for dev shells and stuff, and it doesnt write to its config file, so that should be all that is needed. |
{
wlib,
pkgs,
config,
lib,
...
}:
let
jsonFormat = pkgs.formats.json { };
configJson = config.settings // {
plugins = map (p: "${p}/plugin.wasm") config.plugins;
};
in
{
imports = [ wlib.modules.default ];
options = {
settings = lib.mkOption {
inherit (jsonFormat) type;
default = { };
description = ''
Settings to add to dprint.json.
'';
example = {
excludes = [
"**/node_modules"
"**/*-lock.json"
];
json = { };
malva = { };
markdown = { };
toml = { };
typescript = { };
yaml = { };
};
};
plugins = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ ];
description = ''
Plugins to add to dprint runtime.
'';
example = lib.literalExpression ''
plugins = with pkgs.dprint-plugins; [
g-plane-pretty_yaml
dprint-plugin-typescript
dprint-plugin-json
dprint-plugin-markdown
dprint-plugin-toml
g-plane-malva
];
'';
};
};
config = {
package = lib.mkDefault pkgs.dprint;
constructFiles.generatedConfig = {
relPath = "${config.binName}-config/${config.binName}-config.json";
content = builtins.toJSON configJson;
};
env.DPRINT_CONIFG_DIR = "${placeholder "out"}/${config.binName}-config";
# flags = {
# "--config" = config.constructFiles.generatedConfig.path;
# };
meta.maintainers = [ wlib.maintainers.rachitvrma ];
};
}We can have something like this. |
env.DPRINT_CONIFG_DIR = "${placeholder "out"}/${config.binName}-config";Is there something better about using this variable over Also you might enjoy setting it this way? env.DPRINT_CONIFG_DIR = dirOf config.constructFiles.generatedConfig.path;Does this just make it replace the normal global config dir with this one and otherwise still behave like normal, whereas |
|
IDK. The article just states that it is a "better experience" to not use the Other than that it also gives the flag to disable config discovery. So maybe we can use either the Should we use the |
|
Ummm, unsure. I would need to test to see how it behaves with the env var vs the arg. If it just pretends the env var is the normal global location, that is ideal for us. If it does something weird, then whatever just use I am not sure what the best default for that resolution arg is, but we definitely should have a |
|
like you mean give users the option to choose to either use the |
|
No i mean actually try If it turns out that If it is not treated in that way, and it is treated in the same manner as If Otherwise, we would just use |
|
Okay. I'll try it out. |
add: Dprint is a code formatter built in rust. More detail in https://dprint.dev/