forked from zigtools/zls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
52 lines (47 loc) · 1.81 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
{
inputs =
{
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
zig-overlay.url = "github:mitchellh/zig-overlay";
zig-overlay.inputs.nixpkgs.follows = "nixpkgs";
gitignore.url = "github:hercules-ci/gitignore.nix";
gitignore.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
langref.url = "https://raw.githubusercontent.com/ziglang/zig/63bd2bff12992aef0ce23ae4b344e9cb5d65f05d/doc/langref.html.in";
langref.flake = false;
};
outputs = inputs:
let
inherit (inputs) nixpkgs zig-overlay gitignore flake-utils;
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
inherit (gitignore.lib) gitignoreSource;
in
flake-utils.lib.eachSystem systems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
zig = zig-overlay.packages.${system}.master;
in
rec {
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
packages.default = packages.zls;
packages.zls = pkgs.stdenvNoCC.mkDerivation {
name = "zls";
version = "master";
src = gitignoreSource ./.;
nativeBuildInputs = [ zig ];
dontConfigure = true;
dontInstall = true;
doCheck = true;
langref = inputs.langref;
buildPhase = ''
mkdir -p .cache
ln -s ${pkgs.callPackage ./deps.nix { }} .cache/p
zig build install --cache-dir $(pwd)/zig-cache --global-cache-dir $(pwd)/.cache -Dversion_data_path=$langref -Dcpu=baseline -Doptimize=ReleaseSafe --prefix $out
'';
checkPhase = ''
zig build test --cache-dir $(pwd)/zig-cache --global-cache-dir $(pwd)/.cache -Dversion_data_path=$langref -Dcpu=baseline
'';
};
}
);
}