2022-07-18 18:12:17 +01:00
|
|
|
{
|
2023-03-05 19:38:27 +00:00
|
|
|
inputs =
|
|
|
|
{
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2022-07-18 18:12:17 +01:00
|
|
|
|
2023-03-05 19:38:27 +00:00
|
|
|
zig-overlay.url = "github:mitchellh/zig-overlay";
|
|
|
|
zig-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
2022-07-18 18:12:17 +01:00
|
|
|
|
2023-03-05 19:38:27 +00:00
|
|
|
gitignore.url = "github:hercules-ci/gitignore.nix";
|
|
|
|
gitignore.inputs.nixpkgs.follows = "nixpkgs";
|
2022-07-19 04:42:20 +01:00
|
|
|
|
2023-03-05 19:38:27 +00:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2022-07-19 07:08:04 +01:00
|
|
|
|
2023-03-05 19:38:27 +00:00
|
|
|
known_folders.url = "https://github.com/ziglibs/known-folders/archive/d13ba6137084e55f873f6afb67447fe8906cc951.tar.gz";
|
|
|
|
known_folders.flake = false;
|
2022-12-29 18:36:38 +00:00
|
|
|
|
2023-03-05 19:38:27 +00:00
|
|
|
tres.url = "https://github.com/ziglibs/tres/archive/707a09313b42e05d6ae22d1590499eece5f968ce.tar.gz";
|
|
|
|
tres.flake = false;
|
2023-02-11 22:04:22 +00:00
|
|
|
|
2023-03-05 19:38:27 +00:00
|
|
|
diffz.url = "https://github.com/ziglibs/diffz/archive/b966296b4489eb082b0831ec9a37d6f5e1906040.tar.gz";
|
|
|
|
diffz.flake = false;
|
|
|
|
};
|
2022-11-03 18:44:01 +00:00
|
|
|
|
2023-03-05 19:38:27 +00:00
|
|
|
outputs = inputs:
|
2022-07-18 18:12:17 +01:00
|
|
|
let
|
2023-03-05 19:38:27 +00:00
|
|
|
inherit (inputs) nixpkgs zig-overlay gitignore flake-utils;
|
2022-07-19 04:42:20 +01:00
|
|
|
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
2022-07-18 18:12:17 +01:00
|
|
|
inherit (gitignore.lib) gitignoreSource;
|
2022-11-03 18:44:01 +00:00
|
|
|
in
|
|
|
|
flake-utils.lib.eachSystem systems (system:
|
2022-07-19 04:42:20 +01:00
|
|
|
let
|
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
2022-08-26 16:34:18 +01:00
|
|
|
zig = zig-overlay.packages.${system}.master;
|
2023-03-05 19:38:27 +00:00
|
|
|
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 ${inputs.${k}} .cache/p/${v.hash}") zon));
|
2022-11-03 18:44:01 +00:00
|
|
|
in
|
|
|
|
rec {
|
2023-03-11 01:27:50 +00:00
|
|
|
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
|
2022-07-19 04:42:20 +01:00
|
|
|
packages.default = packages.zls;
|
|
|
|
packages.zls = pkgs.stdenvNoCC.mkDerivation {
|
|
|
|
name = "zls";
|
|
|
|
version = "master";
|
|
|
|
src = gitignoreSource ./.;
|
|
|
|
nativeBuildInputs = [ zig ];
|
|
|
|
dontConfigure = true;
|
|
|
|
dontInstall = true;
|
|
|
|
buildPhase = ''
|
|
|
|
mkdir -p $out
|
2023-03-05 19:38:27 +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
|
2022-07-19 04:42:20 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|
2022-11-03 18:44:01 +00:00
|
|
|
);
|
2022-07-18 18:12:17 +01:00
|
|
|
}
|