From 64713b0e1870d15a71192393aee6c6f0415b61c0 Mon Sep 17 00:00:00 2001 From: Elias Ainsworth Date: Sun, 10 Nov 2024 22:17:10 -0700 Subject: [PATCH] Add nixd to flake.nix and legacyPackages.nix. --- flake.lock | 96 ++++++++++++++++++++++++ flake.nix | 155 +++++++++++++++++++++------------------ flake/legacyPackages.nix | 36 +++++---- 3 files changed, 200 insertions(+), 87 deletions(-) diff --git a/flake.lock b/flake.lock index 0881cae72..8f9a7b2de 100644 --- a/flake.lock +++ b/flake.lock @@ -18,6 +18,39 @@ "type": "github" } }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_2" + }, + "locked": { + "lastModified": 1714606777, + "narHash": "sha256-bMkNmAXLj8iyTvxaaD/StcLSadbj1chPcJOjtuVnLmA=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "4d34ce6412bc450b1d4208c953dc97c7fc764f1a", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-root": { + "locked": { + "lastModified": 1713493429, + "narHash": "sha256-ztz8JQkI08tjKnsTpfLqzWoKFQF4JGu2LRz8bkdnYUk=", + "owner": "srid", + "repo": "flake-root", + "rev": "bc748b93b86ee76e2032eecda33440ceb2532fcd", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "flake-root", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -96,6 +129,29 @@ "type": "github" } }, + "nixd": { + "inputs": { + "flake-parts": "flake-parts_2", + "flake-root": "flake-root", + "nixpkgs": [ + "nixpkgs" + ], + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1731087557, + "narHash": "sha256-W70xy7WFqA5940zhodAsGiC/nvqGwZ07YE34ObMK/po=", + "owner": "nix-community", + "repo": "nixd", + "rev": "1cf9ec0a82bcac57c7c12b6378bd8c28513cd3a6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixd", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1726871744, @@ -124,6 +180,24 @@ "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz" } }, + "nixpkgs-lib_2": { + "locked": { + "dir": "lib", + "lastModified": 1714253743, + "narHash": "sha256-mdTQw2XlariysyScCv2tTE45QSU9v/ezLcHJ22f0Nxc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "58a1abdbae3217ca6b702f03d3b35125d88a2994", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1656753965, @@ -1815,6 +1889,7 @@ "flake-utils": "flake-utils", "mnw": "mnw", "nil": "nil", + "nixd": "nixd", "nixpkgs": "nixpkgs", "nmd": "nmd", "plugin-alpha-nvim": "plugin-alpha-nvim", @@ -1978,6 +2053,27 @@ "type": "github" } }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixd", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1722330636, + "narHash": "sha256-uru7JzOa33YlSRwf9sfXpJG+UAV+bnBEYMjrzKrQZFw=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "768acdb06968e53aa1ee8de207fd955335c754b7", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, "utils": { "locked": { "lastModified": 1656928814, diff --git a/flake.nix b/flake.nix index ed9009378..58f3da72c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,91 +1,100 @@ { description = "A neovim flake with a modular configuration"; - outputs = { - flake-parts, - self, - ... - } @ inputs: let - # call the extedended library with `inputs` - # inputs is used to get the original standard library, and to pass inputs to the plugin autodiscovery function - lib = import ./lib/stdlib-extended.nix inputs; - in - flake-parts.lib.mkFlake { - inherit inputs; - specialArgs = {inherit lib;}; - } { - # Allow users to bring their own systems. - # «https://github.com/nix-systems/nix-systems» - systems = import inputs.systems; - imports = [ - ./flake/apps.nix - ./flake/legacyPackages.nix - ./flake/overlays.nix - ./flake/packages.nix - ]; - - flake = { - lib = { - inherit (lib) nvim; - inherit (lib.nvim) neovimConfiguration; + outputs = + { + flake-parts, + self, + ... + }@inputs: + let + # call the extedended library with `inputs` + # inputs is used to get the original standard library, and to pass inputs to the plugin autodiscovery function + lib = import ./lib/stdlib-extended.nix inputs; + in + flake-parts.lib.mkFlake + { + inherit inputs; + specialArgs = { + inherit lib; }; + } + { + # Allow users to bring their own systems. + # «https://github.com/nix-systems/nix-systems» + systems = import inputs.systems; + imports = [ + ./flake/apps.nix + ./flake/legacyPackages.nix + ./flake/overlays.nix + ./flake/packages.nix + ]; + + flake = { + lib = { + inherit (lib) nvim; + inherit (lib.nvim) neovimConfiguration; + }; - homeManagerModules = { - neovim-flake = - lib.warn '' + homeManagerModules = { + neovim-flake = lib.warn '' homeManagerModules.neovim-flake has been deprecated. Plese use the homeManagerModules.nvf instead - '' - self.homeManagerModules.nvf; + '' self.homeManagerModules.nvf; - nvf = import ./flake/modules/home-manager.nix self.packages lib; + nvf = import ./flake/modules/home-manager.nix self.packages lib; - default = self.homeManagerModules.nvf; - }; + default = self.homeManagerModules.nvf; + }; - nixosModules = { - neovim-flake = - lib.warn '' + nixosModules = { + neovim-flake = lib.warn '' nixosModules.neovim-flake has been deprecated. Please use the nixosModules.nvf instead - '' - self.nixosModules.nvf; + '' self.nixosModules.nvf; - nvf = import ./flake/modules/nixos.nix self.packages lib; - - default = self.nixosModules.nvf; - }; - }; + nvf = import ./flake/modules/nixos.nix self.packages lib; - perSystem = { - self', - config, - pkgs, - ... - }: { - devShells = { - default = self'.devShells.lsp; - nvim-nix = pkgs.mkShell {packages = [config.packages.nix];}; - lsp = pkgs.mkShell { - packages = with pkgs; [nil statix deadnix alejandra]; + default = self.nixosModules.nvf; }; }; - # Provide the default formatter. `nix fmt` in project root - # will format available files with the correct formatter. - # P.S: Please do not format with nixfmt! It messes with many - # syntax elements and results in unreadable code. - formatter = pkgs.alejandra; - - # Check if codebase is properly formatted. - # This can be initiated with `nix build .#checks..nix-fmt` - # or with `nix flake check` - checks = { - nix-fmt = pkgs.runCommand "nix-fmt-check" {nativeBuildInputs = [pkgs.alejandra];} '' - alejandra --check ${self} < /dev/null | tee $out - ''; - }; + perSystem = + { + self', + config, + pkgs, + ... + }: + { + devShells = { + default = self'.devShells.lsp; + nvim-nix = pkgs.mkShell { packages = [ config.packages.nix ]; }; + lsp = pkgs.mkShell { + packages = with pkgs; [ + nil + statix + deadnix + alejandra + ]; + }; + }; + + # Provide the default formatter. `nix fmt` in project root + # will format available files with the correct formatter. + # P.S: Please do not format with nixfmt! It messes with many + # syntax elements and results in unreadable code. + formatter = pkgs.alejandra; + + # Check if codebase is properly formatted. + # This can be initiated with `nix build .#checks..nix-fmt` + # or with `nix flake check` + checks = { + nix-fmt = pkgs.runCommand "nix-fmt-check" { nativeBuildInputs = [ pkgs.alejandra ]; } '' + alejandra --check ${self} < /dev/null | tee $out + ''; + }; + }; }; - }; # Flake inputs inputs = { @@ -111,6 +120,10 @@ inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-utils.follows = "flake-utils"; }; + nixd = { + url = "github:nix-community/nixd"; + inputs.nixpkgs.follows = "nixpkgs"; + }; ## Plugins # LSP plugins diff --git a/flake/legacyPackages.nix b/flake/legacyPackages.nix index 389ca0ce1..805fec601 100644 --- a/flake/legacyPackages.nix +++ b/flake/legacyPackages.nix @@ -1,18 +1,22 @@ -{inputs, ...}: { - perSystem = { - system, - inputs', - ... - }: { - legacyPackages = import inputs.nixpkgs { - inherit system; - overlays = [ - inputs.self.overlays.default - (_: _: { - rnix-lsp = inputs'.rnix-lsp.defaultPackage; - nil = inputs'.nil.packages.default; - }) - ]; +{ inputs, ... }: +{ + perSystem = + { + system, + inputs', + ... + }: + { + legacyPackages = import inputs.nixpkgs { + inherit system; + overlays = [ + inputs.self.overlays.default + (_: _: { + rnix-lsp = inputs'.rnix-lsp.defaultPackage; + nil = inputs'.nil.packages.default; + nixd = inputs'.nixd.packages.default; + }) + ]; + }; }; - }; }