2022-08-04 10:53:05 +03:00
|
|
|
{
|
|
|
|
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 }:
|
2022-09-24 16:09:35 +03:00
|
|
|
let
|
|
|
|
mkNil = { rustPlatform, nix, ... }:
|
|
|
|
let
|
|
|
|
inherit (builtins) substring;
|
|
|
|
mtime = self.lastModifiedDate;
|
|
|
|
date = "${substring 0 4 mtime}-${substring 4 2 mtime}-${substring 6 2 mtime}";
|
|
|
|
rev = self.shortRev or (throw "Git changes are not committed");
|
|
|
|
in
|
|
|
|
rustPlatform.buildRustPackage {
|
|
|
|
pname = "nil";
|
|
|
|
version = "unstable-${date}";
|
|
|
|
src = self;
|
|
|
|
cargoLock.lockFile = self + "/Cargo.lock";
|
2022-09-24 18:48:29 +03:00
|
|
|
|
2022-09-24 16:09:35 +03:00
|
|
|
nativeBuildInputs = [ nix.out ];
|
2022-09-03 23:53:31 +03:00
|
|
|
|
2022-09-24 16:09:35 +03:00
|
|
|
CFG_DATE = date;
|
|
|
|
CFG_REV = rev;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
flake-utils.lib.eachDefaultSystem
|
|
|
|
(system:
|
|
|
|
let
|
|
|
|
inherit (nixpkgs) lib;
|
2022-09-05 13:34:26 +03:00
|
|
|
|
2022-09-24 16:09:35 +03:00
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
rustPkgs = rust-overlay.packages.${system};
|
2022-09-03 23:53:31 +03:00
|
|
|
|
2022-09-24 16:09:35 +03:00
|
|
|
pre-commit = pkgs.writeShellScriptBin "pre-commit" ''
|
|
|
|
set -e
|
|
|
|
die() { echo "$*" >&2; exit 1; }
|
2022-09-05 21:16:00 +03:00
|
|
|
|
2022-09-24 16:09:35 +03:00
|
|
|
cd "$(git rev-parse --show-toplevel)"
|
|
|
|
rg --fixed-strings 'dbg!' --glob '*.rs' \
|
|
|
|
&& die 'Found dbg!()'
|
|
|
|
cargo fmt --quiet --check >/dev/null \
|
|
|
|
|| die 'Format failed'
|
|
|
|
cargo clippy --quiet --all-targets --all-features -- --deny warnings \
|
|
|
|
|| die 'Clippy failed'
|
|
|
|
cargo test --quiet \
|
|
|
|
|| die 'Test failed'
|
|
|
|
'';
|
2022-09-22 15:21:53 +03:00
|
|
|
|
2022-09-24 16:09:35 +03:00
|
|
|
nil = pkgs.callPackage mkNil { };
|
|
|
|
in
|
|
|
|
{
|
|
|
|
packages = {
|
|
|
|
inherit nil;
|
|
|
|
default = nil;
|
2022-08-04 10:53:05 +03:00
|
|
|
};
|
|
|
|
|
2022-09-24 16:09:35 +03:00
|
|
|
devShells.default = pkgs.mkShell {
|
|
|
|
packages = with pkgs; with rustPkgs; [
|
|
|
|
# Override the stable rustfmt.
|
|
|
|
rust-nightly_2022-08-01.availableComponents.rustfmt
|
|
|
|
rust
|
|
|
|
nix.out # For generation of builtins.
|
|
|
|
gdb
|
|
|
|
jq
|
|
|
|
pre-commit
|
2022-09-26 10:53:04 +03:00
|
|
|
nixpkgs-fmt
|
2022-09-28 13:17:33 +03:00
|
|
|
(import ./dev/nvim-lsp.nix { inherit pkgs; })
|
2022-09-24 16:09:35 +03:00
|
|
|
(import ./dev/vim-coc.nix { inherit pkgs; })
|
2022-09-28 13:17:33 +03:00
|
|
|
(import ./dev/vim-lsp.nix { inherit pkgs; })
|
2022-09-24 16:09:35 +03:00
|
|
|
] ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform vscodium) [
|
|
|
|
(import ./dev/vscodium.nix { inherit pkgs; })
|
|
|
|
];
|
2022-09-24 18:48:29 +03:00
|
|
|
|
2022-09-24 16:09:35 +03:00
|
|
|
RUST_BACKTRACE = "short";
|
|
|
|
NIXPKGS = nixpkgs;
|
2022-08-04 10:53:05 +03:00
|
|
|
|
2022-09-24 16:09:35 +03:00
|
|
|
# bash
|
|
|
|
shellHook = ''
|
|
|
|
export NIL_PATH="$(cargo metadata --format-version=1 | jq -r .target_directory)/debug/nil"
|
|
|
|
'';
|
|
|
|
};
|
2022-08-09 10:14:02 +03:00
|
|
|
|
2022-09-24 16:09:35 +03:00
|
|
|
devShells.fuzz = pkgs.mkShell {
|
|
|
|
packages = with pkgs; with rustPkgs; [
|
|
|
|
rust-nightly_2022-08-01
|
|
|
|
cargo-fuzz
|
|
|
|
llvmPackages_14.llvm
|
|
|
|
jq
|
|
|
|
gnugrep
|
|
|
|
];
|
|
|
|
RUST_BACKTRACE = "short";
|
2022-08-09 12:01:01 +03:00
|
|
|
|
2022-09-24 16:09:35 +03:00
|
|
|
# bash
|
|
|
|
shellHook = ''
|
|
|
|
export CARGO_TARGET_DIR=~/.cache/targets-syntax
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
})
|
|
|
|
// rec {
|
|
|
|
overlays = {
|
|
|
|
nil = final: prev: {
|
|
|
|
nil = final.callPackage mkNil { };
|
2022-08-09 10:14:02 +03:00
|
|
|
};
|
2022-09-24 16:09:35 +03:00
|
|
|
default = overlays.nil;
|
|
|
|
};
|
|
|
|
};
|
2022-08-04 10:53:05 +03:00
|
|
|
}
|