Use flake-utils

This commit is contained in:
LeRoyce Pearson 2022-07-18 21:42:20 -06:00
parent 542f49087e
commit 5b94a7df02
2 changed files with 57 additions and 51 deletions

View File

@ -1,6 +1,21 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1629481132,
"narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=",
@ -53,6 +68,7 @@
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs",
"zig-overlay": "zig-overlay"
@ -60,7 +76,7 @@
},
"zig-overlay": {
"inputs": {
"flake-utils": "flake-utils",
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
]

View File

@ -7,59 +7,49 @@
gitignore.url = "github:hercules-ci/gitignore.nix";
gitignore.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {self, nixpkgs, zig-overlay, gitignore }:
outputs = {self, nixpkgs, zig-overlay, gitignore, flake-utils }:
let
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
inherit (gitignore.lib) gitignoreSource;
known-folders-fetch = (system: nixpkgs.legacyPackages.${system}.stdenvNoCC.mkDerivation {
name = "known-folders";
src = nixpkgs.legacyPackages.${system}.fetchFromGitHub {
owner = "ziglibs";
repo = "known-folders";
rev = "9db1b99219c767d5e24994b1525273fe4031e464";
sha256 = "sha256-eqaZxIax8C75L2UwDbVKSUZ7iThm/iWblfoaTfPyHLM=";
in flake-utils.lib.eachSystem systems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
zig = zig-overlay.packages.${system}.master.latest;
known-folders = pkgs.stdenvNoCC.mkDerivation {
name = "known-folders";
src = pkgs.fetchFromGitHub {
owner = "ziglibs";
repo = "known-folders";
rev = "9db1b99219c767d5e24994b1525273fe4031e464";
sha256 = "sha256-eqaZxIax8C75L2UwDbVKSUZ7iThm/iWblfoaTfPyHLM=";
};
dontConfigure = true;
dontInstall = true;
buildPhase = ''
mkdir -p $out
cp known-folders.zig $out
'';
};
dontConfigure = true;
dontInstall = true;
buildPhase = ''
mkdir -p $out
cp known-folders.zig $out
'';
});
zls-derivation-fn = (system: nixpkgs.legacyPackages.${system}.stdenvNoCC.mkDerivation
(let known-folders = known-folders-fetch system;
in {
name = "zls";
version = "master";
src = gitignoreSource ./.;
nativeBuildInputs = [
zig-overlay.packages.${system}.master.latest
];
buildInputs = [
known-folders
];
dontConfigure = true;
dontInstall = true;
buildPhase = ''
mkdir -p $out
zig build install -Drelease-safe=true -Ddata_version=master -Dknown-folders=${known-folders}/known-folders.zig --prefix $out
'';
XDG_CACHE_HOME = ".cache";
}));
in {
packages = rec {
x86_64-linux.zls = zls-derivation-fn "x86_64-linux";
aarch64-linux.zls = zls-derivation-fn "aarch64-linux";
x86_64-darwin.zls = zls-derivation-fn "x86_64-darwin";
aarch64-darwin.zls = zls-derivation-fn "aarch64-darwin";
x86_64-linux.default = x86_64-linux.zls;
aarch64-linux.default = aarch64-linux.zls;
x86_64-darwin.default = x86_64-darwin.zls;
aarch64-darwin.default = aarch64-darwin.zls;
};
};
in rec {
packages.default = packages.zls;
packages.zls = pkgs.stdenvNoCC.mkDerivation {
name = "zls";
version = "master";
src = gitignoreSource ./.;
nativeBuildInputs = [ zig ];
buildInputs = [ known-folders ];
dontConfigure = true;
dontInstall = true;
buildPhase = ''
mkdir -p $out
zig build install -Drelease-safe=true -Ddata_version=master -Dknown-folders=${known-folders}/known-folders.zig --prefix $out
'';
XDG_CACHE_HOME = ".cache";
};
}
);
}