feat: flake.nix for working in the neovim config with direnv
This commit is contained in:
4
.envrc
Normal file
4
.envrc
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then
|
||||||
|
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4="
|
||||||
|
fi
|
||||||
|
use flake
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
spell/
|
spell/
|
||||||
.luarc.json
|
.luarc.json
|
||||||
|
|
||||||
|
.direnv
|
||||||
|
|||||||
114
flake.lock
generated
114
flake.lock
generated
@@ -1,23 +1,5 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-parts": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs-lib": "nixpkgs-lib"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1706830856,
|
|
||||||
"narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=",
|
|
||||||
"owner": "hercules-ci",
|
|
||||||
"repo": "flake-parts",
|
|
||||||
"rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "hercules-ci",
|
|
||||||
"repo": "flake-parts",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
@@ -36,99 +18,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1667395993,
|
|
||||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"gen-luarc": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-parts": "flake-parts",
|
|
||||||
"nixpkgs": "nixpkgs"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1708688915,
|
|
||||||
"narHash": "sha256-Vcfbdo2IOEiimRnehGLUM5l2VEIjZYZdKS0sjYWwfb4=",
|
|
||||||
"owner": "mrcjkb",
|
|
||||||
"repo": "nix-gen-luarc-json",
|
|
||||||
"rev": "6eb62734dae84e5f79368dfc545b3fff305df754",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "mrcjkb",
|
|
||||||
"repo": "nix-gen-luarc-json",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"neovim": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils_2",
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"dir": "contrib",
|
|
||||||
"lastModified": 1703942320,
|
|
||||||
"narHash": "sha256-CcaBqA0yFCffNPmXOJTo8c9v1jrEBiqAl8CG5Dj5YxE=",
|
|
||||||
"owner": "neovim",
|
|
||||||
"repo": "neovim",
|
|
||||||
"rev": "8744ee8783a8597f9fce4a573ae05aca2f412120",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"dir": "contrib",
|
|
||||||
"owner": "neovim",
|
|
||||||
"ref": "stable",
|
|
||||||
"repo": "neovim",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
|
||||||
"lastModified": 1708475490,
|
|
||||||
"narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=",
|
|
||||||
"owner": "nixos",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "0e74ca98a74bc7270d28838369593635a5db3260",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nixos",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs-lib": {
|
|
||||||
"locked": {
|
|
||||||
"dir": "lib",
|
|
||||||
"lastModified": 1706550542,
|
|
||||||
"narHash": "sha256-UcsnCG6wx++23yeER4Hg18CXWbgNpqNXcHIo5/1Y+hc=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "97b17f32362e475016f942bbdfda4a4a72a8a652",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"dir": "lib",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_2": {
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1709479366,
|
"lastModified": 1709479366,
|
||||||
"narHash": "sha256-n6F0n8UV6lnTZbYPl1A9q1BS0p4hduAv1mGAP17CVd0=",
|
"narHash": "sha256-n6F0n8UV6lnTZbYPl1A9q1BS0p4hduAv1mGAP17CVd0=",
|
||||||
@@ -147,9 +37,7 @@
|
|||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"gen-luarc": "gen-luarc",
|
"nixpkgs": "nixpkgs"
|
||||||
"neovim": "neovim",
|
|
||||||
"nixpkgs": "nixpkgs_2"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
|
|||||||
53
flake.nix
53
flake.nix
@@ -1,51 +1,26 @@
|
|||||||
{
|
{
|
||||||
description = "My NeoVim config";
|
description = "learning.rs";
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
neovim = {
|
|
||||||
url = "github:neovim/neovim/stable?dir=contrib";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
gen-luarc.url = "github:mrcjkb/nix-gen-luarc-json";
|
|
||||||
|
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
};
|
};
|
||||||
outputs = { self, nixpkgs, neovim, flake-utils, gen-luarc, ... }@inputs:
|
outputs =
|
||||||
let
|
{ self
|
||||||
supportedSystems = [
|
, nixpkgs
|
||||||
"x86_64-linux"
|
, flake-utils
|
||||||
"aarch64-linux"
|
,
|
||||||
];
|
}:
|
||||||
neovim-overlay = import ./overlay.nix { inherit inputs; };
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
in
|
|
||||||
flake-utils.lib.eachSystem supportedSystems
|
|
||||||
(system:
|
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = [
|
|
||||||
neovim-overlay
|
|
||||||
gen-luarc.overlays.default
|
|
||||||
];
|
|
||||||
};
|
|
||||||
shell = pkgs.mkShell {
|
|
||||||
name = "nvim-devShell";
|
|
||||||
builtInputs = with pkgs; [
|
|
||||||
lua-language-server
|
|
||||||
nil
|
|
||||||
stylua
|
|
||||||
luajitPackages.luacheck
|
|
||||||
deno
|
|
||||||
];
|
|
||||||
shellHook = ''
|
|
||||||
ln -fs ${pkgs.nvim-luarc-json} .luarc.json
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages = rec { default = nvim; nvim = pkgs.nvim-pkg; };
|
devShells.default = pkgs.mkShell {
|
||||||
devShells = { default = shell; };
|
buildInputs = with pkgs; [
|
||||||
}) // { overlays.default = neovim-overlay; };
|
stylua
|
||||||
|
];
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
111
mk-neovim.nix
111
mk-neovim.nix
@@ -1,111 +0,0 @@
|
|||||||
{ pkgs, lib, stdenv, }:
|
|
||||||
with lib;
|
|
||||||
{ appName ? null
|
|
||||||
, plugins ? [ ]
|
|
||||||
, devPlugins ? [ ]
|
|
||||||
, ignoreConfigRegexes ? [ ]
|
|
||||||
, extraPackages ? [ ]
|
|
||||||
, resolvedExtraLuaPackages ? [ ]
|
|
||||||
, extraPython3Packages ? p: [ ]
|
|
||||||
, withPython3 ? true
|
|
||||||
, withRuby ? false
|
|
||||||
, withNodeJs ? false
|
|
||||||
, withSqlite ? true
|
|
||||||
, viAlias ? appName == "nvim"
|
|
||||||
, vimAlias ? appName == "nvim"
|
|
||||||
,
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
defaultPlugin = {
|
|
||||||
plugin = null;
|
|
||||||
config = null;
|
|
||||||
optional = false;
|
|
||||||
runtime = { };
|
|
||||||
};
|
|
||||||
externalPackages = extraPackages ++ (optionals withSqlite [ pkgs.sqlite ]);
|
|
||||||
normalizedPlugins = map
|
|
||||||
(x:
|
|
||||||
defaultPlugin
|
|
||||||
// (
|
|
||||||
if x ? plugin
|
|
||||||
then x
|
|
||||||
else { plugin = x; }
|
|
||||||
))
|
|
||||||
plugins;
|
|
||||||
neovimConfig = pkgs.neovimUtils.makeNeovimConfig {
|
|
||||||
inherit extraPython3Packages withPython3 withRuby withNodeJs viAlias vimAlias;
|
|
||||||
plugins = normalizedPlugins;
|
|
||||||
};
|
|
||||||
nvimRtpSrc =
|
|
||||||
let
|
|
||||||
src = ./.;
|
|
||||||
in
|
|
||||||
lib.cleanSourceWith {
|
|
||||||
inherit src;
|
|
||||||
name = "nvim-rtp-src";
|
|
||||||
filter = path: tyoe:
|
|
||||||
let
|
|
||||||
srcPrefix = toString src + "/";
|
|
||||||
relPath = lib.removePrefix srcPrefix (toString path);
|
|
||||||
in
|
|
||||||
lib.all (regex: builtins.match refex relPath == null) ignoreConfigRegexes;
|
|
||||||
};
|
|
||||||
nvimRtp = stdenv.mkDerivation {
|
|
||||||
name = "nvim-rtp";
|
|
||||||
src = nvimRtpSrc;
|
|
||||||
buildPhase = ''
|
|
||||||
mkdir -p $out/nvim
|
|
||||||
mkdir -p $out/lua
|
|
||||||
rm init.lua
|
|
||||||
'';
|
|
||||||
installPhase = ''
|
|
||||||
cp -r after $out/after
|
|
||||||
rm -r after
|
|
||||||
cp -r lua $out/lua
|
|
||||||
rm -r lua
|
|
||||||
cp -r * $out/nvim
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
initLua = ''
|
|
||||||
vim.loader.enable()
|
|
||||||
vim.opt.rtp:prepend('${nvimRtp}/lua')
|
|
||||||
''
|
|
||||||
+ (builtins.readFile ./init.lua)
|
|
||||||
+ ''
|
|
||||||
vim.opt.rtp:append('${nvimRtp}/nvim')
|
|
||||||
vim.opt.rtp:append('${nvimRtp}/after')
|
|
||||||
'';
|
|
||||||
|
|
||||||
extraMakeWrapperArgs = builtins.concatStringsSep " " (
|
|
||||||
(optional (appName != "nvim" && appName != null && appName != "")
|
|
||||||
''--set NVIM_APPNAME "${appName}"'')
|
|
||||||
++ (optional (externalPackages != [ ])
|
|
||||||
''--prefix PATH : "${makeBinPath externalPackages}"'')
|
|
||||||
++ (optional withSqlite
|
|
||||||
''--set LIBSQLITE_CLIB_PATH "${pkgs.sqlite.out}/lib/libsqlite3.so"'')
|
|
||||||
++ (optional withSqlite
|
|
||||||
''--set LIBSQLITE "${pkgs.sqlite.out}/lib/libsqlite3.so"'')
|
|
||||||
);
|
|
||||||
extraMakeWrapperLuaCArgs = optionalString (resolvedExtraLuaPackages != [ ]) ''
|
|
||||||
--suffix LUA_CPATH ";" "${
|
|
||||||
lib.concatMapStringsSep ";" pkgs.luaPackages.getLuaCPath
|
|
||||||
resolvedExtraLuaPackages
|
|
||||||
}"'';
|
|
||||||
extraMakeWrapperLuaArgs = optionalString (resolvedExtraLuaPackages != [ ]) ''
|
|
||||||
--suffix LUA_PATH ";" "${
|
|
||||||
concatMapStringSep ";" pkgs.luaPackages.getLuaPath
|
|
||||||
resolvedExtraLuaPackages
|
|
||||||
}"'';
|
|
||||||
in
|
|
||||||
pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped (neovimConfig // {
|
|
||||||
luaRcContent = initLua;
|
|
||||||
wrapperArgs =
|
|
||||||
escapeShellArgs neovimConfig.wrapperArgs
|
|
||||||
+ " "
|
|
||||||
+ extraMakeWrapperArgs
|
|
||||||
+ " "
|
|
||||||
+ extraMakeWrapperLuaCArgs
|
|
||||||
+ " "
|
|
||||||
+ extraMakeWrapperLuaArgs;
|
|
||||||
wrapRc = true;
|
|
||||||
})
|
|
||||||
17
overlay.nix
17
overlay.nix
@@ -1,17 +0,0 @@
|
|||||||
{ inputs }: final: prev: with final.pkgs.lib; let
|
|
||||||
pkgs = final;
|
|
||||||
mkNeovim = pkgs.callPackage ./mk-neovim.nix { };
|
|
||||||
extraPackages = with pkgs; [
|
|
||||||
lua-language-server
|
|
||||||
nil
|
|
||||||
];
|
|
||||||
in
|
|
||||||
{
|
|
||||||
nvim-pkg = mkNeovim {
|
|
||||||
plugins = [ ];
|
|
||||||
inherit extraPackages;
|
|
||||||
};
|
|
||||||
nvim-luarc-json = final.mk-luarc-json {
|
|
||||||
plugins = [ ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user