Skip to content

Commit 35d8a31

Browse files
committed
Centralize IOG library lists in iog-libs.nix
Extract the duplicated IOG dependency lists from dynamic.nix, static.nix, cross-js.nix, and cross-windows.nix into a single iog-libs.nix file. This eliminates manual synchronization when adding new libraries (e.g., lmdb was previously missing from cross-compilation targets) and provides a canonical source of truth for IOG-specific dependencies. The centralized file categorizes dependencies into: - crypto: libblst, libsodium-vrf, secp256k1 (all shell types) - data: lmdb (dynamic/static only) - tools: cbor-diag, cddl, gh, icu, jq, yq-go (dynamic/static) - cross-tools: cbor-diag, cddl (cross-compilation targets) Each consumer imports iog-libs.nix and transforms as needed (e.g., static.nix passes static=true to resolve static-* variants). Addresses #56
1 parent b600136 commit 35d8a31

5 files changed

Lines changed: 56 additions & 37 deletions

File tree

cross-js.nix

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{ self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true }:
2-
let tool-version-map = (import ./tool-map.nix) self;
2+
let iog = import ./iog-libs.nix { inherit pkgs; };
3+
tool-version-map = (import ./tool-map.nix) self;
34
tool = tool-name: pkgs.pkgsBuildBuild.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule];
45
cabal-install = tool "cabal";
56
haskell-tools =
@@ -107,10 +108,7 @@ pkgs.mkShell ({
107108
])
108109
++ builtins.attrValues haskell-tools
109110
++ pkgs.lib.optional withIOG
110-
(with pkgs; [ cddl cbor-diag ]
111-
++ map pkgs.lib.getDev (with pkgs; [
112-
libblst libsodium-vrf secp256k1
113-
]))
111+
(iog.cross-tools ++ map pkgs.lib.getDev iog.crypto)
114112
;
115113

116114
passthru = {

cross-windows.nix

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{ self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true }:
2-
let tool-version-map = (import ./tool-map.nix) self;
2+
let iog = import ./iog-libs.nix { inherit pkgs; };
3+
# Build-platform tools (cbor-diag, cddl) — must run on the builder, not Windows.
4+
iog-build = import ./iog-libs.nix { pkgs = pkgs.pkgsBuildBuild; };
5+
tool-version-map = (import ./tool-map.nix) self;
36
tool = tool-name: pkgs.pkgsBuildBuild.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule];
47
cabal-install = tool "cabal";
58
haskell-tools =
@@ -216,10 +219,7 @@ pkgs.pkgsBuildBuild.mkShell ({
216219
])
217220
++ builtins.attrValues haskell-tools
218221
++ pkgs.lib.optional withIOG
219-
(with pkgs.pkgsBuildBuild; [ cddl cbor-diag ]
220-
++ map pkgs.lib.getDev (with pkgs; [
221-
libblst libsodium-vrf secp256k1
222-
]))
222+
(iog-build.cross-tools ++ map pkgs.lib.getDev iog.crypto)
223223
;
224224

