-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathflake.nix
67 lines (62 loc) · 2.38 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
{
description = "Developmet flake for nvimpager";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
neovim.url = "github:nix-community/neovim-nightly-overlay";
};
outputs = { self, nixpkgs, flake-utils, neovim, ... }:
let
inherit (builtins) head match readFile;
inherit (flake-utils.lib) eachDefaultSystem;
version = head (match ".*version=([0-9.]*)\n.*" (readFile ./nvimpager))
+ "-dev-${toString self.sourceInfo.lastModifiedDate}";
inherit (nixpkgs.lib.strings) optionalString;
nvimpager = {
stdenv, neovim, ncurses, procps, scdoc, lua51Packages, util-linux
}:
stdenv.mkDerivation {
pname = "nvimpager";
inherit version;
src = self;
buildInputs = [
ncurses # for tput
procps # for nvim_get_proc() which uses ps(1)
];
nativeBuildInputs = [ scdoc ];
makeFlags = [ "PREFIX=$(out)" "VERSION=${version}" ];
buildFlags = [ "nvimpager.configured" "nvimpager.1" ];
preBuild = ''
patchShebangs nvimpager
substituteInPlace nvimpager --replace ':-nvim' ':-${neovim}/bin/nvim'
'';
doCheck = true;
nativeCheckInputs = [ lua51Packages.busted util-linux neovim ];
# filter out one test that fails in the sandbox of nix
preCheck = let
neovim-version = neovim.version or neovim.passthru.unwrapped.version;
neovim-new = null == match "^0\\.9\\..*" neovim-version;
exclude-tags = "nix" + optionalString stdenv.isDarwin ",mac"
+ optionalString neovim-new ",v10";
in ''
checkFlagsArray+=('BUSTED=busted --output TAP --exclude-tags=${exclude-tags}')
'';
};
in ({
overlays.default = final: prev: {
nvimpager = final.callPackage nvimpager {};
};
} // (eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
callPackage = pkgs.callPackage nvimpager;
neovim-nightly = neovim.packages.${system}.default;
default = callPackage {};
nightly = callPackage { neovim = neovim-nightly; };
in {
apps.default = flake-utils.lib.mkApp { drv = default; };
packages = { inherit default nightly neovim-nightly; inherit (pkgs) neovim; };
packages.ldoc = pkgs.runCommandLocal "nvimpager-api-docs" {}
"cd ${self} && ${pkgs.luaPackages.ldoc}/bin/ldoc . --dir $out";
})));
}