From 5344688a20505af84129c565cdd9d5f5929bb7c2 Mon Sep 17 00:00:00 2001
From: dadada <dadada@dadada.li>
Date: Wed, 31 May 2023 22:20:31 +0200
Subject: [PATCH] add more caches and nixd

---
 devshell.nix                             |  1 +
 flake.lock                               | 58 ++++++++++++++++++++++++
 flake.nix                                | 10 ++++
 home/modules/helix/config/languages.toml |  5 ++
 outputs.nix                              |  2 +
 5 files changed, 76 insertions(+)

diff --git a/devshell.nix b/devshell.nix
index ebdfb12..fd2bf2a 100644
--- a/devshell.nix
+++ b/devshell.nix
@@ -8,6 +8,7 @@
     agenix
     nixpkgs-fmt
     nixos-rebuild
+    nixd
   ];
 
   commands = [
diff --git a/flake.lock b/flake.lock
index 549f598..d3517a0 100644
--- a/flake.lock
+++ b/flake.lock
@@ -130,6 +130,24 @@
         "type": "github"
       }
     },
+    "flake-parts": {
+      "inputs": {
+        "nixpkgs-lib": "nixpkgs-lib_2"
+      },
+      "locked": {
+        "lastModified": 1683560683,
+        "narHash": "sha256-XAygPMN5Xnk/W2c1aW0jyEa6lfMDZWlQgiNtmHXytPc=",
+        "owner": "hercules-ci",
+        "repo": "flake-parts",
+        "rev": "006c75898cf814ef9497252b022e91c946ba8e17",
+        "type": "github"
+      },
+      "original": {
+        "owner": "hercules-ci",
+        "repo": "flake-parts",
+        "type": "github"
+      }
+    },
     "flake-registry": {
       "flake": false,
       "locked": {
@@ -316,6 +334,27 @@
         "type": "github"
       }
     },
+    "nixd": {
+      "inputs": {
+        "flake-parts": "flake-parts",
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1685534829,
+        "narHash": "sha256-erGWtKbSJQ0aulFYX0nPMJqub4qPnlWctnc35mdvfQI=",
+        "owner": "nix-community",
+        "repo": "nixd",
+        "rev": "8f3251fc2d8d1e3cac140e20e785ac733d76ed4a",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-community",
+        "repo": "nixd",
+        "type": "github"
+      }
+    },
     "nixlib": {
       "locked": {
         "lastModified": 1681001314,
@@ -402,6 +441,24 @@
         "type": "github"
       }
     },
+    "nixpkgs-lib_2": {
+      "locked": {
+        "dir": "lib",
+        "lastModified": 1682879489,
+        "narHash": "sha256-sASwo8gBt7JDnOOstnps90K1wxmVfyhsTPPNTGBPjjg=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "da45bf6ec7bbcc5d1e14d3795c025199f28e0de0",
+        "type": "github"
+      },
+      "original": {
+        "dir": "lib",
+        "owner": "NixOS",
+        "ref": "nixos-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
     "nixpkgs_2": {
       "locked": {
         "lastModified": 1629226339,
@@ -511,6 +568,7 @@
         "helix": "helix",
         "home-manager": "home-manager",
         "homePage": "homePage",
+        "nixd": "nixd",
         "nixos-generators": "nixos-generators",
         "nixos-hardware": "nixos-hardware",
         "nixpkgs": "nixpkgs_3",
diff --git a/flake.nix b/flake.nix
index e56834b..4560b95 100644
--- a/flake.nix
+++ b/flake.nix
@@ -32,7 +32,17 @@
       flake = false;
     };
     helix.url = "github:helix-editor/helix/23.03";
+    nixd = {
+      url = "github:nix-community/nixd";
+      inputs.nixpkgs.follows = "nixpkgs";
+    };
   };
 
   outputs = { ... } @ args: import ./outputs.nix args;
+
+  nixConfig = {
+    extra-trusted-public-keys = "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs=";
+    extra-substituters = "https://nix-community.cachix.org/ https://helix.cachix.org/";
+    extra-trusted-substituters = "https://nix-community.cachix.org/ https://helix.cachix.org/";
+  };
 }
diff --git a/home/modules/helix/config/languages.toml b/home/modules/helix/config/languages.toml
index 52e15bc..b9ed5e7 100644
--- a/home/modules/helix/config/languages.toml
+++ b/home/modules/helix/config/languages.toml
@@ -8,3 +8,8 @@ language-server = { command = "ltex-ls" }
 file-types = ["tex"]
 scope = "source.latex"
 roots = []
+
+[[language]]
+name = "nix"
+file-types = ["nix"]
+language-server = { command = "nixd" }
diff --git a/outputs.nix b/outputs.nix
index 3393da0..58812e0 100644
--- a/outputs.nix
+++ b/outputs.nix
@@ -10,6 +10,7 @@
 , agenix
 , devshell
 , helix
+, nixd
 , ...
 } @ inputs:
 (flake-utils.lib.eachDefaultSystem (system:
@@ -24,6 +25,7 @@
           overlays = [
             agenix.overlay
             devshell.overlays.default
+            (final: prev: { nixd = nixd.packages.${system}.nixd; })
           ];
         };
         extraModules = [ "${devshell}/extra/git/hooks.nix" ];