Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
# Ensure git submodules are initialized before nix evaluates the flake.
# The flake declares `self.submodules = true`, so Nix's git fetcher reads
# submodule contents during source fetching — which fails if they're not
# present. This runs before `use flake`, breaking the chicken-and-egg.
git submodule update --init --recursive

use flake
25 changes: 14 additions & 11 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ repository cardano-haskell-packages
d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee

index-state:
, hackage.haskell.org 2025-09-11T07:59:00Z
, cardano-haskell-packages 2025-09-11T08:36:14Z
, hackage.haskell.org 2026-05-08T22:40:19Z
, cardano-haskell-packages 2026-05-08T13:26:45Z

packages:
./
Expand Down Expand Up @@ -46,26 +46,29 @@ package direct-sqlite
flags: +nomutex

constraints:
, any.cardano-node == 10.5.1
, any.cardano-node == 11.0.1

, any.cardano-ledger-core == 1.17.0.0
, any.cardano-ledger-shelley == 1.16.0.0
, any.cardano-ledger-conway == 1.19.0.0
, any.cardano-ledger-conway >= 1.22.1.0

, any.ouroboros-consensus == 0.27.0.0
, any.ouroboros-consensus-cardano == 0.25.1.0
, any.ouroboros-network == 0.21.3.0
, any.ouroboros-consensus ^>= 3.0.1
, any.ouroboros-network ^>= 1.1

, any.io-classes == 1.5.0.0
, any.io-classes-mtl == 0.1.2.0
, any.io-classes ^>= 1.8
, any.formatting == 7.2.0
, any.validation < 1.2
, any.text source

-- Use serial block IO instead of io_uring to avoid requiring liburing
, any.blockio +serialblockio

, direct-sqlite == 2.3.29.1
, sqlite-simple == 0.4.19.0.1

allow-newer:
*:formatting
, katip:Win32
, io-sim:time
, io-classes:time

-- NOTE update hash using
-- nix-prefetch-git https://github.com/CardanoSolutions/ogmios.git --rev <tag> --fetch-submodules --quiet | jq '.hash' | tail -c +9 | head -c -2
Expand Down
26 changes: 17 additions & 9 deletions kupo.cabal

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ library:
- cardano-ledger-byron
- cardano-ledger-conway
- cardano-ledger-core
- cardano-ledger-dijkstra
- cardano-ledger-mary
- cardano-ledger-shelley
- cardano-slotting
Expand All @@ -93,13 +94,13 @@ library:
- modern-uri
- network-mux
- optparse-applicative
- cardano-diffusion
- ouroboros-consensus
- ouroboros-consensus-cardano
- ouroboros-consensus-diffusion
- ouroboros-network
- ouroboros-network-api
- ouroboros-network-framework
- ouroboros-network-protocols
- ouroboros-consensus:cardano
- ouroboros-consensus:diffusion
- ouroboros-network:api
- ouroboros-network:framework
- ouroboros-network:protocols
- prometheus
- relude
- resource-pool
Expand Down Expand Up @@ -139,14 +140,15 @@ tests:
- http-types
- io-classes
- io-sim
- network
- kupo
- lens-aeson
- openapi3
- process
- QuickCheck
- quickcheck-state-machine
- relude
- si-timers
- io-classes:si-timers
- sqlite-simple
- stm
- temporary
Expand Down
17 changes: 17 additions & 0 deletions perSystem/musl.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
perSystem = {
project,
system,
lib,
...
}: let
muslProject = project.projectCross.${
if system == "x86_64-linux"
then "musl64"
else "aarch64-multiplatform-musl"
};
muslExes = muslProject.hsPkgs.kupo.components.exes;
in {
packages.kupo-exe-musl = muslExes.kupo;
};
}
8 changes: 6 additions & 2 deletions perSystem/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
kupo = hsPkgs.kupo;
in
{
packages.kupo = kupo.components.library;
packages.kupo-exe = kupo.components.exes.kupo;
packages = {
default = kupo.components.exes.kupo;
kupo = kupo.components.library;
kupo-exe = kupo.components.exes.kupo;
};

checks.kupo-unit = kupo.checks.unit;
};
}
166 changes: 101 additions & 65 deletions perSystem/project.nix
Original file line number Diff line number Diff line change
@@ -1,71 +1,107 @@
{ inputs, self, ... }:

