about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--flake.lock21
-rw-r--r--flake.nix8
-rw-r--r--flake/default.nix85
3 files changed, 108 insertions, 6 deletions
diff --git a/flake.lock b/flake.lock
index c603353c..9e592f49 100644
--- a/flake.lock
+++ b/flake.lock
@@ -681,6 +681,7 @@
         "strip_js_comments": "strip_js_comments",
         "systems": "systems",
         "templates": "templates",
+        "treefmt-nix": "treefmt-nix_2",
         "user_js": "user_js",
         "video_pause": "video_pause",
         "yambar_cpu": "yambar_cpu",
@@ -879,6 +880,26 @@
         "type": "github"
       }
     },
+    "treefmt-nix_2": {
+      "inputs": {
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1708335038,
+        "narHash": "sha256-ETLZNFBVCabo7lJrpjD6cAbnE11eDOjaQnznmg/6hAE=",
+        "owner": "numtide",
+        "repo": "treefmt-nix",
+        "rev": "e504621290a1fd896631ddbc5e9c16f4366c9f65",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "treefmt-nix",
+        "type": "github"
+      }
+    },
     "user_js": {
       "flake": false,
       "locked": {
diff --git a/flake.nix b/flake.nix
index ba1b8e3a..be0376f0 100644
--- a/flake.nix
+++ b/flake.nix
@@ -245,6 +245,12 @@
       url = "github:arkenfox/user.js";
       flake = false;
     };
+    treefmt-nix = {
+      url = "github:numtide/treefmt-nix";
+      inputs = {
+        nixpkgs.follows = "nixpkgs";
+      };
+    };
   };
 
   outputs = {
@@ -263,6 +269,7 @@
     nixVim,
     # external dependencies
     user_js,
+    treefmt-nix,
     templates,
     # my binaries
     video_pause,
@@ -305,6 +312,7 @@
         lanzaboote
         # external dependencies
         
+        treefmt-nix
         user_js
         templates
         # my binaries
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;};