2022-11-03 18:44:01 +00:00
|
|
|
{ pkgs ? import <nixpkgs> { }
|
|
|
|
, system ? builtins.currentSystem
|
|
|
|
}:
|
2021-06-05 21:05:41 +01:00
|
|
|
|
2020-10-26 03:03:30 +00:00
|
|
|
let
|
2021-06-05 16:47:37 +01:00
|
|
|
zig-overlay = pkgs.fetchFromGitHub {
|
2023-03-11 01:27:50 +00:00
|
|
|
owner = "mitchellh";
|
2021-06-05 16:47:37 +01:00
|
|
|
repo = "zig-overlay";
|
2023-03-11 01:27:50 +00:00
|
|
|
rev = "62ca03d2ff30fb2920c5a1d8a2b6c87d1b68867b";
|
|
|
|
sha256 = "1xriHeSpoL4qN5xqPiQc9S9R7Qvcl3RxHwJ5FYPjLn0=";
|
2021-06-05 16:47:37 +01:00
|
|
|
};
|
2023-03-11 01:27:50 +00:00
|
|
|
|
2020-10-26 18:29:09 +00:00
|
|
|
gitignoreSrc = pkgs.fetchFromGitHub {
|
2020-10-26 03:23:10 +00:00
|
|
|
owner = "hercules-ci";
|
2023-03-11 01:27:50 +00:00
|
|
|
repo = "gitignore.nix";
|
|
|
|
rev = "a20de23b925fd8264fd7fad6454652e142fd7f73";
|
|
|
|
sha256 = "8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=";
|
2020-10-26 03:23:10 +00:00
|
|
|
};
|
2023-03-11 01:27:50 +00:00
|
|
|
|
2020-10-26 03:23:10 +00:00
|
|
|
inherit (import gitignoreSrc { inherit (pkgs) lib; }) gitignoreSource;
|
2023-03-11 01:27:50 +00:00
|
|
|
zig = (import zig-overlay { inherit pkgs system; }).master;
|
|
|
|
|
|
|
|
zon = builtins.fromJSON (
|
|
|
|
builtins.concatStringsSep "" [
|
|
|
|
"{"
|
|
|
|
(builtins.replaceStrings [ "}, " ] [ "}" ]
|
|
|
|
(builtins.replaceStrings [ " ." " =" "\n" ", }" ] [ "\"" "\" :" "" "}" ]
|
|
|
|
(builtins.replaceStrings [ ".{" ] [ "{" ]
|
|
|
|
(builtins.concatStringsSep " "
|
|
|
|
(builtins.filter builtins.isString
|
|
|
|
(builtins.split "[ \n]+"
|
|
|
|
(builtins.elemAt
|
|
|
|
(builtins.match ".*dependencies = .[{](.*)[}].*" (builtins.readFile ./build.zig.zon))
|
|
|
|
0)))))))
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
cp-phase = builtins.concatStringsSep ";" (builtins.attrValues (builtins.mapAttrs (k: v: "cp -r ${builtins.fetchTarball v.url} .cache/p/${v.hash}") zon));
|
2021-06-05 21:05:41 +01:00
|
|
|
in
|
2020-10-31 20:05:19 +00:00
|
|
|
pkgs.stdenvNoCC.mkDerivation {
|
|
|
|
name = "zls";
|
|
|
|
version = "master";
|
|
|
|
src = gitignoreSource ./.;
|
2020-10-31 20:36:37 +00:00
|
|
|
nativeBuildInputs = [ zig ];
|
2020-10-31 20:05:19 +00:00
|
|
|
dontConfigure = true;
|
2020-10-31 20:36:37 +00:00
|
|
|
dontInstall = true;
|
2020-10-31 20:05:19 +00:00
|
|
|
buildPhase = ''
|
|
|
|
mkdir -p $out
|
2023-03-11 01:27:50 +00:00
|
|
|
mkdir -p .cache/{p,z,tmp}
|
|
|
|
${cp-phase}
|
|
|
|
zig build install --cache-dir $(pwd)/zig-cache --global-cache-dir $(pwd)/.cache -Dcpu=baseline -Doptimize=ReleaseSafe -Ddata_version=master --prefix $out
|
2020-10-31 20:05:19 +00:00
|
|
|
'';
|
|
|
|
}
|