-
-
Notifications
You must be signed in to change notification settings - Fork 314
/
Copy pathflake.nix
56 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
55
56
{
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 }: let
inherit (nixpkgs) lib;
# flake-utils polyfill
eachSystem = systems: fn:
lib.foldl' (
acc: system:
lib.recursiveUpdate
acc
(lib.mapAttrs (_: value: {${system} = value;}) (fn system))
) {}
systems;
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
in eachSystem systems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
zig = zig-overlay.packages.${system}.master;
gitignoreSource = gitignore.lib.gitignoreSource;
in
rec {
formatter = pkgs.nixpkgs-fmt;
packages.default = packages.zls;
packages.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 -Dcpu=baseline -Doptimize=ReleaseSafe --prefix $out
'';
checkPhase = ''
zig build test --global-cache-dir $(pwd)/.cache --system $PACKAGE_DIR -Dcpu=baseline
'';
};
}
);
}