1
1
mirror of https://github.com/oxalica/nil.git synced 2024-10-27 04:19:40 +03:00
nil/flake.nix

93 lines
2.9 KiB
Nix
Raw Normal View History

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 }:
flake-utils.lib.eachDefaultSystem (system:
let
inherit (builtins) substring;
pkgs = nixpkgs.legacyPackages.${system};
rustPkgs = rust-overlay.packages.${system};
2022-09-03 23:53:31 +03:00
pre-commit = pkgs.writeShellScriptBin "pre-commit" ''
set -e
die() { echo "$*" >&2; exit 1; }
2022-09-05 20:54:33 +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'
2022-09-05 20:54:33 +03:00
cargo clippy --quiet --all-targets --all-features -- --deny warnings \
|| die 'Clippy failed'
2022-09-05 20:54:33 +03:00
cargo test --quiet \
|| die 'Test failed'
2022-09-03 23:53:31 +03:00
'';
2022-08-04 10:53:05 +03:00
in {
packages = rec {
default = nil;
2022-09-05 21:16:00 +03:00
nil = let
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 pkgs.rustPlatform.buildRustPackage {
2022-08-04 10:53:05 +03:00
pname = "nil";
2022-09-05 21:16:00 +03:00
version = "unstable-${date}";
src = self;
cargoLock.lockFile = self + "/Cargo.lock";
nativeBuildInputs = [ pkgs.nix.out ];
2022-09-05 21:16:00 +03:00
CFG_DATE = date;
CFG_REV = rev;
2022-08-04 10:53:05 +03:00
};
};
devShells.default = pkgs.mkShell {
2022-09-03 23:53:31 +03:00
packages = with pkgs; with rustPkgs; [
2022-08-04 10:53:05 +03:00
# Override the stable rustfmt.
2022-09-03 23:53:31 +03:00
rust-nightly_2022-08-01.availableComponents.rustfmt
rust
nix.out # For generation of builtins.
2022-09-03 23:53:31 +03:00
gdb
jq
2022-09-05 16:44:23 +03:00
(import ./dev/neovim-lsp.nix { inherit pkgs; })
(import ./dev/vim-coc.nix { inherit pkgs; })
(import ./dev/vscodium.nix { inherit pkgs; })
2022-09-03 23:53:31 +03:00
pre-commit
2022-08-04 10:53:05 +03:00
];
RUST_BACKTRACE = "short";
2022-08-04 10:53:05 +03:00
NIXPKGS = nixpkgs;
# bash
2022-08-04 10:53:05 +03:00
shellHook = ''
export NIL_PATH="$(cargo metadata --format-version=1 | jq -r .target_directory)/debug/nil"
2022-08-04 10:53:05 +03:00
'';
};
2022-08-09 10:14:02 +03:00
devShells.fuzz = pkgs.mkShell {
2022-09-03 23:53:31 +03:00
packages = with pkgs; with rustPkgs; [
rust-nightly_2022-08-01
cargo-fuzz
llvmPackages_14.llvm
jq
gnugrep
2022-08-09 10:14:02 +03:00
];
RUST_BACKTRACE = "short";
2022-08-09 12:01:01 +03:00
# bash
shellHook = ''
export CARGO_TARGET_DIR=~/.cache/targets-syntax
'';
2022-08-09 10:14:02 +03:00
};
2022-08-04 10:53:05 +03:00
});
}