From e32eb3851967f2380da41cee6f5d14f64ea3d05a Mon Sep 17 00:00:00 2001 From: Alejandro Cabeza Romero Date: Wed, 28 Jan 2026 16:24:43 +0100 Subject: [PATCH 1/5] Nixify circuits. --- .gitignore | 2 ++ flake.lock | 27 ++++++++++++++ flake.nix | 74 +++++++++++++++++++++++++++++++++++++++ scripts/gh-hash-to-nix.sh | 21 +++++++++++ 4 files changed, 124 insertions(+) create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix create mode 100755 scripts/gh-hash-to-nix.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..75e9c06 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6f6bfa6 --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f8e2635 --- /dev/null +++ b/flake.nix @@ -0,0 +1,74 @@ +{ + 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-darwin" "x86_64-windows" ]; + forAll = lib.genAttrs systems; + + circuitsVersion = "0.3.2"; + + circuitsHashes = { + x86_64-linux = "sha256-80+GrB3kBhwLHvNemme5Vig6tPDRRZC7xHps0DNonzM="; + aarch64-darwin = "sha256-FbLgrHaa8djFEaA69WpZMB3uozkLT/abQiCWKrkzcsk="; + x86_64-windows = "sha256-VOBUXlXNHTY0l91G+B1vybDfES0Y0HXhUytJIfFEiBA="; + }; + + 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."; + 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"; + sha256 = circuitsHashes.${system}; + }; + + installPhase = '' + mkdir -p $out + tar -xzf $src -C $out --strip-components=1 + ''; + + meta = { + platforms = [ system ]; + }; + }; + in + { + packages = forAll (system: + let + circuits = mkCircuits system; + in + { + inherit circuits; + default = circuits; + } + ); + }; +} diff --git a/scripts/gh-hash-to-nix.sh b/scripts/gh-hash-to-nix.sh new file mode 100755 index 0000000..162cab0 --- /dev/null +++ b/scripts/gh-hash-to-nix.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ $# -ne 1 ]; then + echo "usage: $0 " + 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" From d8992faa1d2d8b2ddfc45cd01b93999ebc8b79b1 Mon Sep 17 00:00:00 2001 From: Alejandro Cabeza Romero Date: Wed, 28 Jan 2026 16:26:46 +0100 Subject: [PATCH 2/5] Format flake. --- flake.nix | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/flake.nix b/flake.nix index f8e2635..e8e71e2 100644 --- a/flake.nix +++ b/flake.nix @@ -5,38 +5,50 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; - outputs = { nixpkgs, ... }: + outputs = + { nixpkgs, ... }: let lib = nixpkgs.lib; - systems = [ "x86_64-linux" "aarch64-darwin" "x86_64-windows" ]; + systems = [ + "x86_64-linux" + "aarch64-darwin" + "x86_64-windows" + ]; forAll = lib.genAttrs systems; circuitsVersion = "0.3.2"; circuitsHashes = { - x86_64-linux = "sha256-80+GrB3kBhwLHvNemme5Vig6tPDRRZC7xHps0DNonzM="; + x86_64-linux = "sha256-80+GrB3kBhwLHvNemme5Vig6tPDRRZC7xHps0DNonzM="; aarch64-darwin = "sha256-FbLgrHaa8djFEaA69WpZMB3uozkLT/abQiCWKrkzcsk="; x86_64-windows = "sha256-VOBUXlXNHTY0l91G+B1vybDfES0Y0HXhUytJIfFEiBA="; }; - githubBase = - "https://github.com/logos-blockchain/logos-blockchain-circuits/releases/download"; + githubBase = "https://github.com/logos-blockchain/logos-blockchain-circuits/releases/download"; - mkCircuits = system: + 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"; + 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."; + if pkgs.stdenv.isx86_64 then + "x86_64" + else if pkgs.stdenv.isAarch64 then + "aarch64" + else + throw "Unsupported architecture."; in pkgs.stdenv.mkDerivation { pname = "logos-blockchain-circuits"; @@ -61,7 +73,8 @@ }; in { - packages = forAll (system: + packages = forAll ( + system: let circuits = mkCircuits system; in From b71a648643983eb933c0c46da741bb46b9cec57e Mon Sep 17 00:00:00 2001 From: Alejandro Cabeza Romero Date: Wed, 28 Jan 2026 16:38:11 +0100 Subject: [PATCH 3/5] Add separate versions file. --- versions.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 versions.nix diff --git a/versions.nix b/versions.nix new file mode 100644 index 0000000..93941ef --- /dev/null +++ b/versions.nix @@ -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.0" = { + x86_64-linux = "sha256-Oi3xhqm5Sd4PaCSHWMvsJm2YPtSlm11BBG99xG30tiM="; + aarch64-linux = "sha256-8lsgqflHXPP6mnxILpUCNhetpVeDNOXiQlWKoZLHa7I="; + aarch64-darwin = "sha256-E+yMjJPMy08jbiHLlDmDvlKnGJ4UiIRKB9GGZ0JGBB8="; + x86_64-windows = "sha256-8qceJxNt+OGF5cRNwNG146Op5xcqbShQEtmVJ6iDvmQ="; + }; +} From df057aa15ab3e0429fd8564ec2c474b74f56197d Mon Sep 17 00:00:00 2001 From: Alejandro Cabeza Romero Date: Wed, 28 Jan 2026 16:51:29 +0100 Subject: [PATCH 4/5] wip --- flake.nix | 24 ++++++++++++++++-------- versions.nix | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/flake.nix b/flake.nix index e8e71e2..476a4bc 100644 --- a/flake.nix +++ b/flake.nix @@ -12,18 +12,16 @@ systems = [ "x86_64-linux" + "aarch64-linux" "aarch64-darwin" "x86_64-windows" ]; + forAll = lib.genAttrs systems; - circuitsVersion = "0.3.2"; - - circuitsHashes = { - x86_64-linux = "sha256-80+GrB3kBhwLHvNemme5Vig6tPDRRZC7xHps0DNonzM="; - aarch64-darwin = "sha256-FbLgrHaa8djFEaA69WpZMB3uozkLT/abQiCWKrkzcsk="; - x86_64-windows = "sha256-VOBUXlXNHTY0l91G+B1vybDfES0Y0HXhUytJIfFEiBA="; - }; + circuitsVersion = "0.4.1"; + versions = import ./versions.nix; + circuitsHashes = versions.${circuitsVersion}; githubBase = "https://github.com/logos-blockchain/logos-blockchain-circuits/releases/download"; @@ -49,6 +47,12 @@ "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"; @@ -59,7 +63,7 @@ url = "${githubBase}/v${circuitsVersion}" + "/logos-blockchain-circuits-v${circuitsVersion}-${os}-${arch}.tar.gz"; - sha256 = circuitsHashes.${system}; + inherit sha256; }; installPhase = '' @@ -70,6 +74,10 @@ meta = { platforms = [ system ]; }; + + passthru = { + version = circuitsVersion; + }; }; in { diff --git a/versions.nix b/versions.nix index 93941ef..32ce77a 100644 --- a/versions.nix +++ b/versions.nix @@ -4,7 +4,7 @@ aarch64-darwin = "sha256-FbLgrHaa8djFEaA69WpZMB3uozkLT/abQiCWKrkzcsk="; x86_64-windows = "sha256-VOBUXlXNHTY0l91G+B1vybDfES0Y0HXhUytJIfFEiBA="; }; - "0.4.0" = { + "0.4.1" = { x86_64-linux = "sha256-Oi3xhqm5Sd4PaCSHWMvsJm2YPtSlm11BBG99xG30tiM="; aarch64-linux = "sha256-8lsgqflHXPP6mnxILpUCNhetpVeDNOXiQlWKoZLHa7I="; aarch64-darwin = "sha256-E+yMjJPMy08jbiHLlDmDvlKnGJ4UiIRKB9GGZ0JGBB8="; From 1576b3a31ff784e21884a4509e71ee61fb10fa7e Mon Sep 17 00:00:00 2001 From: Alejandro Cabeza Romero Date: Wed, 28 Jan 2026 16:54:20 +0100 Subject: [PATCH 5/5] Set default version and add todo. --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 476a4bc..ede0955 100644 --- a/flake.nix +++ b/flake.nix @@ -19,7 +19,7 @@ forAll = lib.genAttrs systems; - circuitsVersion = "0.4.1"; + circuitsVersion = "0.3.2"; # TODO: Parametrize or make package per version available versions = import ./versions.nix; circuitsHashes = versions.${circuitsVersion};