1
1
mirror of https://github.com/oxalica/nil.git synced 2024-08-16 22:20:31 +03:00

Package as flake

This commit is contained in:
oxalica 2022-08-04 15:53:05 +08:00
parent 3f6751ab4c
commit bca921c5c0
5 changed files with 137 additions and 10 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/target
/.envrc
/result*

View File

@ -1,4 +1,4 @@
nil: Language server of Nix Expression Language
nil: Language server for Nix Expression Language
🚧 *This project is under development, but be happy to try it out!*
@ -19,8 +19,23 @@ Super fast incremental analysis! Scans `all-packages.nix` in less then 0.1s and
## Installation
1. Have the latest stable version of Rust installed.
2. `cargo install --git https://github.com/oxalica/nil.git`
**TODO: Beginner friendly instructions.**
This repo is packaged via [Nix flakes][nix-flakes], the language server binary package is
available through the default flake output `github:oxalica/nil#` with the path `bin/nil`.
Flake output structure:
```
├───devShells
│ └───(...)
└───packages
├───x86_64-linux
│ ├───default: package 'nil-unstable-2022-08-04'
│ └───nil: package 'nil-unstable-2022-08-04'
└───(...)
```
[nix-flakes]: https://nixos.wiki/wiki/Flakes
### For neovim `nvim-lspconfig` user
@ -30,8 +45,8 @@ Add the following vimscript to your configuration.
lua <<EOF
require('lspconfig').rnix.setup {
autostart = true,
-- Set to the path to `nil` binary you installed.
cmd = { vim.env.HOME .. "/.local/bin/nil" },
-- Change it to the path to the `nil` binary you installed.
cmd = { "/run/current-system/sw/bin/bin/nil" },
}
EOF
```

67
flake.lock Normal file
View File

@ -0,0 +1,67 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1659494082,
"narHash": "sha256-XRwMisQY/BcvDMDRVkd4n3/CT89HOtlPgWIQUNPvWSc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "8c7576622aeb4707351a17e83429667f42e7d910",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1659599305,
"narHash": "sha256-htzFq5RffyoKSZxiLfpUq5CyhkQwycsXB5ptale5e78=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "28cedcb8dfea9f1b96b0635cf99fe6bdca163f4e",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

48
flake.nix Normal file
View File

@ -0,0 +1,48 @@
{
description = "Language Server for Nix Expression Language";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.flake-utils.follows = "flake-utils";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, flake-utils, nixpkgs, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
inherit (builtins) substring;
pkgs = nixpkgs.legacyPackages.${system};
rustPkgs = rust-overlay.packages.${system};
in {
packages = rec {
default = nil;
nil = pkgs.rustPlatform.buildRustPackage {
pname = "nil";
version = let mtime = self.lastModifiedDate; in
"unstable-${substring 0 4 mtime}-${substring 4 2 mtime}-${substring 6 2 mtime}";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
buildAndTestSubdir = "lsp";
};
};
devShells.default = pkgs.mkShell {
packages = [
# Override the stable rustfmt.
rustPkgs.rust-nightly_2022-08-01.availableComponents.rustfmt
rustPkgs.rust
pkgs.jq
(import ./neovim-env.nix { inherit pkgs; })
];
RUST_BACKTRACE = 1;
NIXPKGS = nixpkgs;
shellHook = ''
export NIL_PATH="$(cargo metadata --format-version=1 | jq -r .target_directory)"
'';
};
});
}

View File

@ -95,8 +95,4 @@ let
'';
in
pkgs.mkShell {
packages = [
neovim
];
}
neovim