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,15 +7,21 @@
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
pkgs = nixpkgs.legacyPackages.${system};
zig = zig-overlay.packages.${system}.master.latest;
known-folders = pkgs.stdenvNoCC.mkDerivation {
name = "known-folders"; name = "known-folders";
src = nixpkgs.legacyPackages.${system}.fetchFromGitHub { src = pkgs.fetchFromGitHub {
owner = "ziglibs"; owner = "ziglibs";
repo = "known-folders"; repo = "known-folders";
rev = "9db1b99219c767d5e24994b1525273fe4031e464"; rev = "9db1b99219c767d5e24994b1525273fe4031e464";
@ -27,20 +33,15 @@
mkdir -p $out mkdir -p $out
cp known-folders.zig $out cp known-folders.zig $out
''; '';
}); };
in rec {
zls-derivation-fn = (system: nixpkgs.legacyPackages.${system}.stdenvNoCC.mkDerivation packages.default = packages.zls;
(let known-folders = known-folders-fetch system; packages.zls = pkgs.stdenvNoCC.mkDerivation {
in {
name = "zls"; name = "zls";
version = "master"; version = "master";
src = gitignoreSource ./.; src = gitignoreSource ./.;
nativeBuildInputs = [ nativeBuildInputs = [ zig ];
zig-overlay.packages.${system}.master.latest buildInputs = [ known-folders ];
];
buildInputs = [
known-folders
];
dontConfigure = true; dontConfigure = true;
dontInstall = true; dontInstall = true;
buildPhase = '' buildPhase = ''
@ -48,18 +49,7 @@
zig build install -Drelease-safe=true -Ddata_version=master -Dknown-folders=${known-folders}/known-folders.zig --prefix $out zig build install -Drelease-safe=true -Ddata_version=master -Dknown-folders=${known-folders}/known-folders.zig --prefix $out
''; '';
XDG_CACHE_HOME = ".cache"; 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;
};
}; };
} }
);
}