Fixes nix build. (#1032)

* fix nix build

* fix nix build
This commit is contained in:
Álan Crístoffer 2023-03-05 20:38:27 +01:00 committed by GitHub
parent 76ee4b80fd
commit 8edb8bcac3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 52 deletions

View File

@ -3,17 +3,13 @@
"diffz": { "diffz": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1676881125, "narHash": "sha256-9bdX4R/VDdjAn8TDH4T3a783mvbpjdWq2KSNtM9RcnY=",
"narHash": "sha256-iCXoJp+89GhdFO9roE208mhqURTuMX8zKiEEpvMH2do=", "type": "tarball",
"owner": "ziglibs", "url": "https://github.com/ziglibs/diffz/archive/b966296b4489eb082b0831ec9a37d6f5e1906040.tar.gz"
"repo": "diffz",
"rev": "efc91679b000a2d7f86fb40930f0a95a0d349bff",
"type": "github"
}, },
"original": { "original": {
"owner": "ziglibs", "type": "tarball",
"repo": "diffz", "url": "https://github.com/ziglibs/diffz/archive/b966296b4489eb082b0831ec9a37d6f5e1906040.tar.gz"
"type": "github"
} }
}, },
"flake-compat": { "flake-compat": {
@ -82,29 +78,25 @@
"type": "github" "type": "github"
} }
}, },
"known-folders": { "known_folders": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1675710004, "narHash": "sha256-hgzm6HrtusbhmWEq6moKYGf5sWc52UwyHTjAIjr6EEQ=",
"narHash": "sha256-eIAKOrapiqofwj4okOH9iRxBwl09VnAgS+nbfmD5q9U=", "type": "tarball",
"owner": "ziglibs", "url": "https://github.com/ziglibs/known-folders/archive/d13ba6137084e55f873f6afb67447fe8906cc951.tar.gz"
"repo": "known-folders",
"rev": "53fe3b676f32e59d46f4fd201d7ab200e5f6cb98",
"type": "github"
}, },
"original": { "original": {
"owner": "ziglibs", "type": "tarball",
"repo": "known-folders", "url": "https://github.com/ziglibs/known-folders/archive/d13ba6137084e55f873f6afb67447fe8906cc951.tar.gz"
"type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1676991263, "lastModified": 1677852945,
"narHash": "sha256-MXTZ2WdiYJ4LmWUo9Yc3DzrWr+V3NSxNE0t2ynoqYZ0=", "narHash": "sha256-liiVJjkBTuBTAkRW3hrI8MbPD2ImYzwUpa7kvteiKhM=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "f7475ce8950b761d80a13f3f81d2c23fce60c1dd", "rev": "f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -119,7 +111,7 @@
"diffz": "diffz", "diffz": "diffz",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"gitignore": "gitignore", "gitignore": "gitignore",
"known-folders": "known-folders", "known_folders": "known_folders",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"tres": "tres", "tres": "tres",
"zig-overlay": "zig-overlay" "zig-overlay": "zig-overlay"
@ -128,17 +120,13 @@
"tres": { "tres": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1677011084, "narHash": "sha256-WFI/nXcxy05kfrl4kLjP0LfwO9xCqjxKg7ZPEKiB6NY=",
"narHash": "sha256-hUPEz/agefsEAylFgfTA9csickOfqLbzguPIfwLI5WU=", "type": "tarball",
"owner": "ziglibs", "url": "https://github.com/ziglibs/tres/archive/707a09313b42e05d6ae22d1590499eece5f968ce.tar.gz"
"repo": "tres",
"rev": "d8b0c24a945da02fffdae731edd1903c6889e73c",
"type": "github"
}, },
"original": { "original": {
"owner": "ziglibs", "type": "tarball",
"repo": "tres", "url": "https://github.com/ziglibs/tres/archive/707a09313b42e05d6ae22d1590499eece5f968ce.tar.gz"
"type": "github"
} }
}, },
"zig-overlay": { "zig-overlay": {
@ -150,11 +138,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1676999840, "lastModified": 1678018077,
"narHash": "sha256-hOctK9Skbpdy1plgZlWzj6EoVQJFwpG1JRrr0F+9l34=", "narHash": "sha256-Gwzyc99gdpi7m7i6pRQhtAjWcvJRvJT65s2E9CTjCg0=",
"owner": "mitchellh", "owner": "mitchellh",
"repo": "zig-overlay", "repo": "zig-overlay",
"rev": "1b0d9c8d127616d40abb11f663924293b8e6dbfd", "rev": "09cda6f73587dd4d5dfa8ab8490a94eff5651001",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -1,27 +1,29 @@
{ {
inputs = { inputs =
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
zig-overlay.url = "github:mitchellh/zig-overlay"; zig-overlay.url = "github:mitchellh/zig-overlay";
zig-overlay.inputs.nixpkgs.follows = "nixpkgs"; zig-overlay.inputs.nixpkgs.follows = "nixpkgs";
gitignore.url = "github:hercules-ci/gitignore.nix"; gitignore.url = "github:hercules-ci/gitignore.nix";
gitignore.inputs.nixpkgs.follows = "nixpkgs"; gitignore.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
known-folders.url = "github:ziglibs/known-folders"; known_folders.url = "https://github.com/ziglibs/known-folders/archive/d13ba6137084e55f873f6afb67447fe8906cc951.tar.gz";
known-folders.flake = false; known_folders.flake = false;
diffz.url = "github:ziglibs/diffz"; tres.url = "https://github.com/ziglibs/tres/archive/707a09313b42e05d6ae22d1590499eece5f968ce.tar.gz";
diffz.flake = false; tres.flake = false;
tres.url = "github:ziglibs/tres"; diffz.url = "https://github.com/ziglibs/diffz/archive/b966296b4489eb082b0831ec9a37d6f5e1906040.tar.gz";
tres.flake = false; diffz.flake = false;
}; };
outputs = { self, nixpkgs, zig-overlay, gitignore, flake-utils, known-folders, tres, diffz }: outputs = inputs:
let let
inherit (inputs) nixpkgs zig-overlay gitignore flake-utils;
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
inherit (gitignore.lib) gitignoreSource; inherit (gitignore.lib) gitignoreSource;
in in
@ -29,6 +31,21 @@
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
zig = zig-overlay.packages.${system}.master; 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 in
rec { rec {
packages.default = packages.zls; packages.default = packages.zls;
@ -41,9 +58,10 @@
dontInstall = true; dontInstall = true;
buildPhase = '' buildPhase = ''
mkdir -p $out mkdir -p $out
zig build install -Dcpu=baseline -Doptimize=ReleaseSafe -Ddata_version=master -Dtres=${tres}/tres.zig -Dknown-folders=${known-folders}/known-folders.zig -Ddiffz=${diffz}/DiffMatchPatch.zig --prefix $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
''; '';
XDG_CACHE_HOME = ".cache";
}; };
} }
); );