aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.lock98
-rw-r--r--flake.nix34
-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
6 files changed, 189 insertions, 0 deletions
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..6de15f0
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,98 @@
+{
+ "nodes": {
+ "flake-parts": {
+ "inputs": {
+ "nixpkgs-lib": "nixpkgs-lib"
+ },
+ "locked": {
+ "lastModified": 1778716662,
+ "narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=",
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "type": "github"
+ }
+ },
+ "import-tree": {
+ "locked": {
+ "lastModified": 1778781969,
+ "narHash": "sha256-Jjuz5CmSkur8KvLDoGa+vylEp+RkQtv4mt/qcMznpH0=",
+ "owner": "denful",
+ "repo": "import-tree",
+ "rev": "d321337efd0f23a9eb14a42adb7b2c29313ab274",
+ "type": "github"
+ },
+ "original": {
+ "owner": "denful",
+ "repo": "import-tree",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1780030872,
+ "narHash": "sha256-u6WU/yd/o8iYQrHX3RAwO1hYa3LkoSL+WNQD0rJfJZQ=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "e9a7635a57597d9754eccebdfc7045e6c8600e6b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs-lib": {
+ "locked": {
+ "lastModified": 1777168982,
+ "narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=",
+ "owner": "nix-community",
+ "repo": "nixpkgs.lib",
+ "rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-community",
+ "repo": "nixpkgs.lib",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-parts": "flake-parts",
+ "import-tree": "import-tree",
+ "nixpkgs": "nixpkgs",
+ "treefmt-nix": "treefmt-nix"
+ }
+ },
+ "treefmt-nix": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1780220602,
+ "narHash": "sha256-eynAfOmbmxJnkp7YewvCEbShNnnYJ9gLLqkzsYtBPeM=",
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "rev": "db947814a175b7ca6ded66e21383d938df01c227",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..99e9192
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,34 @@
+{
+ description = "vkcku's monorepo.";
+
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
+
+ # keep-sorted start block=yes newline_separated=yes
+ flake-parts.url = "github:hercules-ci/flake-parts";
+
+ import-tree.url = "github:denful/import-tree";
+
+ treefmt-nix = {
+ url = "github:numtide/treefmt-nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ # keep-sorted end
+ };
+
+ outputs =
+ {
+ nixpkgs,
+ flake-parts,
+ import-tree,
+ ...
+ }@inputs:
+ let
+ lib = nixpkgs.lib;
+ directories = builtins.attrNames (
+ lib.attrsets.filterAttrs (_: type: type == "directory") (builtins.readDir ./.)
+ );
+ paths = map (lib.path.append ./.) directories;
+ in
+ flake-parts.lib.mkFlake { inherit inputs; } (import-tree paths);
+}
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" ];
+}