forked from justinbarclay/parinfer-rust-emacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
87 lines (80 loc) · 2.56 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{
inputs = {
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = { self, flake-utils, naersk, nixpkgs, fenix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
localeEnv = if pkgs.stdenv.isDarwin then "" else "LOCALE_ARCHIVE=${pkgs.glibcLocales}/lib/locale/locale-archive";
naersk' = pkgs.callPackage naersk { };
parinfer-rust = naersk'.buildPackage {
src = ./.;
doCheck = true;
nativeBuildInputs = [ pkgs.cargo-nextest ];
buildFlags = [ "--release" "--no-default-features" ];
cargoTestCommands = x: [ ''cargo nextest run'' ];
};
runVimTests = name: path: pkgs.stdenv.mkDerivation {
name = "parinfer-rust-${name}-tests";
src = ./tests/vim;
buildPhase = ''
printf 'Testing %s\n' '${path}'
LC_ALL=en_US.UTF-8 \
${localeEnv} \
VIM_TO_TEST=${path} \
PLUGIN_TO_TEST=${parinfer-rust}/share/vim-plugins/parinfer-rust \
${pkgs.vim}/bin/vim --clean -u run.vim
'';
installPhase = ''
touch $out
'';
};
vim-tests = runVimTests "vim" "${pkgs.vim}/bin/vim";
neovim-tests = runVimTests "neovim" "${pkgs.neovim}/bin/nvim";
in
rec {
# For `nix build` & `nix run`:
packages = {
default = parinfer-rust;
app = parinfer-rust;
};
checks = {
neovim = neovim-tests;
vim = vim-tests;
kakoune = pkgs.stdenv.mkDerivation {
name = "parinfer-rust-kakoune-tests";
src = ./tests/kakoune;
buildInputs = [
pkgs.kakoune-unwrapped
parinfer-rust
];
buildPhase = ''
patchShebangs ./run.sh
PLUGIN_TO_TEST=${parinfer-rust}/share/kak/autoload/plugins ./run.sh
'';
installPhase = ''
touch $out
'';
};
};
devShells = with pkgs; {
default = mkShell {
nativeBuildInputs = [
rustc
cargo
rust-analyzer
rustfmt
vim
neovim
] ++ lib.optional stdenv.isDarwin libiconv;
};
};
});
}