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": { "nodes": {
"flake-utils": { "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": { "locked": {
"lastModified": 1629481132, "lastModified": 1629481132,
"narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=",
@ -53,6 +68,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"gitignore": "gitignore", "gitignore": "gitignore",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"zig-overlay": "zig-overlay" "zig-overlay": "zig-overlay"
@ -60,7 +76,7 @@
}, },
"zig-overlay": { "zig-overlay": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils_2",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ]

View File

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