{
perSystem = { pkgs, lib, ... }:
let
project = pkgs.haskell-nix.cabalProject' ({ config, pkgs, ... }: {
src = pkgs.haskell-nix.haskellLib.cleanSourceWith {
name = "kupo-src";
src = self;
# Filter out package.yaml files so plan-to-nix uses the
# pre-generated .cabal files instead. The package.yaml files
# `!include` .hpack.config.yaml via relative paths that the
# haskell.nix sandbox can't always resolve.
filter = path: type:
builtins.all (x: x) [
(baseNameOf path != "package.yaml")
];
};
name = "kupo";
compiler-nix-name = lib.mkDefault "ghc984";
inputs,
self,
...
}: {
perSystem = {
pkgs,
lib,
...
}: let
project = pkgs.haskell-nix.cabalProject' ({
config,
pkgs,
...
}: {
src = pkgs.haskell-nix.haskellLib.cleanSourceWith {
name = "kupo-src";
src = self;
# Filter out package.yaml files so plan-to-nix uses the
# pre-generated .cabal files instead. The package.yaml files
# `!include` .hpack.config.yaml via relative paths that the
# haskell.nix sandbox can't always resolve.
filter = path: type:
builtins.all (x: x) [
(baseNameOf path != "package.yaml")
];
};
name = "kupo";
compiler-nix-name = lib.mkDefault "ghc984";

inputMap = {
"https://input-output-hk.github.io/cardano-haskell-packages" = inputs.CHaP;
};
inputMap = {
"https://input-output-hk.github.io/cardano-haskell-packages" = inputs.CHaP;
};

# Mirrors source-repository-package entries in cabal.project so
# haskell.nix can fetch them deterministically.
sha256map = {
"https://github.com/CardanoSolutions/ogmios"."ae876badb138f42dcd6d2389734b0c15502684ed" = "sha256-xkOfOdX6Dxi7+VW78Tk3n3MoguIg39pKdxiNVfdeEwE=";
"https://github.com/CardanoSolutions/sqlite-simple"."08015be2ee52a7e67159b6b0c476bd3e0a2e0b87" = "1ahpjycsfibv09kzgfbm4i55z4nz1p3rvnmfwwwraxy45n1ivl85";
"https://github.com/CardanoSolutions/direct-sqlite"."2b14a78cb73805e2e5d84354230e872a223faa39" = "1lwaariy0zjjh006ll1zbpdi9sphyqmcbbxhb0rj99nii5s91fd7";
"https://github.com/CardanoSolutions/text-ansi"."e204822d2f343b2d393170a2ec46ee935571345c" = "16ki7wsf7wivxn65acv4hxwfrzmphq4zp61lpxwzqkgrg8shi8bv";
};
# Mirrors source-repository-package entries in cabal.project so
# haskell.nix can fetch them deterministically.
sha256map = {
"https://github.com/CardanoSolutions/ogmios"."ae876badb138f42dcd6d2389734b0c15502684ed" = "sha256-xkOfOdX6Dxi7+VW78Tk3n3MoguIg39pKdxiNVfdeEwE=";
"https://github.com/CardanoSolutions/sqlite-simple"."08015be2ee52a7e67159b6b0c476bd3e0a2e0b87" = "1ahpjycsfibv09kzgfbm4i55z4nz1p3rvnmfwwwraxy45n1ivl85";
"https://github.com/CardanoSolutions/direct-sqlite"."2b14a78cb73805e2e5d84354230e872a223faa39" = "1lwaariy0zjjh006ll1zbpdi9sphyqmcbbxhb0rj99nii5s91fd7";
"https://github.com/CardanoSolutions/text-ansi"."e204822d2f343b2d393170a2ec46ee935571345c" = "16ki7wsf7wivxn65acv4hxwfrzmphq4zp61lpxwzqkgrg8shi8bv";
};

modules = [
{
doHaddock = false;
packages.kupo.ghcOptions = [ "-Werror" ];
# GHC 9.8 enabled -Wx-partial by default; kupo was written for
# 9.6 and uses `Prelude.head` in a handful of test spots.
# Silence it under -Werror until the source is updated.
packages.kupo.components.tests.unit.ghcOptions = [ "-Wno-x-partial" ];
modules = [
{
doHaddock = false;
packages.kupo.ghcOptions = ["-Werror"];
# GHC 9.8 enabled -Wx-partial by default; kupo was written for
# 9.6 and uses `Prelude.head` in a handful of test spots.
# Silence it under -Werror until the source is updated.
packages.kupo.components.tests.unit.ghcOptions = ["-Wno-x-partial"];

# Tests use relative paths like `./test/vectors/...` and
# `./config/network/.../config.json`. The default test runCommand
# CWD is empty, so populate it with the vectors tree and the
# cardano-configurations submodule before invoking the binary.
packages.kupo.components.tests.unit.preCheck = ''
cp -r ${self}/test/vectors ./test/vectors
cp -r ${self}/config ./config
'';
}
({ pkgs, ... }: {
# Use the VRF fork of libsodium
packages = {
cardano-crypto-praos.components.library.pkgconfig = pkgs.lib.mkForce [
[ pkgs.libsodium-vrf ]
];
cardano-crypto-class.components.library.pkgconfig = pkgs.lib.mkForce [
[ pkgs.libsodium-vrf pkgs.secp256k1 pkgs.libblst ]
];
};
})
];
});
in
{
_module.args.hsPkgs = project.hsPkgs;
_module.args.shellFor = args: project.shellFor args;
};
# Tests use relative paths like `./test/vectors/...` and
# `./config/network/.../config.json`. The default test runCommand
# CWD is empty, so populate it with the vectors tree and the
# cardano-configurations submodule before invoking the binary.
packages.kupo.components.tests.unit.preCheck = ''
cp -r ${self}/test/vectors ./test/vectors
cp -r ${self}/config ./config
'';
}
({pkgs, ...}: {
# Use the VRF fork of libsodium
packages = {
cardano-crypto-praos.components.library.pkgconfig = pkgs.lib.mkForce [
[pkgs.libsodium-vrf]
];
cardano-crypto-class.components.library.pkgconfig = pkgs.lib.mkForce [
[pkgs.libsodium-vrf pkgs.secp256k1 pkgs.libblst]
];
};
})
# Musl libc fully static build
({
config,
lib,
pkgs,
...
}: {
options.packages = lib.genAttrs config.package-keys (_:
lib.mkOption {
type = lib.types.submodule (
{
config,
lib,
pkgs,
...
}:
lib.mkIf (pkgs.stdenv.hostPlatform.isMusl && config.package.isLocal)
{
enableShared = true; # TH code breaks if this is false
enableStatic = true;
}
);
});
config = lib.mkIf pkgs.stdenv.hostPlatform.isMusl {
doHaddock = false;
};
})
];
});
in {
_module.args.project = project;
_module.args.hsPkgs = project.hsPkgs;
_module.args.shellFor = args: project.shellFor args;
};
}
Loading