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
11 changes: 11 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
printWidth: 100
tabWidth: 2
semi: false
singleQuote: false

overrides:
- files: "*.md"
options:
proseWrap: always
tabWidth: 2
62 changes: 43 additions & 19 deletions dev/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions dev/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,23 @@

# CI will override `services-flake` to run checks on the latest source
services-flake.url = "github:juspay/services-flake";

treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
outputs = inputs@{ nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;

imports = [
(inputs.pre-commit-hooks-nix + /flake-module.nix)
./nix/pre-commit.nix
./nix/treefmt.nix
];
perSystem = { self', pkgs, config, ... }: {

perSystem = { pkgs, config, ... }: {
devShells.default = pkgs.mkShell {
packages = with pkgs; [
just
Expand Down
11 changes: 8 additions & 3 deletions dev/nix/pre-commit.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{ inputs, ... }:
{ lib, inputs, ... }:
{
perSystem = { pkgs, lib, ... }: {
perSystem = { self', ... }: {
pre-commit = {
check.enable = true;
settings = {
rootSrc = lib.mkForce inputs.services-flake;
hooks = {
nixpkgs-fmt.enable = true;
commitizen.enable = true;

treefmt = {
enable = true;
package = self'.packages.treefmt;
pass_filenames = false; # treefmt walks the tree itself.
};
};
};
};
Expand Down
59 changes: 59 additions & 0 deletions dev/nix/treefmt.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{ lib, inputs, ... }:
{
imports = [
inputs.treefmt-nix.flakeModule
];

perSystem =
{ config, pkgs, ... }:
let
treefmt = config.treefmt.build.wrapper;
in
{
# Define formatter as global output.
# cause it provides better options than `nix fmt ...`
packages = {
inherit treefmt;
};

treefmt = {
# Overwrite the built in check, since we need to
# run in the root of the repo.
build.check = self:
let
src = ./../..;
in
pkgs.runCommandLocal "format" { }
# Bash
''
PRJ=$TMP/project
cp -r "${src}" $PRJ && chmod -R a+w $PRJ && cd $PRJ

echo "Check formatting of all files."

"${lib.getExe treefmt}" --no-cache --fail-on-change "$@" . || {
echo "Formatting check failed: please run 'just format'."
exit 1
}
'';

# Used to find the project root
# For worktrees we need either `.git` or a file.
projectRootFile = "CHANGELOG.md";

settings.global = {
excludes = [
];
};

# Markdown, JSON, YAML, etc.
programs.prettier.enable = true;
settings.formatter.prettier.excludes = [ ];

# Nix.
programs.deadnix.enable = false;
programs.statix.enable = false;
programs.nixfmt.enable = true;
};
};
}
10 changes: 10 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
set positional-arguments
set shell := ["bash", "-cue"]

# List all the just commands
default:
@just --list
Expand All @@ -6,6 +9,13 @@ default:
changelog:
cz ch --start-rev $(git describe --tags --abbrev=0 HEAD^) --incremental

# Format treewide all files.
[group('lint')]
format *args:
cd dev && nix run \
--override-input services-flake ../. \
".#treefmt" -- "$@"

# Run example/simple
[group('example')]
ex-simple:
Expand Down
Loading