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
5 changes: 5 additions & 0 deletions modules/lib/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@
github = "prescientmoon";
githubId = 39400800;
};
rachitvrma = {
name = "Rachit Kumar Verma";
github = "rachitvrma";
githubId = 155641117;
};
rasmus-kirk = {
name = "Rasmus Kirk";
email = "mail@rasmuskirk.com";
Expand Down
14 changes: 14 additions & 0 deletions modules/misc/news/2026/04/2026-04-14_14-50-21.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
_: {
time = "2026-04-14T09:20:21+00:00";
# condition = pkgs.stdenv.hostPlatform.isLinux;
# condition = config.programs.neovim.enable;
condition = true;
# if behavior changed, explain how to restore previous behavior.
message = ''
A new module is available: 'programs.dprint'.

dprint is a code formatter written in rust.
It allows formatting toml, markdown, yaml, and many other filetypes.
See https://dprint.dev/ for more.
'';
}
77 changes: 77 additions & 0 deletions modules/programs/dprint.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
pkgs,
config,
lib,
...
}:
let
inherit (lib) mkIf mkOption types;

cfg = config.programs.dprint;

jsonFormat = pkgs.formats.json { };

configJson = cfg.settings // {
plugins = map (p: "${p}/plugin.wasm") cfg.plugins;
};

hasConfig = cfg.plugins != [ ] || cfg.settings != { };
in
{
meta.maintainers = [ lib.maintainers.rachitvrma ];

options.programs.dprint = {
enable = lib.mkEnableOption ''
dprint: a code formatter for common filetypes like markdown, toml, yaml,
and many more. See https://dprint.dev/
'';

package = lib.mkPackageOption pkgs "dprint" { };

settings = mkOption {
inherit (jsonFormat) type;
default = { };
description = ''
Settings to add to {file}`$XDG_CONIFG_HOME/dprint/dprint.json`.
'';

example = lib.literalExpression ''
{
excludes = [
"**/node_modules"
"**/*-lock.json"
];
json = { };
malva = { };
markdown = { };
toml = { };
typescript = { };
yaml = { };
}
'';
};

plugins = mkOption {
type = with types; listOf package;
default = [ ];
description = ''
Plugins to add to dprint's plugin set
'';

example = lib.literalExpression ''
[
pkgs.dprint-plugins.gplane-pretty_yaml
pkgs.dprint-plugin-typescript
]
'';
};
};

config = mkIf cfg.enable {
home.packages = [ cfg.package ];

xdg.configFile."dprint/dprint.json" = mkIf hasConfig {
text = builtins.toJSON configJson;
};
};
}
Loading