add support for more systems

This commit is contained in:
Max Känner 2024-09-16 10:21:57 +02:00
parent cccea58966
commit 1ee35d233f
5 changed files with 164 additions and 73 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/result
/esp-clang
.null-ls*

View File

@ -1,17 +1,44 @@
{pkgs ? import <nixpkgs> {}}: {
pkgs.stdenv.mkDerivation rec { pkgs ? import <nixpkgs> {},
system ? builtins.currentSystem,
}: let
systems_table = {
"x86_64-linux" = {
system = "x86_64-linux-gnu";
binhash = "aee15b8e02440f9ec6a8070f017621dc400dbd62a4701f9cf456dbe34d2a0c4d";
libhash = "cfd6fcb41d6d3651e3e7bdbb37d0e0b691b43e680dff4c998cf77f7e4ecd05c5";
};
"x86_64-darwin" = {
system = "x86_64-apple-darwin";
binhash = "b4641ec4dd574b6b7d037aa1bb2e5ff5a8a4623c88e89668db656282eb1d9dc8";
libhash = "80c086c29235016382b9ab95b41556ff5bdb40186f7f1c60c64acb2af420607b";
};
"aarch64-linux" = {
system = "aarch64-linux-gnu";
binhash = "14abbc368d9c153270aa4d22ce28d78633cb0f1ca83d4be70591d9e39ae9bc82";
libhash = "d49dfda7331a26b5d0da41bac91d5240a14ee731cbfa49f1ead3aa6377bd1b7e";
};
"aarch64-darwin" = {
system = "aarch64-apple-darwin";
binhash = "5d2e187ef40ecc9996630a7c6efcc19bdfd32ec4ce8cc4dd3014cd24e7016560";
libhash = "8b9c6bab01bffaed5f24e37e6e255bc4e0905cd175473e7d480f301f9b0d3f0d";
};
};
system_download = systems_table.${system};
in
pkgs.stdenv.mkDerivation rec {
pname = "esp-clang"; pname = "esp-clang";
version = "18.1.2_20240912"; version = "18.1.2_20240912";
srcs = [ srcs = [
(builtins.fetchurl (builtins.fetchurl
{ {
url = "https://github.com/espressif/llvm-project/releases/download/esp-${version}/clang-esp-${version}-x86_64-linux-gnu.tar.xz"; url = "https://github.com/espressif/llvm-project/releases/download/esp-${version}/clang-esp-${version}-${system_download.system}.tar.xz";
sha256 = "0k8c596y7nsnyjf1yw54cayhsh6w45v023q7m339w3s40a75pqdf"; sha256 = system_download.binhash;
}) })
(builtins.fetchurl (builtins.fetchurl
{ {
url = "https://github.com/espressif/llvm-project/releases/download/esp-${version}/libs-clang-esp-${version}-x86_64-linux-gnu.tar.xz"; url = "https://github.com/espressif/llvm-project/releases/download/esp-${version}/libs-clang-esp-${version}-${system_download.system}.tar.xz";
sha256 = "1i85rm77wzzpijclrzqdd0zb94dnw383gfxxwzim2dkd3nsgrmng"; sha256 = system_download.libhash;
}) })
]; ];
@ -31,4 +58,4 @@ pkgs.stdenv.mkDerivation rec {
mkdir -p "$out" mkdir -p "$out"
cp -R ./{bin,share,lib,include} "$out" cp -R ./{bin,share,lib,include} "$out"
''; '';
} }

View File

@ -1,5 +1,23 @@
{ {
"nodes": { "nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1725983898, "lastModified": 1725983898,
@ -18,8 +36,24 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View File

@ -3,19 +3,23 @@
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { outputs = {
self,
nixpkgs, nixpkgs,
}: let flake-utils,
system = "x86_64-linux"; ...
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
in { in {
packages.${system} = { packages = rec {
rust = import ./rust.nix {inherit pkgs;}; rust = import ./rust.nix {inherit pkgs system;};
clang = import ./clang.nix {inherit pkgs;}; clang = import ./clang.nix {inherit pkgs system;};
default = self.packages.${system}.rust; default = rust;
};
}; };
}
);
} }

View File

@ -1,16 +1,39 @@
{pkgs ? import <nixpkgs> {}}: {
pkgs.stdenv.mkDerivation rec { pkgs ? import <nixpkgs> {},
system ? builtins.currentSystem,
}: let
systems_table = {
"x86_64-linux" = {
system = "x86_64-unknown-linux-gnu";
hash = "1pilzw6lqygysdrklzs64vb07a3ni0pw24qklkwc5gjqwgzc4ka4";
};
"x86_64-darwin" = {
system = "x86_64-apple-darwin";
hash = "09j72xspg1bq82hk9w9ij9h17yk4lr0wfv20ybm1pah4bfxw6mha";
};
"aarch64-linux" = {
system = "aarch64-unknown-linux-gnu";
hash = "170013pw7rllqzc03i39xrwy486jllxjjh53sgnywqz0ylycx7j8";
};
"aarch64-darwin" = {
system = "aarch64-apple-darwin";
hash = "143kb7vawssg6b5h8c7k4szm43qqif3sjniwzc60avhn60zrc00j";
};
};
download_system = systems_table.${system};
in
pkgs.stdenv.mkDerivation rec {
pname = "esp-rust"; pname = "esp-rust";
version = "1.81.0"; version = "1.81.0.0";
srcs = [ srcs = [
(builtins.fetchurl (builtins.fetchurl
{ {
url = "https://github.com/esp-rs/rust-build/releases/download/v${version}.0/rust-${version}.0-x86_64-unknown-linux-gnu.tar.xz"; url = "https://github.com/esp-rs/rust-build/releases/download/v${version}/rust-${version}-${download_system.system}.tar.xz";
sha256 = "1pilzw6lqygysdrklzs64vb07a3ni0pw24qklkwc5gjqwgzc4ka4"; sha256 = download_system.hash;
}) })
(builtins.fetchurl (builtins.fetchurl
{ {
url = "https://github.com/esp-rs/rust-build/releases/download/v${version}.0/rust-src-${version}.0.tar.xz"; url = "https://github.com/esp-rs/rust-build/releases/download/v${version}.0/rust-src-${version}.tar.xz";
sha256 = "0w7fy0biml8ddvwpmrn9js4x6vkqjhm118gxy2431fnxl97v947f"; sha256 = "0w7fy0biml8ddvwpmrn9js4x6vkqjhm118gxy2431fnxl97v947f";
}) })
]; ];
@ -33,4 +56,4 @@ pkgs.stdenv.mkDerivation rec {
cp -R ./*/*/{bin,share,lib} "$out" cp -R ./*/*/{bin,share,lib} "$out"
runHook postInstall runHook postInstall
''; '';
} }