From a39124bffc4235b31c1125a09688fd19f550cc78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20J=C3=B6rg?= Date: Sun, 31 May 2026 21:25:54 +0200 Subject: [PATCH] fix: Add formatter --- .envrc | 2 ++ by-name/sz3/default.nix | 15 +++++++-------- npins/sources.json | 13 +++++++++++++ shell.nix | 6 ++++-- tools/treefmt.nix | 22 ++++++++++++++++++++++ 5 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 .envrc create mode 100644 tools/treefmt.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..21dccbd --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +# shellcheck shell=bash +use nix diff --git a/by-name/sz3/default.nix b/by-name/sz3/default.nix index 83065aa..e347855 100644 --- a/by-name/sz3/default.nix +++ b/by-name/sz3/default.nix @@ -24,14 +24,13 @@ stdenv.mkDerivation { pkg-config ]; - buildInputs = - [ - zstd - gsl - ] - ++ lib.optionals stdenv.cc.isClang [ - llvmPackages.openmp - ]; + buildInputs = [ + zstd + gsl + ] + ++ lib.optionals stdenv.cc.isClang [ + llvmPackages.openmp + ]; cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" diff --git a/npins/sources.json b/npins/sources.json index c4e5084..ed21045 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -5,6 +5,19 @@ "name": "nixos-unstable", "url": "https://releases.nixos.org/nixos/unstable/nixos-26.05pre1004030.64c08a7ca051/nixexprs.tar.xz", "hash": "sha256-NpH8iEQ5JHv/BtUuzTEXUMDxPLetCDzIv4OxL8H7Kps=" + }, + "treefmt-nix": { + "type": "Git", + "repository": { + "type": "GitHub", + "owner": "numtide", + "repo": "treefmt-nix" + }, + "branch": "main", + "submodules": false, + "revision": "db947814a175b7ca6ded66e21383d938df01c227", + "url": "https://github.com/numtide/treefmt-nix/archive/db947814a175b7ca6ded66e21383d938df01c227.tar.gz", + "hash": "sha256-eynAfOmbmxJnkp7YewvCEbShNnnYJ9gLLqkzsYtBPeM=" } }, "version": 7 diff --git a/shell.nix b/shell.nix index 3339b29..5105b17 100644 --- a/shell.nix +++ b/shell.nix @@ -2,12 +2,14 @@ sources ? import ./npins, pkgs ? import sources.nixpkgs { }, }: - +let + treefmt = pkgs.callPackage ./tools/treefmt.nix { inherit sources; }; +in pkgs.mkShellNoCC { packages = [ pkgs.npins pkgs.nix-init - pkgs.nixfmt-rfc-style pkgs.nix-update + treefmt ]; } diff --git a/tools/treefmt.nix b/tools/treefmt.nix new file mode 100644 index 0000000..acbeb92 --- /dev/null +++ b/tools/treefmt.nix @@ -0,0 +1,22 @@ +{ pkgs, sources, ... }: +let + treefmt-nix = import sources.treefmt-nix; +in +treefmt-nix.mkWrapper pkgs { + projectRootFile = ".git/config"; + programs = { + nixfmt.enable = true; + deadnix.enable = true; + statix = { + enable = true; + disabled-lints = [ + "manual_inherit_from" + "repeated_keys" + ]; + }; + shellcheck.enable = true; + }; + settings.global.excludes = [ + "npins/default.nix" + ]; +}