diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..44610e5 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake; diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..92b2793 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.direnv diff --git a/flake.nix b/flake.nix index 2aa75a9..f8b21e0 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "A very basic flake"; + description = "A portable Neovim flake"; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; @@ -12,6 +12,15 @@ pkgs = import nixpkgs { inherit system; }; in { - packages.x86_64-linux.default = pkgs.callPackage ./nix/package.nix { }; + packages.${system}.default = pkgs.callPackage ./nix/package.nix { }; + devShells.${system}.default = pkgs.mkShell { + packages = [ self.packages.${system}.default ]; + + EDITOR = "${self.packages.${system}.default}/bin/nvim"; + + shellHook = '' + export TMP_PROJECT_ROOT="$PWD" + ''; + }; }; } diff --git a/init.lua b/init.lua index 3e8f981..ccd195b 100644 --- a/init.lua +++ b/init.lua @@ -58,6 +58,8 @@ vim.filetype.add({ }, }) +vim.o.undofile = true + require("plugins") vim.cmd([[ diff --git a/nix/package.nix b/nix/package.nix index 43dd4f6..1c15d3d 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -1,4 +1,4 @@ -{ pkgs, lib ... }: +{ pkgs, lib, ... }: let deps = with pkgs; [ lua @@ -45,8 +45,16 @@ pkgs.writeTextFile { text = '' #!${pkgs.bash}/bin/bash export PATH=${lib.makeBinPath deps}:$PATH - export LUA_PATH=${../.}/lua/?.lua - ${pkgs.neovim-unwrapped}/bin/nvim -u ${../.}/init.lua $@ + + if [ -z $${TMP_PROJECT_ROOT+x} ]; then + export LUA_PATH=${../.}/lua/?.lua; + export CONFIG_LOC=${../init.lua} + else + export LUA_PATH="$TMP_PROJECT_ROOT/lua/?.lua"; + export CONFIG_LOC="$TMP_PROJECT_ROOT/init.lua" + fi + + ${pkgs.neovim-unwrapped}/bin/nvim -u $CONFIG_LOC $@ ''; checkPhase = '' ${pkgs.stdenv.shellDryRun} "$target"