diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..7fd05db --- /dev/null +++ b/.envrc @@ -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 diff --git a/.gitignore b/.gitignore index 0410e5e..612fd8b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ spell/ .luarc.json +.direnv diff --git a/flake.lock b/flake.lock index bb6e612..9290712 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,5 @@ { "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": { "inputs": { "systems": "systems" @@ -36,99 +18,7 @@ "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": { - "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": { "lastModified": 1709479366, "narHash": "sha256-n6F0n8UV6lnTZbYPl1A9q1BS0p4hduAv1mGAP17CVd0=", @@ -147,9 +37,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", - "gen-luarc": "gen-luarc", - "neovim": "neovim", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs" } }, "systems": { diff --git a/flake.nix b/flake.nix index 7593f7a..3c1df97 100644 --- a/flake.nix +++ b/flake.nix @@ -1,51 +1,26 @@ { - description = "My NeoVim config"; + description = "learning.rs"; inputs = { 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"; }; - outputs = { self, nixpkgs, neovim, flake-utils, gen-luarc, ... }@inputs: + outputs = + { self + , nixpkgs + , flake-utils + , + }: + flake-utils.lib.eachDefaultSystem (system: let - supportedSystems = [ - "x86_64-linux" - "aarch64-linux" - ]; - neovim-overlay = import ./overlay.nix { inherit inputs; }; + pkgs = import nixpkgs { + inherit system; + }; in - flake-utils.lib.eachSystem supportedSystems - (system: - let - pkgs = import nixpkgs { - 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 - { - packages = rec { default = nvim; nvim = pkgs.nvim-pkg; }; - devShells = { default = shell; }; - }) // { overlays.default = neovim-overlay; }; + { + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + stylua + ]; + }; + }); } diff --git a/mk-neovim.nix b/mk-neovim.nix deleted file mode 100644 index 49640b0..0000000 --- a/mk-neovim.nix +++ /dev/null @@ -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; -}) diff --git a/overlay.nix b/overlay.nix deleted file mode 100644 index 140cb94..0000000 --- a/overlay.nix +++ /dev/null @@ -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 = [ ]; - }; -}