8edb8bcac3
* fix nix build * fix nix build
69 lines
2.6 KiB
Nix
69 lines
2.6 KiB
Nix
{
|
|
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";
|
|
|
|
known_folders.url = "https://github.com/ziglibs/known-folders/archive/d13ba6137084e55f873f6afb67447fe8906cc951.tar.gz";
|
|
known_folders.flake = false;
|
|
|
|
tres.url = "https://github.com/ziglibs/tres/archive/707a09313b42e05d6ae22d1590499eece5f968ce.tar.gz";
|
|
tres.flake = false;
|
|
|
|
diffz.url = "https://github.com/ziglibs/diffz/archive/b966296b4489eb082b0831ec9a37d6f5e1906040.tar.gz";
|
|
diffz.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;
|
|
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));
|
|
in
|
|
rec {
|
|
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
|
|
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
|
|
'';
|
|
};
|
|
}
|
|
);
|
|
}
|