Merge pull request #11 from logos-blockchain/feat/nixify

feat: Nixify
This commit is contained in:
Álex 2026-01-30 14:33:49 +01:00 committed by GitHub
commit 480b9bc4fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 158 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.idea/
result

27
flake.lock generated Normal file
View File

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1769461804,
"narHash": "sha256-msG8SU5WsBUfVVa/9RPLaymvi5bI8edTavbIq3vRlhI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "bfc1b8a4574108ceef22f02bafcf6611380c100d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

95
flake.nix Normal file
View File

@ -0,0 +1,95 @@
{
description = "Logos Blockchain Circuits (GitHub Releases)";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{ nixpkgs, ... }:
let
lib = nixpkgs.lib;
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-windows"
];
forAll = lib.genAttrs systems;
circuitsVersion = "0.3.2"; # TODO: Parametrize or make package per version available
versions = import ./versions.nix;
circuitsHashes = versions.${circuitsVersion};
githubBase = "https://github.com/logos-blockchain/logos-blockchain-circuits/releases/download";
mkCircuits =
system:
let
pkgs = nixpkgs.legacyPackages.${system};
os =
if pkgs.stdenv.isLinux then
"linux"
else if pkgs.stdenv.isDarwin then
"macos"
else if pkgs.stdenv.isWindows then
"windows"
else
throw "Unsupported OS";
arch =
if pkgs.stdenv.isx86_64 then
"x86_64"
else if pkgs.stdenv.isAarch64 then
"aarch64"
else
throw "Unsupported architecture.";
sha256 =
if circuitsHashes ? ${system} then
circuitsHashes.${system}
else
throw "logos-blockchain-circuits ${circuitsVersion} does not support ${system}.";
in
pkgs.stdenv.mkDerivation {
pname = "logos-blockchain-circuits";
version = circuitsVersion;
phases = [ "installPhase" ];
src = pkgs.fetchurl {
url =
"${githubBase}/v${circuitsVersion}"
+ "/logos-blockchain-circuits-v${circuitsVersion}-${os}-${arch}.tar.gz";
inherit sha256;
};
installPhase = ''
mkdir -p $out
tar -xzf $src -C $out --strip-components=1
'';
meta = {
platforms = [ system ];
};
passthru = {
version = circuitsVersion;
};
};
in
{
packages = forAll (
system:
let
circuits = mkCircuits system;
in
{
inherit circuits;
default = circuits;
}
);
};
}

21
scripts/gh-hash-to-nix.sh Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
if [ $# -ne 1 ]; then
echo "usage: $0 <sha256-hex | sha256:hex | sha256-SRI>"
exit 1
fi
input="$1"
# If already SRI, print as-is
if [[ "$input" =~ ^sha256- ]]; then
echo "$input"
exit 0
fi
# Strip optional sha256: prefix
hex="${input#sha256:}"
# Convert hex → SRI
nix hash convert --hash-algo sha256 "$hex"

13
versions.nix Normal file
View File

@ -0,0 +1,13 @@
{
"0.3.2" = {
x86_64-linux = "sha256-80+GrB3kBhwLHvNemme5Vig6tPDRRZC7xHps0DNonzM=";
aarch64-darwin = "sha256-FbLgrHaa8djFEaA69WpZMB3uozkLT/abQiCWKrkzcsk=";
x86_64-windows = "sha256-VOBUXlXNHTY0l91G+B1vybDfES0Y0HXhUytJIfFEiBA=";
};
"0.4.1" = {
x86_64-linux = "sha256-Oi3xhqm5Sd4PaCSHWMvsJm2YPtSlm11BBG99xG30tiM=";
aarch64-linux = "sha256-8lsgqflHXPP6mnxILpUCNhetpVeDNOXiQlWKoZLHa7I=";
aarch64-darwin = "sha256-E+yMjJPMy08jbiHLlDmDvlKnGJ4UiIRKB9GGZ0JGBB8=";
x86_64-windows = "sha256-8qceJxNt+OGF5cRNwNG146Op5xcqbShQEtmVJ6iDvmQ=";
};
}