about summary refs log tree commit diff stats
path: root/flake/default.nix
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2024-02-20 15:34:03 +0100
committerSoispha <soispha@vhack.eu>2024-02-20 15:49:47 +0100
commit7d7bb4838feba557fc4f8ad022f734d7db273943 (patch)
tree1d2ead8241a7e292d89bfb7d0f74e9f26edefbe4 /flake/default.nix
parentfix(hm/conf/nix/plgs/lsp/s/openscad): GNU is unfortunately not the best format (diff)
downloadnixos-config-7d7bb4838feba557fc4f8ad022f734d7db273943.tar.gz
nixos-config-7d7bb4838feba557fc4f8ad022f734d7db273943.zip
build(flake): Add treefmt
Diffstat (limited to 'flake/default.nix')
-rw-r--r--flake/default.nix85
1 files changed, 79 insertions, 6 deletions
diff --git a/flake/default.nix b/flake/default.nix
index 00d11f89..4e166b8a 100644
--- a/flake/default.nix
+++ b/flake/default.nix
@@ -17,6 +17,7 @@
   lanzaboote,
   # external dependencies
   user_js,
+  treefmt-nix,
   templates,
   # my binaries
   video_pause,
@@ -33,10 +34,10 @@
       pkgs
       sysLib
       # extra information
-      
+
       system
       # bins
-      
+
       video_pause
       yambar_cpu
       yambar_memory
@@ -45,10 +46,10 @@
       river_init_lesser
       shell_library
       # external deps
-      
+
       user_js
       # modules
-      
+
       impermanence
       nixVim
       ;
@@ -74,11 +75,74 @@
       serverphone
       system
       # nix registry
-      
+
       nixpkgs_as_input
       self
       ;
   };
+  treefmtEval = treefmt-nix.lib.evalModule pkgs (
+    {pkgs, ...}: {
+      # Used to find the project root
+      projectRootFile = "flake.nix";
+
+      programs = {
+        alejandra.enable = true;
+        rustfmt.enable = true;
+        clang-format.enable = true;
+        mdformat.enable = true;
+        shfmt = {
+          enable = true;
+          indent_size = 4;
+        };
+        shellcheck.enable = true;
+        prettier = {
+          settings = {
+            arrowParens = "always";
+            bracketSameLine = false;
+            bracketSpacing = true;
+            editorconfig = true;
+            embeddedLanguageFormatting = "auto";
+            endOfLine = "lf";
+            # experimentalTernaries = false;
+            htmlWhitespaceSensitivity = "css";
+            insertPragma = false;
+            jsxSingleQuote = true;
+            printWidth = 80;
+            proseWrap = "always";
+            quoteProps = "consistent";
+            requirePragma = false;
+            semi = true;
+            singleAttributePerLine = true;
+            singleQuote = true;
+            trailingComma = "all";
+            useTabs = false;
+            vueIndentScriptAndStyle = false;
+
+            tabWidth = 4;
+            overrides = {
+              files = ["*.js"];
+              options.tabwidth = 2;
+            };
+          };
+        };
+        stylua.enable = true;
+        ruff = {
+          enable = true;
+          format = true;
+        };
+        taplo.enable = true;
+      };
+
+      settings.formatter = {
+        clang-format = {
+          options = ["--style" "GNU"];
+        };
+        shfmt = {
+          includes = ["*.bash"];
+        };
+      };
+    }
+  );
 in {
   nixosConfigurations = import ./nixosConfigurations {
     inherit
@@ -86,12 +150,20 @@ in {
       pkgs
       nixpkgs_as_input
       # configs
-      
+
       defaultModules
       defaultSpecialArgs
       ;
   };
   inherit pkgs;
+  checks."${system}" = {
+    inherit
+      (self.packages."${system}")
+      nvim
+      ;
+    formatting = treefmtEval.config.build.check self;
+  };
+
   packages."${system}" = import ./packages {
     inherit
       nixos-generators
@@ -106,6 +178,7 @@ in {
       ;
     inherit (pkgs) lib;
   };
+  formatter."${system}" = treefmtEval.config.build.wrapper;
 
   apps."${system}" = import ./apps {inherit self system;};