Skip to content

Commit

Permalink
add: flake.nix and nix instructions (#6)
Browse files Browse the repository at this point in the history
* build: add nix support

* docs: add nix instructions
  • Loading branch information
matt1432 committed Nov 26, 2023
1 parent cd4666f commit da3c1d7
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
node_modules
target
result
52 changes: 52 additions & 0 deletions README.md
Expand Up @@ -31,3 +31,55 @@ Packer:
```lua
use { "luckasRanarison/tree-sitter-hypr" }
```

Nix:

with a basic `flake.nix` and all treesitter grammars
```nix
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
tree-sitter-hypr = {
url = "github:luckasRanarison/tree-sitter-hypr";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
nixpkgs,
home-manager,
tree-sitter-hypr,
...
}: {
homeConfigurations."user@hostname" = let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
in
home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
{
programs.neovim = {
enable = true;
plugins = with pkgs.vimPlugins; [
tree-sitter-hypr.packages.${pkgs.system}.default
{
plugin = nvim-treesitter.withAllGrammars;
type = "lua";
config = ''
require('nvim-treesitter.configs').setup({
highlight = { enable = true }
})
'';
}
];
};
}
# ...
];
};
};
}
```
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions flake.nix
@@ -0,0 +1,44 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
};

src = ./.;
version = "v1.0.2";

hypr-grammar = pkgs.tree-sitter.buildGrammar {
language = "hypr";
inherit version src;
generate = true;
};

in {
packages = {
default = pkgs.vimUtils.buildVimPlugin {
pname = "tree-sitter-hypr";
inherit version src;

# Since this package isn't with all the other treesitter grammars,
# we can simply add this line in the plugin to load it
preInstall = let
tsInstall = ''
vim.treesitter.language.require_language(\"hypr\", \"${hypr-grammar}/parser\")
'';
in ''
echo "${tsInstall}" >> ./plugin/init.lua
'';
};
};
});
}

0 comments on commit da3c1d7

Please sign in to comment.