aboutsummaryrefslogtreecommitdiff
path: root/root
diff options
context:
space:
mode:
authorvkcku <[email protected]>2026-06-01 08:21:20 +0530
committervkcku <[email protected]>2026-06-01 08:21:20 +0530
commitb911adccfdf598d7130ca017e677f5b58f476299 (patch)
treee6f3d56e088ef1e7b2b48fa06729d3698ffb9f9e /root
parentroot: initial commit (diff)
root: setup nix
monorepo-revid: f83eede55beb9a636ce34eead83d4d5fce288b51
Diffstat (limited to 'root')
-rw-r--r--root/nix/_treefmt-base.nix17
-rw-r--r--root/nix/_treefmt.nix7
-rw-r--r--root/nix/devshell.nix30
-rw-r--r--root/nix/systems.nix3
4 files changed, 57 insertions, 0 deletions
diff --git a/root/nix/_treefmt-base.nix b/root/nix/_treefmt-base.nix
new file mode 100644
index 0000000..d613092
--- /dev/null
+++ b/root/nix/_treefmt-base.nix
@@ -0,0 +1,17 @@
+/**
+ The base treefmt configuration that all projects should import
+ from. This will include a consistent configuration for most, if not all,
+ formatters/linters. This will NOT enable the formatters/linters except
+ for a few that are used across all projects (nixfmt, typos etc.).
+*/
+{
+ projectRootFile = "README.md";
+
+ programs = {
+ # keep-sorted start block=yes
+ keep-sorted.enable = true;
+ nixfmt.enable = true;
+ typos.enable = true;
+ # keep-sorted end
+ };
+}
diff --git a/root/nix/_treefmt.nix b/root/nix/_treefmt.nix
new file mode 100644
index 0000000..8cd6d6d
--- /dev/null
+++ b/root/nix/_treefmt.nix
@@ -0,0 +1,7 @@
+{ treefmt-nix, pkgs, ... }:
+let
+ conf = {
+ imports = [ ./_treefmt-base.nix ];
+ };
+in
+treefmt-nix.lib.mkWrapper pkgs conf
diff --git a/root/nix/devshell.nix b/root/nix/devshell.nix
new file mode 100644
index 0000000..6c1dc29
--- /dev/null
+++ b/root/nix/devshell.nix
@@ -0,0 +1,30 @@
+{ inputs, self, ... }:
+{
+ perSystem =
+ { pkgs, system, ... }:
+ {
+ devShells.common = pkgs.mkShellNoCC {
+ name = "common";
+
+ packages = [
+ pkgs.nixd
+ ];
+ };
+
+ devShells.root =
+ let
+ treefmt = pkgs.callPackage ./_treefmt.nix { treefmt-nix = inputs.treefmt-nix; };
+ in
+ pkgs.mkShellNoCC {
+ name = "root";
+
+ inputsFrom = [ self.devShells."${system}".common ];
+ packages = [
+ treefmt
+ ];
+ shellHook = ''
+ export TREEFMT_WORKING_DIR="$("${pkgs.git}/bin/git" rev-parse --show-toplevel)"
+ '';
+ };
+ };
+}
diff --git a/root/nix/systems.nix b/root/nix/systems.nix
new file mode 100644
index 0000000..ce708c6
--- /dev/null
+++ b/root/nix/systems.nix
@@ -0,0 +1,3 @@
+{
+ systems = [ "x86_64-linux" ];
+}