225225
passthru = {

dynamic.nix

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# define a development shell for dynamically linked applications (default)
22
{ self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true, withIOGFull ? false, withGHCTooling ? false }:
3-
let tool-version-map = (import ./tool-map.nix) self;
3+
let iog = import ./iog-libs.nix { inherit pkgs; };
4+
tool-version-map = (import ./tool-map.nix) self;
45
tool = tool-name: pkgs.pkgsBuildBuild.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule];
56
cabal-install = tool "cabal";
67
haskell-tools =
@@ -127,21 +128,9 @@ pkgs.mkShell {
127128
zlib
128129
])
129130
++ optional stdenv.hostPlatform.isLinux pkgs.systemd
130-
++ optionals withIOG (
131-
with pkgs; [
132-
cbor-diag
133-
cddl
134-
gh
135-
icu
136-
jq
137-
libblst
138-
libsodium-vrf
139-
lmdb # required by ouroboros-consensus (cardano-lmdb)
140-
secp256k1
141-
yq-go
142-
]
131+
++ optionals withIOG (iog.tools ++ iog.crypto ++ iog.data
143132
++ optionals withIOGFull (
144-
[ postgresql ] ++ (optional stdenv.hostPlatform.isAarch64 R)
133+
with pkgs; [ postgresql ] ++ (optional stdenv.hostPlatform.isAarch64 R)
145134
)
146135
)
147136
++ attrValues haskell-tools

iog-libs.nix

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# iog-libs.nix — Canonical list of IOG-specific dependencies.
2+
#
3+
# Copyright 2025 Input Output Group
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Imported by dynamic.nix, static.nix, cross-js.nix, cross-windows.nix.
7+
# When adding a new IOG library, update the relevant category here
8+
# and each consumer file will pick it up automatically.
9+
#
10+
# The `static` flag controls whether linked libraries resolve to their
11+
# static-* variants (for musl cross-compilation in static.nix).
12+
{ pkgs, static ? false }:
13+
let
14+
# For linked libraries, resolve to static-* variants when building
15+
# static shells (musl cross-compilation).
16+
resolve = name:
17+
if static
18+
then builtins.getAttr ("static-" + name) pkgs
19+
else builtins.getAttr name pkgs;
20+
in {
21+
# Cryptographic libraries required by the Cardano stack.
22+
# Present in ALL shell types (dynamic, static, cross-js, cross-windows).
23+
crypto = map resolve [ "libblst" "libsodium-vrf" "secp256k1" ];
24+
25+
# Data-storage libraries (ouroboros-consensus / cardano-lmdb).
26+
# Dynamic and static shells only — not meaningful for JS/Windows cross.
27+
data = map resolve [ "lmdb" ];
28+
29+
# Development/CI tools (not linked into builds). Dynamic and static only.
30+
tools = with pkgs; [ cbor-diag cddl gh icu jq yq-go ];
31+
32+
# Minimal tool set for cross-compilation targets (CDDL/CBOR validation).
33+
cross-tools = with pkgs; [ cbor-diag cddl ];
34+
}

static.nix

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{ self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true, withIOGFull ? false }:
2-
let tool-version-map = (import ./tool-map.nix) self;
2+
let iog = import ./iog-libs.nix { inherit pkgs; static = true; };
3+
iog-tools = import ./iog-libs.nix { inherit pkgs; };
4+
tool-version-map = (import ./tool-map.nix) self;
35
tool = tool-name: pkgs.pkgsBuildBuild.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule];
46
cabal-install = tool "cabal";
57
haskell-tools =
@@ -47,6 +49,7 @@ let tool-version-map = (import ./tool-map.nix) self;
4749
$NIX_CABAL_FLAGS \
4850
--disable-shared --enable-static \
4951
--ghc-option=-L${lib.getLib static-gmp}/lib \
52+
# IOG crypto/data libs — keep in sync with iog-libs.nix
5053
--ghc-option=-L${lib.getLib static-libsodium-vrf}/lib \
5154
--ghc-option=-L${lib.getLib static-secp256k1}/lib \
5255
--ghc-option=-L${lib.getLib static-libblst}/lib \
@@ -134,16 +137,11 @@ pkgs.mkShell (rec {
134137
static-gmp
135138
static-openssl
136139
static-zlib
137-
] ++ lib.optionals withIOG [
138-
static-libblst
139-
static-libsodium-vrf
140-
static-lmdb # required by ouroboros-consensus (cardano-lmdb)
141-
static-secp256k1
142-
icu # for cardano-cli
143-
gh
144-
jq
145-
yq-go
146-
] ++ lib.optionals withIOGFull [
140+
] ++ lib.optionals withIOG (
141+
# IOG crypto/data libs — keep in sync with iog-libs.nix
142+
iog.crypto ++ iog.data
143+
++ [ icu gh jq yq-go ] # dev tools (non-static, through getDev)
144+
) ++ lib.optionals withIOGFull [
147145
# for plutus; but unavailable for static/aarch64, or static even.
148146
# R fails in almost any direction. For now, we just disable it.
149147
(if (pkgs.stdenv.hostPlatform.isAarch64 || pkgs.stdenv.hostPlatform.isMusl) then null else R)
@@ -166,7 +164,7 @@ pkgs.mkShell (rec {
166164
]) ++ (with pkgs.buildPackages; [
167165
])
168166
++ builtins.attrValues haskell-tools
169-
++ pkgs.lib.optional withIOG (with pkgs; [ cddl cbor-diag ])
167+
++ pkgs.lib.optional withIOG iog-tools.cross-tools
170168
;
171169

172170
passthru = {

0 commit comments

Comments
 (0)