-
-
Notifications
You must be signed in to change notification settings - Fork 325
/
Copy pathflake.nix
54 lines (51 loc) · 1.77 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
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";
};
outputs = {
self,
nixpkgs,
zig-overlay,
gitignore,
}:
builtins.foldl' nixpkgs.lib.recursiveUpdate {} (
builtins.map
(
system: let
pkgs = nixpkgs.legacyPackages.${system};
zig = zig-overlay.packages.${system}.master;
gitignoreSource = gitignore.lib.gitignoreSource;
target = builtins.replaceStrings ["darwin"] ["macos"] system;
revision = self;
in {
formatter.${system} = pkgs.alejandra;
packages.${system} = rec {
default = zls;
zls = pkgs.stdenvNoCC.mkDerivation {
name = "zls";
version = "master";
meta.mainProgram = "zls";
src = gitignoreSource ./.;
nativeBuildInputs = [zig];
dontConfigure = true;
dontInstall = true;
doCheck = true;
buildPhase = ''
NO_COLOR=1 # prevent escape codes from messing up the `nix log`
PACKAGE_DIR=${pkgs.callPackage ./deps.nix {zig = zig;}}
zig build install --global-cache-dir $(pwd)/.cache --system $PACKAGE_DIR -Dtarget=${target} -Doptimize=ReleaseSafe --prefix $out
'';
checkPhase = ''
zig build test --global-cache-dir $(pwd)/.cache --system $PACKAGE_DIR -Dtarget=${target}
'';
};
};
}
)
["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]
);
}