diff --git a/flake.lock b/flake.lock index ef47a49b4f3..08ecf85b761 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1749631879, - "narHash": "sha256-H7dxW3fRA8/U4u4GaR+YVnu6aKkev4GPTPgY524V5uM=", + "lastModified": 1751474634, + "narHash": "sha256-aB46saAQxsJRoqbxLhnSzC5Sbk0TxcdKIrHjNCjSlqQ=", "owner": "intersectmbo", "repo": "cardano-haskell-packages", - "rev": "2d1517e42e1ed5b19deb29c1c4fc9e30d360b961", + "rev": "d0da4a4a6b2548405a9e151394ec9a539106e74f", "type": "github" }, "original": { @@ -133,23 +133,25 @@ "type": "github" } }, - "flake-compat": { - "flake": false, + "easy-purescript-nix": { + "inputs": { + "flake-utils": "flake-utils" + }, "locked": { - "lastModified": 1733328505, - "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "lastModified": 1710161569, + "narHash": "sha256-lcIRIOFCdIWEGyKyG/tB4KvxM9zoWuBRDxW+T+mvIb0=", + "owner": "justinwoo", + "repo": "easy-purescript-nix", + "rev": "117fd96acb69d7d1727df95b6fde9d8715e031fc", "type": "github" }, "original": { - "owner": "edolstra", - "repo": "flake-compat", + "owner": "justinwoo", + "repo": "easy-purescript-nix", "type": "github" } }, - "flake-compat_2": { + "flake-compat": { "flake": false, "locked": { "lastModified": 1672831974, @@ -166,6 +168,21 @@ "type": "github" } }, + "flake-compat_2": { + "locked": { + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-compat_3": { "flake": false, "locked": { @@ -187,16 +204,51 @@ "systems": "systems" }, "locked": { - "lastModified": 1681378341, - "narHash": "sha256-2qUN04W6X9cHHytEsJTM41CmusifPTC0bgTtYsHSNY8=", - "owner": "hamishmack", + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", "repo": "flake-utils", - "rev": "2767bafdb189cd623354620c2dacbeca8fd58b17", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", "type": "github" }, "original": { - "owner": "hamishmack", - "ref": "hkm/nested-hydraJobs", + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "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" } @@ -237,7 +289,8 @@ "gitignore": { "inputs": { "nixpkgs": [ - "pre-commit-hooks", + "iogx", + "pre-commit-hooks-nix", "nixpkgs" ] }, @@ -255,14 +308,30 @@ "type": "github" } }, + "hackage": { + "flake": false, + "locked": { + "lastModified": 1751551600, + "narHash": "sha256-6U3H9aZYVcqrhMhLFC+6mhxkHLENyqlywc1G3WDc8pI=", + "owner": "input-output-hk", + "repo": "hackage.nix", + "rev": "4e9ac286650c3b6763c723bd132948407a96e53c", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "hackage.nix", + "type": "github" + } + }, "hackage-for-stackage": { "flake": false, "locked": { - "lastModified": 1748478380, - "narHash": "sha256-tL9oo3kqsGggwyu+6SzqmwvxMgP9TW4kYr7wrcT4F9Y=", + "lastModified": 1751675146, + "narHash": "sha256-S8XGmWI1tfbfg33xuQmJbCXfANPIGIdZ3jSeEOj8Fa0=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "4c1cfe985a6d2f0e8c6d903d2b5297fece257382", + "rev": "6273d5fac630e788362bbaf6aa1a9e70618d1742", "type": "github" }, "original": { @@ -272,14 +341,14 @@ "type": "github" } }, - "hackageNix": { + "hackage-internal": { "flake": false, "locked": { - "lastModified": 1749687986, - "narHash": "sha256-cEt2Hhbc0w0SqiadjZg4TJyn2+rKxW/15nmu4an79wo=", + "lastModified": 1750307553, + "narHash": "sha256-iiafNoeLHwlSLQTyvy8nPe2t6g5AV4PPcpMeH/2/DLs=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "0949afe39e6d249b6db126a96646d3f51a4a4c11", + "rev": "f7867baa8817fab296528f4a4ec39d1c7c4da4f3", "type": "github" }, "original": { @@ -288,23 +357,25 @@ "type": "github" } }, - "haskellNix": { + "haskell-nix": { "inputs": { "HTTP": "HTTP", "cabal-32": "cabal-32", "cabal-34": "cabal-34", "cabal-36": "cabal-36", "cardano-shell": "cardano-shell", - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat", "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", "hackage": [ - "hackageNix" + "hackage" ], "hackage-for-stackage": "hackage-for-stackage", + "hackage-internal": "hackage-internal", "hls": "hls", "hls-1.10": "hls-1.10", "hls-2.0": "hls-2.0", "hls-2.10": "hls-2.10", + "hls-2.11": "hls-2.11", "hls-2.2": "hls-2.2", "hls-2.3": "hls-2.3", "hls-2.4": "hls-2.4", @@ -316,23 +387,24 @@ "hpc-coveralls": "hpc-coveralls", "iserv-proxy": "iserv-proxy", "nixpkgs": [ - "haskellNix", + "haskell-nix", "nixpkgs-unstable" ], "nixpkgs-2305": "nixpkgs-2305", "nixpkgs-2311": "nixpkgs-2311", "nixpkgs-2405": "nixpkgs-2405", "nixpkgs-2411": "nixpkgs-2411", + "nixpkgs-2505": "nixpkgs-2505", "nixpkgs-unstable": "nixpkgs-unstable", "old-ghc-nix": "old-ghc-nix", "stackage": "stackage" }, "locked": { - "lastModified": 1748516483, - "narHash": "sha256-nqtbSbs2G/Ldjkt7KLgePqyDjd+zZtj3YxAbRk1M8wo=", + "lastModified": 1751676723, + "narHash": "sha256-EyLzUZ670DupEcShqAdmld0LMBuqeM44iVt5GzHyT+M=", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "7707658389458461553071792fa744f80663ee30", + "rev": "85f2f27286932b80987046e51460d3c4ba1bc749", "type": "github" }, "original": { @@ -408,6 +480,23 @@ "type": "github" } }, + "hls-2.11": { + "flake": false, + "locked": { + "lastModified": 1747306193, + "narHash": "sha256-/MmtpF8+FyQlwfKHqHK05BdsxC9LHV70d/FiMM7pzBM=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "46ef4523ea4949f47f6d2752476239f1c6d806fe", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.11.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, "hls-2.2": { "flake": false, "locked": { @@ -560,19 +649,58 @@ "type": "github" } }, - "iohkNix": { + "iogx": { + "inputs": { + "CHaP": [ + "CHaP" + ], + "easy-purescript-nix": "easy-purescript-nix", + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_2", + "hackage": [ + "hackage" + ], + "haskell-nix": [ + "haskell-nix" + ], + "iohk-nix": [ + "iohk-nix" + ], + "nix2container": "nix2container", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable", + "pre-commit-hooks-nix": "pre-commit-hooks-nix", + "sphinxcontrib-haddock": "sphinxcontrib-haddock" + }, + "locked": { + "lastModified": 1740037150, + "narHash": "sha256-OmAvyhPwJBEgaoyhtFqT60Lh3VoaKvq1s/0e1fZwAkc=", + "owner": "input-output-hk", + "repo": "iogx", + "rev": "0cec4b1b2b7dcaf3653fc32b3ff246e2ff173bb7", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "iogx", + "type": "github" + } + }, + "iohk-nix": { "inputs": { "blst": "blst", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_3", "secp256k1": "secp256k1", "sodium": "sodium" }, "locked": { - "lastModified": 1745582862, - "narHash": "sha256-dMoJ6yHcRvUcB66nofzfAtmVxnDg8oPW3wiVtimXT/o=", + "lastModified": 1751421193, + "narHash": "sha256-rklXDo12dfukaSqcEyiYbze3ffRtTl2/WAAQCWfkGiw=", "owner": "input-output-hk", "repo": "iohk-nix", - "rev": "5c16fdfc45deda7a4ccf964b6dfa1c3cab72f1f7", + "rev": "64ca6f4c0c6db283e2ec457c775bce75173fb319", "type": "github" }, "original": { @@ -584,11 +712,11 @@ "iserv-proxy": { "flake": false, "locked": { - "lastModified": 1747047742, - "narHash": "sha256-PCDULyZSIPdDdF8Lanbcy+Dl6AJ5z6H2ng3sRsv+gwc=", + "lastModified": 1750543273, + "narHash": "sha256-WaswH0Y+Fmupvv8AkIlQBlUy/IdD3Inx9PDuE+5iRYY=", "owner": "stable-haskell", "repo": "iserv-proxy", - "rev": "dea34de4bde325aca22472c18d659bee7800b477", + "rev": "a53c57c9a8d22a66a2f0c4c969e806da03f08c28", "type": "github" }, "original": { @@ -598,18 +726,36 @@ "type": "github" } }, + "nix2container": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1730479402, + "narHash": "sha256-79NLeNjpCa4mSasmFsE3QA6obURezF0TUO5Pm+1daog=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "5fb215a1564baa74ce04ad7f903d94ad6617e17a", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "nix2container", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1684171562, - "narHash": "sha256-BMUWjVWAUdyMWKk0ATMC9H0Bv4qAV/TXwwPUvTiC5IQ=", - "owner": "nixos", + "lastModified": 1712920918, + "narHash": "sha256-1yxFvUcJfUphK9V91KufIQom7gCsztza0H4Rz2VCWUU=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "55af203d468a6f5032a519cba4f41acf5a74b638", + "rev": "92323443a56f4e9fc4e4b712e3119f66d0969297", "type": "github" }, "original": { - "owner": "nixos", - "ref": "release-22.11", + "owner": "NixOS", "repo": "nixpkgs", "type": "github" } @@ -664,11 +810,11 @@ }, "nixpkgs-2411": { "locked": { - "lastModified": 1746566971, - "narHash": "sha256-I40weT0FZWth1IEjgR5a0zC9LLyrPwTC0DAQcejtTJE=", + "lastModified": 1748037224, + "narHash": "sha256-92vihpZr6dwEMV6g98M5kHZIttrWahb9iRPBm1atcPk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "209c5b3b0f5cf5b5a7e12ddea59bf19699f97e75", + "rev": "f09dede81861f3a83f7f06641ead34f02f37597f", "type": "github" }, "original": { @@ -678,13 +824,45 @@ "type": "github" } }, + "nixpkgs-2505": { + "locked": { + "lastModified": 1748852332, + "narHash": "sha256-r/wVJWmLYEqvrJKnL48r90Wn9HWX9SHFt6s4LhuTh7k=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a8167f3cc2f991dd4d0055746df53dae5fd0c953", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-25.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1690680713, + "narHash": "sha256-NXCWA8N+GfSQyoN7ZNiOgq/nDJKOp5/BHEpiZP8sUZw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b81af66deb21f73a70c67e5ea189568af53b1e8c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b81af66deb21f73a70c67e5ea189568af53b1e8c", + "type": "github" + } + }, "nixpkgs-unstable": { "locked": { - "lastModified": 1746576598, - "narHash": "sha256-FshoQvr6Aor5SnORVvh/ZdJ1Sa2U4ZrIMwKBX5k2wu0=", + "lastModified": 1748856973, + "narHash": "sha256-RlTsJUvvr8ErjPBsiwrGbbHYW8XbB/oek0Gi78XdWKg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b3582c75c7f21ce0b429898980eddbbf05c68e55", + "rev": "e4b09e47ace7d87de083786b404bf232eb6c89d8", "type": "github" }, "original": { @@ -710,6 +888,22 @@ "type": "github" } }, + "nixpkgs_3": { + "locked": { + "lastModified": 1751071626, + "narHash": "sha256-/uHE/AD2qGq4QLigWAnBHiVvpVXB04XAfrOtw8JMv+Y=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a47938d89bdf8e279ad432bd6a473cf4c430f48c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "release-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, "old-ghc-nix": { "flake": false, "locked": { @@ -727,18 +921,18 @@ "type": "github" } }, - "pre-commit-hooks": { + "pre-commit-hooks-nix": { "inputs": { "flake-compat": "flake-compat_3", "gitignore": "gitignore", "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1735882644, - "narHash": "sha256-3FZAG+pGt3OElQjesCAWeMkQ7C/nB1oTHLRQ8ceP110=", + "lastModified": 1737465171, + "narHash": "sha256-R10v2hoJRLq8jcL4syVFag7nIGE7m13qO48wRIukWNg=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "a5a961387e75ae44cc20f0a57ae463da5e959656", + "rev": "9364dc02281ce2d37a1f55b6e51f7c0f65a75f17", "type": "github" }, "original": { @@ -751,17 +945,15 @@ "inputs": { "CHaP": "CHaP", "cardano-mainnet-mirror": "cardano-mainnet-mirror", - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", "formal-ledger-specifications": "formal-ledger-specifications", - "hackageNix": "hackageNix", - "haskellNix": "haskellNix", - "iohkNix": "iohkNix", + "hackage": "hackage", + "haskell-nix": "haskell-nix", + "iogx": "iogx", + "iohk-nix": "iohk-nix", "nixpkgs": [ - "haskellNix", + "haskell-nix", "nixpkgs-unstable" - ], - "pre-commit-hooks": "pre-commit-hooks" + ] } }, "secp256k1": { @@ -798,14 +990,30 @@ "type": "github" } }, + "sphinxcontrib-haddock": { + "flake": false, + "locked": { + "lastModified": 1594136664, + "narHash": "sha256-O9YT3iCUBHP3CEF88VDLLCO2HSP3HqkNA2q2939RnVY=", + "owner": "michaelpj", + "repo": "sphinxcontrib-haddock", + "rev": "f3956b3256962b2d27d5a4e96edb7951acf5de34", + "type": "github" + }, + "original": { + "owner": "michaelpj", + "repo": "sphinxcontrib-haddock", + "type": "github" + } + }, "stackage": { "flake": false, "locked": { - "lastModified": 1748477586, - "narHash": "sha256-XlNzJApYAlnV+rPcFIHgxaA304jbfY00JbbkDpsd6bs=", + "lastModified": 1751674367, + "narHash": "sha256-9LSwfx+H+rJ6v/PuZj2BamaIPpasq07KCw+7WBUEQy4=", "owner": "input-output-hk", "repo": "stackage.nix", - "rev": "c04f95ad0731ff773c027ed1390aca827d9ca902", + "rev": "2b7caae5c8d26f6ed1176cf07962926d7d614451", "type": "github" }, "original": { @@ -828,6 +1036,36 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "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", diff --git a/flake.nix b/flake.nix index e685eddcd24..4840e064ea2 100644 --- a/flake.nix +++ b/flake.nix @@ -1,314 +1,81 @@ +# Docs for this file: https://github.com/input-output-hk/iogx/blob/main/doc/api.md#flakenix { description = "cardano-ledger"; inputs = { + iogx = { + url = "github:input-output-hk/iogx"; + inputs.hackage.follows = "hackage"; + inputs.CHaP.follows = "CHaP"; + inputs.haskell-nix.follows = "haskell-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.iohk-nix.follows = "iohk-nix"; + }; + + nixpkgs.follows = "haskell-nix/nixpkgs-unstable"; - hackageNix = { + hackage = { url = "github:input-output-hk/hackage.nix"; flake = false; }; - haskellNix = { - url = "github:input-output-hk/haskell.nix"; - inputs.hackage.follows = "hackageNix"; - }; - - nixpkgs.follows = "haskellNix/nixpkgs-unstable"; - iohkNix.url = "github:input-output-hk/iohk-nix"; - flake-utils.url = "github:hamishmack/flake-utils/hkm/nested-hydraJobs"; - CHaP = { url = "github:intersectmbo/cardano-haskell-packages?ref=repo"; flake = false; }; - cardano-mainnet-mirror = { - url = "github:input-output-hk/cardano-mainnet-mirror"; - flake = false; + haskell-nix = { + url = "github:input-output-hk/haskell.nix"; + inputs.hackage.follows = "hackage"; }; - # non-flake nix compatibility - flake-compat = { - url = "github:edolstra/flake-compat"; + cardano-mainnet-mirror = { + url = "github:input-output-hk/cardano-mainnet-mirror"; flake = false; }; - pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; - formal-ledger-specifications = { url = "github:IntersectMBO/formal-ledger-specifications"; flake = false; }; - }; - - outputs = inputs: let - supportedSystems = [ - "x86_64-linux" - "x86_64-darwin" - # "aarch64-linux" - disable these temporarily because the build is broken - "aarch64-darwin" - ]; - in - inputs.flake-utils.lib.eachSystem supportedSystems ( - system: let - # setup our nixpkgs with the haskell.nix overlays, and the iohk-nix - # overlays... - nixpkgs = import inputs.nixpkgs { - overlays = [ - # our local packages. - (import ./nix/pkgs.nix) - # iohkNix.overlays.crypto provide libsodium-vrf, libblst and libsecp256k1. - inputs.iohkNix.overlays.crypto - # haskellNix.overlay can be configured by later overlays, so need to come before them. - inputs.haskellNix.overlay - # configure haskell.nix to use iohk-nix crypto librairies. - inputs.iohkNix.overlays.haskell-nix-crypto - ]; - inherit system; - inherit (inputs.haskellNix) config; - }; - inherit (nixpkgs) lib; - # see flake `variants` below for alternative compilers - defaultCompiler = "ghc967"; - fourmoluVersion = "0.17.0.0"; - # We use cabalProject' to ensure we don't build the plan for - # all systems. - cabalProject = nixpkgs.haskell-nix.cabalProject' ({config, ...}: { - src = ./.; - name = "cardano-ledger"; - compiler-nix-name = lib.mkDefault defaultCompiler; + iohk-nix.url = "github:input-output-hk/iohk-nix"; + }; - # CHaP input map, so we can find CHaP packages (needs to be more - # recent than the index-state we set!). Can be updated with - # - # nix flake lock --update-input CHaP - # - inputMap = { - "https://chap.intersectmbo.org/" = inputs.CHaP; - "https://github.com/IntersectMBO/formal-ledger-specifications.git" = inputs.formal-ledger-specifications; - }; - cabalProjectLocal = '' - repository cardano-haskell-packages-local - url: file:${inputs.CHaP} - secure: True - active-repositories: hackage.haskell.org, cardano-haskell-packages-local - ''; + # Docs for mkFlake: https://github.com/input-output-hk/iogx/blob/main/doc/api.md#mkflake + outputs = inputs: + inputs.iogx.lib.mkFlake { - shell = { - # Due to plutus-tx-plugin being a bit special, we need to augment the default package selection. - packages = ps: builtins.attrValues (nixpkgs.haskell-nix.haskellLib.selectLocalPackages ps) ++ lib.optional (ps ? plutus-tx-plugin) ps.plutus-tx-plugin; + inherit inputs; - # force LANG to be UTF-8, otherwise GHC might choke on UTF encoded data. - shellHook = '' - export LANG=en_US.UTF-8 - export LC_ALL=en_US.UTF-8 - export CARDANO_MAINNET_MIRROR="${inputs.cardano-mainnet-mirror}/epochs" - '' + lib.optionalString (nixpkgs.glibcLocales != null && nixpkgs.stdenv.hostPlatform.libc == "glibc") '' - export LOCALE_ARCHIVE="${nixpkgs.glibcLocales}/lib/locale/locale-archive" - DEFAULT_PS1="\n\[\033[1;32m\][nix-shell:\w]\$\[\033[0m\] " - prompt() { - local EXIT="$?" - if [ $EXIT != 0 ]; then - PS1="$DEFAULT_PS1\[\033[1;31m\]($EXIT)\[\033[00m\] " - else - PS1="$DEFAULT_PS1" - fi - } - PROMPT_COMMAND=prompt - ''; + repoRoot = ./.; - # tools we want in our shell, from hackage - tools = - { - cabal = "3.14.1.0"; - } - // lib.optionalAttrs (config.compiler-nix-name == defaultCompiler) { - # tools that work only with default compiler - fourmolu = fourmoluVersion; - hlint = "3.8"; - haskell-language-server = "2.9.0.0"; - cabal-gild = "1.5.0.1"; - }; + outputs = import ./nix/outputs.nix; - # and from nixpkgs or other inputs - nativeBuildInputs = with nixpkgs; - [ - (python3.withPackages (ps: with ps; [sphinx sphinx_rtd_theme recommonmark sphinx-markdown-tables sphinxemoji])) - haskellPackages.implicit-hie - shellcheck - ] ++ - (let - doctest = haskell-nix.hackage-package { - name = "doctest"; - version = "0.24.0"; - configureArgs = "-f cabal-doctest"; - inherit (config) compiler-nix-name; - }; - in - [ - (doctest.getComponent "exe:cabal-doctest") - (doctest.getComponent "exe:doctest") - ]); - # disable Hoogle until someone request it - withHoogle = false; - # Skip cross compilers for the shell - crossPlatforms = _: []; - }; + systems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + # "aarch64-linux" + ]; - # package customizations as needed. Where cabal.project is not - # specific enough, or doesn't allow setting these. - modules = [ - ({pkgs, ...}: { - # packages.plutus-core.components.library.ghcOptions = [ "-fexternal-interpreter" ]; - # uncomment if necessary when profiling - packages.byron-spec-chain.configureFlags = ["--ghc-option=-Werror"]; - packages.byron-spec-ledger.configureFlags = ["--ghc-option=-Werror"]; - packages.non-integral.configureFlags = ["--ghc-option=-Werror"]; - packages.cardano-ledger-shelley.configureFlags = ["--ghc-option=-Werror"]; - packages.cardano-ledger-shelley-ma-test.configureFlags = ["--ghc-option=-Werror"]; - packages.small-steps.configureFlags = ["--ghc-option=-Werror"]; - packages.cardano-ledger-byron = { - configureFlags = ["--ghc-option=-Werror"]; - components = { - tests.tests = { - preCheck = '' - export CARDANO_MAINNET_MIRROR="${inputs.cardano-mainnet-mirror}/epochs" - ''; - testFlags = ["--scenario=ContinuousIntegration"]; - }; - }; - }; - }) - ({pkgs, ...}: - lib.mkIf pkgs.stdenv.hostPlatform.isUnix { - packages.cardano-ledger-shelley.components.tests.tests.build-tools = [pkgs.cddl pkgs.cbor-diag]; - packages.cardano-ledger-allegra.components.tests.tests.build-tools = [pkgs.cddl pkgs.cbor-diag]; - packages.cardano-ledger-mary.components.tests.tests.build-tools = [pkgs.cddl pkgs.cbor-diag]; - packages.cardano-ledger-alonzo.components.tests.tests.build-tools = [pkgs.cddl pkgs.cbor-diag]; - packages.cardano-ledger-babbage.components.tests.tests.build-tools = [pkgs.cddl pkgs.cbor-diag]; - packages.cardano-ledger-conway.components.tests.tests.build-tools = [pkgs.cddl pkgs.cbor-diag]; - packages.cardano-protocol-tpraos.components.tests.tests.build-tools = [pkgs.cddl pkgs.cbor-diag]; - }) - ({pkgs, ...}: - lib.mkIf pkgs.stdenv.hostPlatform.isWindows { - packages.set-algebra.components.tests.tests.buildable = lib.mkForce false; - packages.plutus-preprocessor.buildable = lib.mkForce false; - packages.cardano-ledger-test.buildable = lib.mkForce false; - packages.cardano-ledger-shelley.buildable = lib.mkForce false; - packages.cardano-ledger-allegra.buildable = lib.mkForce false; - packages.cardano-ledger-mary.buildable = lib.mkForce false; - packages.cardano-ledger-alonzo.buildable = lib.mkForce false; - packages.cardano-ledger-babbage.buildable = lib.mkForce false; - packages.cardano-ledger-conway.buildable = lib.mkForce false; - packages.cardano-protocol-tpraos.buildable = lib.mkForce false; - }) - ]; - }); - # ... and construct a flake from the cabal project - flake = - cabalProject.flake ( - lib.optionalAttrs (system == "x86_64-linux") { - # on linux, build/test other supported compilers - variants = lib.genAttrs ["ghc967" "ghc9121"] (compiler-nix-name: { - inherit compiler-nix-name; - }); - } - ); - in - lib.recursiveUpdate flake rec { - project = cabalProject; - # add a required job, that's basically all hydraJobs. - hydraJobs = - nixpkgs.callPackages inputs.iohkNix.utils.ciJobsAggregates - { - ciJobs = - flake.hydraJobs - // { - inherit (legacyPackages) doc specs; + # TODO: remove before merge + debug = true; - # This ensure hydra send a status for the required job (even if no change other than commit hash) - revision = nixpkgs.writeText "revision" (inputs.self.rev or "dirty"); - }; - }; - legacyPackages = rec { - inherit cabalProject nixpkgs; - # also provide hydraJobs through legacyPackages to allow building without system prefix: - inherit hydraJobs; - doc.site = ((import ./doc/flake.nix).outputs {main = inputs.self;}).packages.${system}.default; - # - # PDF builds of LaTeX documentation. - # - # To download the latest PDF build from Hydra, use this link: - # https://github.com/intersectmbo/cardano-ledger/releases/latest/download/NAME.pdf - # - # To get a shell where you can run pdflatex to build it yourself, use: - # cd - # nix develop - # - # To build all specs locally with Nix: - # nix build .#specs -o spec - # - specs = nixpkgs.symlinkJoin { - name = "cardano-ledger-specs"; - # XXX: make use of flake relative path inputs once this is fixed: https://github.com/NixOS/nix/issues/6352 - # (so that we can ditch flake-compat.nix) - paths = map (d: ((import "${./.}/${d}/flake.nix").outputs {main = inputs.self;}).packages.${system}.default) [ - "eras/byron/ledger/formal-spec" - "eras/byron/chain/formal-spec" - "eras/shelley/formal-spec" - "eras/shelley-ma/formal-spec" - "eras/alonzo/formal-spec" - "eras/babbage/formal-spec" - "eras/shelley/design-spec" - "docs/small-step-semantics" - "docs/pool-ranking" - "docs/non-integer-calculations" - "eras/byron/ledger/impl/cddl-spec" - ]; - }; - }; + nixpkgsArgs = { + config = {}; + overlays = [ + (import ./nix/pkgs.nix) + ]; + }; - devShells = let - mkDevShells = p: { - # `nix develop .#profiling` (or `.#ghc967.profiling): a shell with profiling enabled - profiling = (p.appendModule {modules = [{enableLibraryProfiling = true;}];}).shell; - # `nix develop .#pre-commit` (or `.#ghc967.pre-commit): a shell with pre-commit enabled - pre-commit = let - pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run { - src = ./.; - hooks = { - fourmolu.enable = true; - }; - tools = { - fourmolu = p.tool "fourmolu" fourmoluVersion; - }; - }; - in - p.shell.overrideAttrs (old: { - shellHook = old.shellHook + pre-commit-check.shellHook; - }); - }; - in - mkDevShells cabalProject - # Additional shells for every GHC version supported by haskell.nix, eg. `nix develop .#ghc9121` - // lib.mapAttrs (compiler-nix-name: _: let - p = cabalProject.appendModule {inherit compiler-nix-name;}; - in - p.shell // (mkDevShells p)) - nixpkgs.haskell-nix.compiler; - # formatter used by nix fmt - formatter = nixpkgs.alejandra; - } - ); + # flake = { repoRoot, inputs }: {}; + }; nixConfig = { - extra-substituters = [ - "https://cache.iog.io" - ]; - extra-trusted-public-keys = [ - "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" - ]; + extra-substituters = [ "https://cache.iog.io" ]; + extra-trusted-public-keys = + [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ]; allow-import-from-derivation = true; }; } diff --git a/nix/outputs.nix b/nix/outputs.nix new file mode 100644 index 00000000000..3d955297a9f --- /dev/null +++ b/nix/outputs.nix @@ -0,0 +1,16 @@ +{ repoRoot, inputs, pkgs, lib, system }: + +let + + project = repoRoot.nix.project; + +in [ + ( + # Docs for project.flake: https://github.com/input-output-hk/iogx/blob/main/doc/api.md#mkhaskellprojectoutflake + project.flake) + { + devShells = lib.genAttrs (lib.attrNames project.variants) (variantName: + project.variants."${variantName}".devShell + ); + } +] diff --git a/nix/project.nix b/nix/project.nix new file mode 100644 index 00000000000..df2fa0e91a4 --- /dev/null +++ b/nix/project.nix @@ -0,0 +1,119 @@ +{ repoRoot, inputs, pkgs, system, lib }: + +let + supportedCompilers = [ + # "ghc967" -- broken + "ghc9121" + ]; + + variants = lib.genAttrs supportedCompilers (compiler-nix-name: { + inherit compiler-nix-name; + }); + + cabalProject' = pkgs.haskell-nix.cabalProject' ({ pkgs, config, ... }: + let + # When `isCross` is `true`, it means that we are cross-compiling the project. + # WARNING You must use the `pkgs` coming from cabalProject' for `isCross` to work. + isCross = pkgs.stdenv.hostPlatform != pkgs.stdenv.buildPlatform; + in { + src = ../.; + + shell.withHoogle = false; + + inputMap = { + "https://chap.intersectmbo.org/" = inputs.CHaP; + "https://github.com/IntersectMBO/formal-ledger-specifications.git" = inputs.formal-ledger-specifications; + }; + + name = "cardano-ledger"; + + compiler-nix-name = lib.mkDefault "ghc966"; + + flake.variants = variants // { + profiled = { + modules = [{ + enableProfiling = true; + # enableLibraryProfiling = true; + }]; + }; + }; + + cabalProjectLocal = '' + repository cardano-haskell-packages-local + url: file:${inputs.CHaP} + secure: True + active-repositories: hackage.haskell.org, cardano-haskell-packages-local + ''; + + modules = [ + ({pkgs, ...}: { + # packages.plutus-core.components.library.ghcOptions = [ "-fexternal-interpreter" ]; + # uncomment if necessary when profiling + packages.byron-spec-chain.ghcOptions = ["-Werror"]; + packages.byron-spec-ledger.ghcOptions = ["-Werror"]; + packages.non-integral.ghcOptions = ["-Werror"]; + packages.cardano-ledger-shelley.ghcOptions = ["-Werror"]; + packages.cardano-ledger-shelley-ma-test.ghcOptions = ["-Werror"]; + packages.small-steps.ghcOptions = ["-Werror"]; + packages.cardano-ledger-byron = { + ghcOptions = ["-Werror"]; + components = { + tests.tests = { + preCheck = '' + export CARDANO_MAINNET_MIRROR="${inputs.cardano-mainnet-mirror}/epochs" + ''; + testFlags = ["--scenario=ContinuousIntegration"]; + }; + }; + }; + }) + ({pkgs, ...}: + lib.mkIf pkgs.stdenv.hostPlatform.isUnix { + packages.cardano-ledger-shelley.components.tests.tests.build-tools = [pkgs.cddl pkgs.cbor-diag]; + packages.cardano-ledger-allegra.components.tests.tests.build-tools = [pkgs.cddl pkgs.cbor-diag]; + packages.cardano-ledger-mary.components.tests.tests.build-tools = [pkgs.cddl pkgs.cbor-diag]; + packages.cardano-ledger-alonzo.components.tests.tests.build-tools = [pkgs.cddl pkgs.cbor-diag]; + packages.cardano-ledger-babbage.components.tests.tests.build-tools = [pkgs.cddl pkgs.cbor-diag]; + packages.cardano-ledger-conway.components.tests.tests.build-tools = [pkgs.cddl pkgs.cbor-diag]; + packages.cardano-protocol-tpraos.components.tests.tests.build-tools = [pkgs.cddl pkgs.cbor-diag]; + }) + ({pkgs, ...}: + lib.mkIf pkgs.stdenv.hostPlatform.isWindows { + packages.set-algebra.components.tests.tests.buildable = lib.mkForce false; + packages.plutus-preprocessor.buildable = lib.mkForce false; + packages.cardano-ledger-test.buildable = lib.mkForce false; + packages.cardano-ledger-shelley.buildable = lib.mkForce false; + packages.cardano-ledger-allegra.buildable = lib.mkForce false; + packages.cardano-ledger-mary.buildable = lib.mkForce false; + packages.cardano-ledger-alonzo.buildable = lib.mkForce false; + packages.cardano-ledger-babbage.buildable = lib.mkForce false; + packages.cardano-ledger-conway.buildable = lib.mkForce false; + packages.cardano-protocol-tpraos.buildable = lib.mkForce false; + }) + ]; + }); + + cabalProject = cabalProject'.appendOverlays [ ]; + + # Docs for mkHaskellProject: https://github.com/input-output-hk/iogx/blob/main/doc/api.md#mkhaskellproject + project = lib.iogx.mkHaskellProject { + inherit cabalProject; + + shellArgs = repoRoot.nix.shell; + + readTheDocs = { + enable = false; # TODO: broken + siteFolder = "doc"; + # sphinxToolchain = pkgs.python3.withPackages (py: [ + # py.sphinx + # py.sphinx_rtd_theme + # py.sphinx-markdown-tables + # py.sphinxemoji + # py.recommonmark + # for regenerating requirements.txt + # py.pip-tools + # ]); + }; + }; + +in project diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 00000000000..2cee43cfe55 --- /dev/null +++ b/nix/shell.nix @@ -0,0 +1,63 @@ +# Docs for this file: https://github.com/input-output-hk/iogx/blob/main/doc/api.md#mkhaskellprojectinshellargs + +{ repoRoot, inputs, pkgs, lib, system }: + +# Each flake variant defined in your project.nix project will yield a separate +# shell. If no flake variants are defined, then cabalProject is the original +# project. +cabalProject: + +{ + name = "nix-shell"; + + # prompt = null; + + # welcomeMessage = null; + + packages = with pkgs; + [ + haskellPackages.implicit-hie + ] ++ + (let + doctest = haskell-nix.hackage-package { + name = "doctest"; + version = "0.24.0"; + configureArgs = "-f cabal-doctest"; + inherit (cabalProject.args) compiler-nix-name; + }; + in + [ + (doctest.getComponent "exe:cabal-doctest") + (doctest.getComponent "exe:doctest") + ]); + + env = { + LANG = "en_US.UTF-8"; + LC_ALL = "en_US.UTF-8"; + CARDANO_MAINNET_MIRROR = "${inputs.cardano-mainnet-mirror}/epochs"; + LOCALE_ARCHIVE = lib.optionalString (pkgs.glibcLocales != null && pkgs.stdenv.hostPlatform.libc == "glibc") + "{pkgs.glibcLocales}/lib/locale/locale-archive"; + }; + + shellHook = '' + DEFAULT_PS1="\n\[\033[1;32m\][nix-shell:\w]\$\[\033[0m\] " + prompt() { + local EXIT="$?" + if [ $EXIT != 0 ]; then + PS1="$DEFAULT_PS1\[\033[1;31m\]($EXIT)\[\033[00m\] " + else + PS1="$DEFAULT_PS1" + fi + } + PROMPT_COMMAND=prompt + ''; + + tools = { + haskellCompilerVersion = cabalProject.args.compiler-nix-name; + # haskell-language-server = cabalProject.tool "haskell-language-server" "2.9.0.0"; + # fourmolu = cabalProject.tool "fourmolu" "0.18.0.0"; + # hlint = cabalProject.tool "hlint" "3.8"; + }; + + # preCommit = {}; +}