Code
Pre-requisites
You will need to have the following installed:
Important
We use a Flake-based workflow. You can certainly develop for data-mesher without Flakes and leverage
much of what is listed below, but it is left up to the reader to determine how to make that work.
We use treefmt and treefmt-nix to format the repository by running nix fmt from the root directory.
| formatter.nix |
|---|
| {
inputs,
...
}:
{
imports = [
inputs.treefmt-nix.flakeModule
];
perSystem = {
treefmt = {
projectRootFile = ".git/config";
programs = {
nixfmt.enable = true;
deadnix.enable = true;
gofumpt.enable = true;
mdformat = {
enable = true;
plugins = ps: [ ps.mdformat-gfm ];
settings = {
number = true;
wrap = 80;
};
excludes = [
"docs/**/*.md"
];
};
prettier = {
enable = true;
excludes = [
"*.md"
"*.mdx"
];
};
rustfmt.enable = true;
shellcheck.enable = true;
shfmt.enable = true;
sizelint =
let
sizelintExcludes = [ ];
in
{
enable = true;
settings = {
excludes = sizelintExcludes;
max_file_size = "100kb";
rules.default.description = "File exceeds the maximum allowed size";
rules.default.suggestion = "Add the file to 'sizelintExcludes' in nix/formatter.nix";
};
};
statix.enable = true;
};
settings = {
global.excludes = [
"LICENSE"
".adr-dir"
# unsupported extensions
"*.{gif,png,svg,tape,mts,lock,mod,sum,toml,env,envrc,gitignore,sql,conf,pem,*.so.2,key,pub,py,narHash}"
"data-mesher/test/networks/*"
"nss-datamesher/test/dns.json"
];
formatter = {
deadnix = {
priority = 1;
};
statix = {
priority = 2;
};
nixfmt = {
priority = 3;
};
prettier = {
options = [
"--tab-width"
"4"
];
};
};
};
};
};
}
|
Checks
Running nix flake check will build all the devshells and Nix packages, as well as check the formatting with treefmt
and any other Flake checks that have been configured.
Documentation
When making changes, it is important to add or update any relevant sections in the documentation within the same
pull request.
For more information see the next section.