├── .github └── workflows │ ├── github-action.yml │ └── release.yml ├── .gitignore ├── README.md ├── bors.toml ├── cardano-lib ├── default.nix ├── explorer-log-config.nix ├── generic-log-config.nix ├── mainnet-config-bp.nix ├── mainnet-config.nix ├── mainnet │ ├── alonzo-genesis.json │ ├── byron-genesis.json │ ├── checkpoints.json │ ├── conway-genesis.json │ ├── peer-snapshot.json │ └── shelley-genesis.json ├── preprod-config-bp.nix ├── preprod-config.nix ├── preprod │ ├── alonzo-genesis.json │ ├── byron-genesis.json │ ├── conway-genesis.json │ ├── peer-snapshot.json │ └── shelley-genesis.json ├── preview-config-bp.nix ├── preview-config.nix ├── preview │ ├── alonzo-genesis.json │ ├── byron-genesis.json │ ├── conway-genesis.json │ ├── peer-snapshot.json │ └── shelley-genesis.json └── testnet-template │ ├── Readme.md │ ├── alonzo.json │ ├── byron.json │ ├── config.json │ ├── conway.json │ ├── shelley.json │ └── topology-empty-p2p.json ├── changelog.md ├── ci.nix ├── ci ├── aggregates.nix ├── cabal-project-regenerate │ ├── cabal-project-regenerate.py │ └── default.nix ├── check-hydra.nix ├── check-hydra.sh ├── check-source-repo-tags-on-master.nix ├── check-stack-project.nix ├── hydra-eval-errors │ ├── bin │ │ └── hydra-eval-errors.py │ ├── default.nix │ └── setup.py └── sha256map-regenerate │ ├── default.nix │ └── sha256map-regenerate.py ├── default.nix ├── fetch-tarball-with-override.nix ├── flake.lock ├── flake.nix ├── jormungandr-lib ├── calculate_hashes.nix ├── default.nix ├── genesis-beta.yaml ├── genesis-itn_rewards_v1.yaml ├── genesis-legacy.yaml ├── genesis-nightly.yaml ├── genesis-qa.yaml ├── sync.cr └── versions.json ├── lib ├── default.nix └── release-lib.nix ├── maybe-env.nix ├── nix ├── default.nix ├── sources.json └── sources.nix ├── overlays ├── crypto │ ├── default.nix │ ├── libblst.nix │ ├── libsecp256k1.nix │ └── libsodium.nix ├── haskell-nix-crypto │ └── default.nix ├── haskell-nix-extra │ ├── default.nix │ ├── nix-tools-regenerate.nix │ └── utils │ │ ├── .gitignore │ │ ├── Setup.hs │ │ ├── default.nix │ │ ├── iohk-nix-utils.cabal │ │ ├── lib │ │ ├── Build.hs │ │ ├── BuildArgs.hs │ │ └── CommonBuild.hs │ │ ├── rewrite-libs.hs │ │ ├── set-git-rev.hs │ │ └── stack.yaml ├── rust │ ├── cardano-cli.nix │ ├── cardano-http-bridge-emurgo.nix │ ├── cardano-http-bridge.nix │ ├── channel-rust-stable.toml │ ├── default.nix │ ├── jormungandr.nix │ ├── mozilla.nix │ └── patches │ │ └── 0001-update-Cargo.lock.patch └── utils │ └── default.nix ├── pkgs ├── cabal-wrapper.nix └── stack-cabal-sync-shell.nix ├── release.nix ├── shell.nix ├── supervisord └── default.nix └── tests ├── fix-stylish-haskell.nix ├── fourmolu.nix ├── hlint.nix ├── shellcheck.nix └── stylish-haskell.nix /.github/workflows/github-action.yml: -------------------------------------------------------------------------------- 1 | name: Validate IOG Core GH Action 2 | on: push 3 | jobs: 4 | integration: 5 | strategy: 6 | fail-fast: false 7 | matrix: 8 | os: [ubuntu-latest, windows-latest, macos-latest] 9 | name: GitHub Action integration test 10 | runs-on: ${{ matrix.os }} 11 | steps: 12 | - uses: input-output-hk/actions/base@latest 13 | - name: Check pkg-config 14 | run: | 15 | pkg-config --libs libblst 16 | pkg-config --libs libsodium 17 | pkg-config --libs libsecp256k1 18 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v3 14 | - name: Install nix 15 | uses: cachix/install-nix-action@v20 16 | with: 17 | nix_path: nixpkgs=https://github.com/nixos/nixpkgs/archive/release-22.11.tar.gz 18 | extra_nix_config: | 19 | trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk= 20 | substituters = https://cache.nixos.org/ https://cache.iog.io/ https://cache.zw3rk.com/ 21 | - name: Build 22 | uses: workflow/nix-shell-action@v3.2.1 23 | with: 24 | packages: zip 25 | script: | 26 | mkdir __pkgs 27 | echo ${{ github.sha }} > __pkgs/COMMIT_SHA 28 | for sys in msys2 macos x86_64-macos arm64-macos debian; do 29 | for lib in libsodium libsodium-vrf libsecp256k1 libblst; do 30 | out=$(nix build .#dist.$sys.$lib --no-link --print-out-paths -L) 31 | for ext in pkg.tar.zstd pkg deb; do 32 | if [ -f "$out"/*."$ext" ]; then 33 | cp "$out"/*."$ext" __pkgs/"$sys.$lib.$ext" 34 | base=$(basename "$out"/*."$ext") 35 | echo -e "$sys.$lib.$ext\t$base" >> __pkgs/INFO 36 | fi 37 | done 38 | done 39 | (cd __pkgs && zip -9 $sys.zip $sys.*) 40 | done 41 | - name: Release 42 | uses: softprops/action-gh-release@v1 43 | with: 44 | files: __pkgs/* 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /result* 2 | \#*\# 3 | *.*~ 4 | *.bak 5 | 6 | ## Editor artifacts and configuration files 7 | TAGS 8 | .dir-locals.el 9 | *.md.temp 10 | 11 | ## Stack artifacts 12 | stack.yaml.lock 13 | result* 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IOHK Common Nix Code 2 | 3 | This repo contains build code and tools shared between IOHK projects. 4 | 5 | 1. Some util functions such as source filtering or helpers for [Haskell.nix](https://github.com/input-output-hk/haskell.nix). 6 | 2. Customized libraries (as an overlay for [nixpkgs](https://github.com/nixos/nixpkgs). 7 | 2. Nix builds of development tools such as cache-s3. 8 | 9 | ## When making changes to `iohk-nix` 10 | 11 | Please document any change that might affect project builds in the 12 | [ChangeLog](./changelog.md). For example: 13 | 14 | - Bumping `nixpkgs` to a different branch. 15 | - Changing API (renaming attributes, changing function parameters, etc). 16 | -------------------------------------------------------------------------------- /bors.toml: -------------------------------------------------------------------------------- 1 | status = [ 2 | "ci/hydra-eval", 3 | "ci/hydra-build:required", 4 | "buildkite/iohk-nix" 5 | ] 6 | timeout_sec = 7200 7 | required_approvals = 1 8 | block_labels = [ "WIP", "DO NOT MERGE" ] 9 | delete_merged_branches = true 10 | -------------------------------------------------------------------------------- /cardano-lib/explorer-log-config.nix: -------------------------------------------------------------------------------- 1 | { 2 | # global filter; messages must have at least this severity to pass: 3 | minSeverity = "Info"; 4 | 5 | EnableLogging = true; 6 | EnableLogMetrics = false; 7 | 8 | # global file rotation settings: 9 | rotation = { 10 | rpLogLimitBytes = 5000000; 11 | rpKeepFilesNum = 10; 12 | rpMaxAgeHours = 24; 13 | }; 14 | 15 | # these backends are initialized: 16 | setupBackends = [ 17 | "AggregationBK" 18 | "KatipBK" 19 | ]; 20 | 21 | # if not indicated otherwise, then messages are passed to these backends: 22 | defaultBackends = [ 23 | "KatipBK" 24 | ]; 25 | 26 | # if wanted, the GUI is listening on this port: 27 | # hasGUI: 12787 28 | 29 | # if wanted, the EKG interface is listening on this port: 30 | PrometheusPort = 8080; 31 | 32 | # here we set up outputs of logging in 'katip': 33 | setupScribes = [ 34 | { 35 | scKind = "StdoutSK"; 36 | scName = "stdout"; 37 | scFormat = "ScText"; 38 | scRotation = null; 39 | } 40 | ]; 41 | 42 | # if not indicated otherwise, then log output is directed to this: 43 | defaultScribes = [ 44 | [ 45 | "StdoutSK" 46 | "stdout" 47 | ] 48 | ]; 49 | 50 | # more options which can be passed as key-value pairs: 51 | options = { 52 | cfokey = { 53 | value = "Release-1.0.0"; 54 | }; 55 | mapSubtrace = { 56 | benchmark = { 57 | contents = [ 58 | "GhcRtsStats" 59 | "MonotonicClock" 60 | ]; 61 | subtrace = "ObservableTrace"; 62 | }; 63 | "#ekgview" = { 64 | contents = [ 65 | [ 66 | { 67 | tag = "Contains"; 68 | contents = "cardano.epoch-validation.benchmark"; 69 | } 70 | [ 71 | { 72 | tag = "Contains"; 73 | contents = ".monoclock.basic."; 74 | } 75 | ] 76 | ] 77 | [ 78 | { 79 | tag = "Contains"; 80 | contents = "cardano.epoch-validation.benchmark"; 81 | } 82 | [ 83 | { 84 | tag = "Contains"; 85 | contents = "diff.RTS.cpuNs.timed."; 86 | } 87 | ] 88 | ] 89 | [ 90 | { 91 | tag = "StartsWith"; 92 | contents = "#ekgview.#aggregation.cardano.epoch-validation.benchmark"; 93 | } 94 | [ 95 | { 96 | tag = "Contains"; 97 | contents = "diff.RTS.gcNum.timed."; 98 | } 99 | ] 100 | ] 101 | ]; 102 | subtrace = "FilterTrace"; 103 | }; 104 | "cardano.epoch-validation.utxo-stats" = { 105 | # Change the `subtrace` value to `Neutral` in order to log 106 | # `UTxO`-related messages during epoch validation. 107 | subtrace = "NoTrace"; 108 | }; 109 | "#messagecounters.aggregation" = { 110 | subtrace = "NoTrace"; 111 | }; 112 | "#messagecounters.ekgview" = { 113 | subtrace = "NoTrace"; 114 | }; 115 | "#messagecounters.switchboard" = { 116 | subtrace = "NoTrace"; 117 | }; 118 | "#messagecounters.katip" = { 119 | subtrace = "NoTrace"; 120 | }; 121 | "#messagecounters.monitoring" = { 122 | subtrace = "NoTrace"; 123 | }; 124 | }; 125 | mapBackends = { 126 | }; 127 | mapSeverity = { 128 | "db-sync-node.Subscription" = "Error"; 129 | "db-sync-node.Mux" = "Error"; 130 | "db-sync-node" = "Info"; 131 | }; 132 | }; 133 | } 134 | -------------------------------------------------------------------------------- /cardano-lib/generic-log-config.nix: -------------------------------------------------------------------------------- 1 | { 2 | # Enable or disable logging overall 3 | TurnOnLogging = true; 4 | 5 | # Enable the collection of various OS metrics such as memory and CPU use. 6 | # These metrics can be directed to the logs or monitoring backends. 7 | TurnOnLogMetrics = true; 8 | 9 | # Global logging severity filter. Messages must have at least this severity to 10 | # pass. Typical values would be Warning, Notice, Info or Debug. 11 | minSeverity = "Info"; 12 | 13 | # Log items can be rendered with more or less verbose detail. 14 | # The verbosity can be: MinimalVerbosity, NormalVerbosity 15 | TracingVerbosity = "NormalVerbosity"; 16 | 17 | # Use legacy tracing 18 | UseTraceDispatcher = false; 19 | 20 | # The system supports a number of backends for logging and monitoring. 21 | # This setting lists the the backends that will be available to use in the 22 | # configuration below. The logging backend is called Katip. Also enable the EKG 23 | # backend if you want to use the EKG or Prometheus monitoring interfaces. 24 | setupBackends = [ 25 | "KatipBK" 26 | # EKGViewBK 27 | ]; 28 | 29 | # This specifies the default backends that trace output is sent to if it 30 | # is not specifically configured to be sent to other backends. 31 | defaultBackends = [ 32 | "KatipBK" 33 | ]; 34 | 35 | # EKG is a simple metrics monitoring system. Uncomment the following to listen 36 | # on the given local port and point your web browser to http://localhost:12788/ 37 | # for a live view. The same URL can also serve JSON output. 38 | hasEKG = 12788; 39 | 40 | # The Prometheus monitoring system can also be used. Uncomment the following 41 | # to listen on the given port 42 | hasPrometheus = ["127.0.0.1" 12798]; 43 | 44 | # For the Katip logging backend we must set up outputs (called scribes) 45 | # The available types of scribe are: 46 | # FileSK for files 47 | # StdoutSK/StdoutSK for stdout/stderr 48 | # JournalSK for systemd's journal system 49 | # DevNullSK 50 | # The scribe output format can be ScText or ScJson. Log rotation settings can 51 | # be specified in the defaults below or overidden on a per-scribe basis here. 52 | setupScribes = [ 53 | { 54 | scKind = "StdoutSK"; 55 | scName = "stdout"; 56 | scFormat = "ScText"; 57 | scRotation = null; 58 | } 59 | ]; 60 | 61 | # For the Katip logging backend this specifies the default scribes that trace 62 | # output is sent to if it is not configured to be sent to other scribes. 63 | defaultScribes = [ 64 | [ 65 | "StdoutSK" 66 | "stdout" 67 | ] 68 | ]; 69 | 70 | # The default file rotation settings for katip scribes, unless overridden 71 | # in the setupScribes above for specific scribes. 72 | rotation = { 73 | rpLogLimitBytes = 5000000; 74 | rpKeepFilesNum = 10; 75 | rpMaxAgeHours = 24; 76 | }; 77 | 78 | ##### Coarse grained logging control ##### 79 | 80 | # Trace output from whole subsystems can be enabled/disabled using the following 81 | # settings. This provides fairly coarse grained control, but it is relatively 82 | # efficient at filtering out unwanted trace output. 83 | 84 | # Trace BlockFetch client. 85 | TraceBlockFetchClient = false; 86 | 87 | # Trace BlockFetch decisions made by the BlockFetch client. 88 | TraceBlockFetchDecisions = false; 89 | 90 | # Trace BlockFetch protocol messages. 91 | TraceBlockFetchProtocol = false; 92 | 93 | # Serialised Trace BlockFetch protocol messages. 94 | TraceBlockFetchProtocolSerialised = false; 95 | 96 | # Trace BlockFetch server. 97 | TraceBlockFetchServer = false; 98 | 99 | # Verbose tracer of ChainDB 100 | TraceChainDb = true; 101 | 102 | # Trace ChainSync client. 103 | TraceChainSyncClient = false; 104 | 105 | # Trace ChainSync server (blocks). 106 | TraceChainSyncBlockServer = false; 107 | 108 | # Trace ChainSync server (headers) 109 | TraceChainSyncHeaderServer = false; 110 | 111 | # Trace ChainSync protocol messages. 112 | TraceChainSyncProtocol = false; 113 | 114 | # Trace connection manager 115 | TraceConnectionManager = true; 116 | 117 | # Trace diffusion initialization messages 118 | TraceDiffusionInitialization = true; 119 | 120 | # Trace DNS Resolver messages. 121 | TraceDNSResolver = true; 122 | 123 | # Trace DNS Subscription messages. 124 | TraceDNSSubscription = true; 125 | 126 | TraceAcceptPolicy = true; 127 | 128 | # Trace error policy resolution. 129 | TraceErrorPolicy = true; 130 | 131 | # Trace local error policy resolution. 132 | TraceLocalErrorPolicy = true; 133 | 134 | # Trace block forging. 135 | TraceForge = true; 136 | 137 | # Trace Handshake protocol messages. 138 | TraceHandshake = true; 139 | 140 | TraceInboundGovernor = true; 141 | 142 | # Trace IP Subscription messages. 143 | TraceIpSubscription = true; 144 | 145 | # Trace ledger peers. 146 | TraceLedgerPeers = true; 147 | 148 | # Trace local ChainSync protocol messages. 149 | TraceLocalChainSyncProtocol = false; 150 | 151 | # Trace local Handshake protocol messages. 152 | TraceLocalHandshake = true; 153 | 154 | # Trace local root peers 155 | TraceLocalRootPeers = true; 156 | 157 | # Trace local TxSubmission protocol messages. 158 | TraceLocalTxSubmissionProtocol = false; 159 | 160 | # Trace local TxSubmission server. 161 | TraceLocalTxSubmissionServer = false; 162 | 163 | # Trace local Connection Manager. 164 | TraceLocalConnectionManager = true; 165 | 166 | # Trace mempool. 167 | TraceMempool = true; 168 | 169 | # Trace Mux Events 170 | TraceMux = false; 171 | 172 | # Trace peer selection 173 | TracePeerSelection = true; 174 | 175 | # Trace peer selection actions (demotion / protmotion between cold / warm and 176 | # hot peers). 177 | TracePeerSelectionActions = true; 178 | 179 | # Trace public root peers 180 | TracePublicRootPeers = true; 181 | 182 | # Trace server 183 | TraceServer = true; 184 | 185 | # Trace TxSubmission server (inbound transactions). 186 | TraceTxInbound = false; 187 | 188 | # Trace TxSubmission client (outbound transactions). 189 | TraceTxOutbound = false; 190 | 191 | # Trace TxSubmission protocol messages. 192 | TraceTxSubmissionProtocol = false; 193 | 194 | ##### Fine grained logging control ##### 195 | 196 | # It is also possible to have more fine grained control over filtering of 197 | # trace output, and to match and route trace output to particular backends. 198 | # This is less efficient than the coarse trace filters above but provides 199 | # much more precise control. 200 | 201 | options = { 202 | # This routes metrics matching specific names to particular backends. 203 | # This overrides the defaultBackends listed above. And note that it is 204 | # and override and not an extension so anything matched here will not 205 | # go to the default backend, only to the explicitly listed backends. 206 | mapBackends = { 207 | "cardano.node.metrics" = ["EKGViewBK"]; 208 | "cardano.node.resources" = ["EKGViewBK"]; 209 | }; 210 | 211 | # This section is more expressive still, and needs to be properly documented. 212 | mapSubtrace = { 213 | "cardano.node.metrics" = { 214 | subtrace = "Neutral"; 215 | }; 216 | }; 217 | }; 218 | } 219 | -------------------------------------------------------------------------------- /cardano-lib/mainnet-config-bp.nix: -------------------------------------------------------------------------------- 1 | ########################################################## 2 | ####### Mainnet ######## 3 | ####### Cardano Node Block Producer Configuration ######## 4 | ########################################################## 5 | 6 | import ./mainnet-config.nix // { 7 | ##### Core protocol parameters ##### 8 | PeerSharing = false; 9 | TargetNumberOfKnownPeers = 100; 10 | TargetNumberOfRootPeers = 100; 11 | } 12 | -------------------------------------------------------------------------------- /cardano-lib/mainnet-config.nix: -------------------------------------------------------------------------------- 1 | ########################################################## 2 | ############### Mainnet ############### 3 | ############### Cardano Node Configuration ############### 4 | ########################################################## 5 | 6 | with builtins; { 7 | ##### Locations ##### 8 | 9 | ByronGenesisFile = ./mainnet + "/byron-genesis.json"; 10 | ByronGenesisHash = "5f20df933584822601f9e3f8c024eb5eb252fe8cefb24d1317dc3d432e940ebb"; 11 | ConwayGenesisFile = ./mainnet + "/conway-genesis.json"; 12 | ConwayGenesisHash = "15a199f895e461ec0ffc6dd4e4028af28a492ab4e806d39cb674c88f7643ef62"; 13 | ShelleyGenesisFile = ./mainnet + "/shelley-genesis.json"; 14 | ShelleyGenesisHash = "1a3be38bcbb7911969283716ad7aa550250226b76a61fc51cc9a9a35d9276d81"; 15 | AlonzoGenesisFile = ./mainnet + "/alonzo-genesis.json"; 16 | AlonzoGenesisHash = "7e94a15f55d1e82d10f09203fa1d40f8eede58fd8066542cf6566008068ed874"; 17 | CheckpointsFile = ./mainnet + "/checkpoints.json"; 18 | CheckpointsFileHash = "3e6dee5bae7acc6d870187e72674b37c929be8c66e62a552cf6a876b1af31ade"; 19 | 20 | ##### Core protocol parameters ##### 21 | 22 | # This is the instance of the Ouroboros family that we are running. 23 | # The node also supports various test and mock instances. 24 | # "RealPBFT" is the real (ie not mock) (permissive) OBFT protocol, which 25 | # is what we use on mainnet in Byron era. 26 | Protocol = "Cardano"; 27 | 28 | # The mainnet does not include the network magic into addresses. Testnets do. 29 | RequiresNetworkMagic = "RequiresNoMagic"; 30 | EnableP2P = true; 31 | PeerSharing = true; 32 | TargetNumberOfActivePeers = 20; 33 | TargetNumberOfEstablishedPeers = 30; 34 | TargetNumberOfKnownPeers = 150; 35 | TargetNumberOfRootPeers = 60; 36 | TraceMempool = false; 37 | 38 | MaxKnownMajorProtocolVersion = 2; 39 | 40 | # The consensus mode. If set to "GenesisMode", the `CheckpointsFile` and 41 | # `CheckpointsFileHash` values above will be used and a path to a peer 42 | # snapshot file will need to be declared in the p2p topology file under key 43 | # `peerSnapshotFile`. 44 | ConsensusMode = "PraosMode"; 45 | 46 | # Default "GenesisMode" parameter values 47 | SyncTargetNumberOfActivePeers = 0; 48 | SyncTargetNumberOfActiveBigLedgerPeers = 30; 49 | SyncTargetNumberOfEstablishedBigLedgerPeers = 40; 50 | SyncTargetNumberOfKnownBigLedgerPeers = 100; 51 | MinBigLedgerPeersForTrustedState = 5; 52 | 53 | # Default Ledger Configuration 54 | # Additional configuration options can be found at: 55 | # https://ouroboros-consensus.cardano.intersectmbo.org/docs/for-developers/utxo-hd/migrating 56 | LedgerDB = { 57 | # The time interval between snapshots, in seconds. 58 | SnapshotInterval = (fromJSON (readFile ./mainnet/shelley-genesis.json)).securityParam * 2; 59 | 60 | # The number of disk snapshots to keep. 61 | NumOfDiskSnapshots = 2; 62 | 63 | # When querying the store for a big range of UTxOs (such as with 64 | # QueryUTxOByAddress), the store will be read in batches of this size. 65 | QueryBatchSize = 100000; 66 | 67 | # The backend can either be in memory with `V2InMemory` or on disk with 68 | # `V1LMDB`. 69 | Backend = "V2InMemory"; 70 | }; 71 | 72 | ##### Update system parameters ##### 73 | 74 | # This protocol version number gets used by block producing nodes as part 75 | # part of the system for agreeing on and synchronising protocol updates. 76 | LastKnownBlockVersion-Major = 3; 77 | LastKnownBlockVersion-Minor = 0; 78 | LastKnownBlockVersion-Alt = 0; 79 | } 80 | -------------------------------------------------------------------------------- /cardano-lib/mainnet/conway-genesis.json: -------------------------------------------------------------------------------- 1 | { 2 | "poolVotingThresholds": { 3 | "committeeNormal": 0.51, 4 | "committeeNoConfidence": 0.51, 5 | "hardForkInitiation": 0.51, 6 | "motionNoConfidence": 0.51, 7 | "ppSecurityGroup": 0.51 8 | }, 9 | "dRepVotingThresholds": { 10 | "motionNoConfidence": 0.67, 11 | "committeeNormal": 0.67, 12 | "committeeNoConfidence": 0.6, 13 | "updateToConstitution": 0.75, 14 | "hardForkInitiation": 0.6, 15 | "ppNetworkGroup": 0.67, 16 | "ppEconomicGroup": 0.67, 17 | "ppTechnicalGroup": 0.67, 18 | "ppGovGroup": 0.75, 19 | "treasuryWithdrawal": 0.67 20 | }, 21 | "committeeMinSize": 7, 22 | "committeeMaxTermLength": 146, 23 | "govActionLifetime": 6, 24 | "govActionDeposit": 100000000000, 25 | "dRepDeposit": 500000000, 26 | "dRepActivity": 20, 27 | "minFeeRefScriptCostPerByte": 15, 28 | "plutusV3CostModel": [ 29 | 100788, 30 | 420, 31 | 1, 32 | 1, 33 | 1000, 34 | 173, 35 | 0, 36 | 1, 37 | 1000, 38 | 59957, 39 | 4, 40 | 1, 41 | 11183, 42 | 32, 43 | 201305, 44 | 8356, 45 | 4, 46 | 16000, 47 | 100, 48 | 16000, 49 | 100, 50 | 16000, 51 | 100, 52 | 16000, 53 | 100, 54 | 16000, 55 | 100, 56 | 16000, 57 | 100, 58 | 100, 59 | 100, 60 | 16000, 61 | 100, 62 | 94375, 63 | 32, 64 | 132994, 65 | 32, 66 | 61462, 67 | 4, 68 | 72010, 69 | 178, 70 | 0, 71 | 1, 72 | 22151, 73 | 32, 74 | 91189, 75 | 769, 76 | 4, 77 | 2, 78 | 85848, 79 | 123203, 80 | 7305, 81 | -900, 82 | 1716, 83 | 549, 84 | 57, 85 | 85848, 86 | 0, 87 | 1, 88 | 1, 89 | 1000, 90 | 42921, 91 | 4, 92 | 2, 93 | 24548, 94 | 29498, 95 | 38, 96 | 1, 97 | 898148, 98 | 27279, 99 | 1, 100 | 51775, 101 | 558, 102 | 1, 103 | 39184, 104 | 1000, 105 | 60594, 106 | 1, 107 | 141895, 108 | 32, 109 | 83150, 110 | 32, 111 | 15299, 112 | 32, 113 | 76049, 114 | 1, 115 | 13169, 116 | 4, 117 | 22100, 118 | 10, 119 | 28999, 120 | 74, 121 | 1, 122 | 28999, 123 | 74, 124 | 1, 125 | 43285, 126 | 552, 127 | 1, 128 | 44749, 129 | 541, 130 | 1, 131 | 33852, 132 | 32, 133 | 68246, 134 | 32, 135 | 72362, 136 | 32, 137 | 7243, 138 | 32, 139 | 7391, 140 | 32, 141 | 11546, 142 | 32, 143 | 85848, 144 | 123203, 145 | 7305, 146 | -900, 147 | 1716, 148 | 549, 149 | 57, 150 | 85848, 151 | 0, 152 | 1, 153 | 90434, 154 | 519, 155 | 0, 156 | 1, 157 | 74433, 158 | 32, 159 | 85848, 160 | 123203, 161 | 7305, 162 | -900, 163 | 1716, 164 | 549, 165 | 57, 166 | 85848, 167 | 0, 168 | 1, 169 | 1, 170 | 85848, 171 | 123203, 172 | 7305, 173 | -900, 174 | 1716, 175 | 549, 176 | 57, 177 | 85848, 178 | 0, 179 | 1, 180 | 955506, 181 | 213312, 182 | 0, 183 | 2, 184 | 270652, 185 | 22588, 186 | 4, 187 | 1457325, 188 | 64566, 189 | 4, 190 | 20467, 191 | 1, 192 | 4, 193 | 0, 194 | 141992, 195 | 32, 196 | 100788, 197 | 420, 198 | 1, 199 | 1, 200 | 81663, 201 | 32, 202 | 59498, 203 | 32, 204 | 20142, 205 | 32, 206 | 24588, 207 | 32, 208 | 20744, 209 | 32, 210 | 25933, 211 | 32, 212 | 24623, 213 | 32, 214 | 43053543, 215 | 10, 216 | 53384111, 217 | 14333, 218 | 10, 219 | 43574283, 220 | 26308, 221 | 10, 222 | 16000, 223 | 100, 224 | 16000, 225 | 100, 226 | 962335, 227 | 18, 228 | 2780678, 229 | 6, 230 | 442008, 231 | 1, 232 | 52538055, 233 | 3756, 234 | 18, 235 | 267929, 236 | 18, 237 | 76433006, 238 | 8868, 239 | 18, 240 | 52948122, 241 | 18, 242 | 1995836, 243 | 36, 244 | 3227919, 245 | 12, 246 | 901022, 247 | 1, 248 | 166917843, 249 | 4307, 250 | 36, 251 | 284546, 252 | 36, 253 | 158221314, 254 | 26549, 255 | 36, 256 | 74698472, 257 | 36, 258 | 333849714, 259 | 1, 260 | 254006273, 261 | 72, 262 | 2174038, 263 | 72, 264 | 2261318, 265 | 64571, 266 | 4, 267 | 207616, 268 | 8310, 269 | 4, 270 | 1293828, 271 | 28716, 272 | 63, 273 | 0, 274 | 1, 275 | 1006041, 276 | 43623, 277 | 251, 278 | 0, 279 | 1 280 | ], 281 | "constitution": { 282 | "anchor": { 283 | "dataHash": "ca41a91f399259bcefe57f9858e91f6d00e1a38d6d9c63d4052914ea7bd70cb2", 284 | "url": "ipfs://bafkreifnwj6zpu3ixa4siz2lndqybyc5wnnt3jkwyutci4e2tmbnj3xrdm" 285 | }, 286 | "script": "fa24fb305126805cf2164c161d852a0e7330cf988f1fe558cf7d4a64" 287 | }, 288 | "committee": { 289 | "members": { 290 | "scriptHash-df0e83bde65416dade5b1f97e7f115cc1ff999550ad968850783fe50": 580, 291 | "scriptHash-b6012034ba0a7e4afbbf2c7a1432f8824aee5299a48e38e41a952686": 580, 292 | "scriptHash-ce8b37a72b178a37bbd3236daa7b2c158c9d3604e7aa667e6c6004b7": 580, 293 | "scriptHash-f0dc2c00d92a45521267be2d5de1c485f6f9d14466d7e16062897cf7": 580, 294 | "scriptHash-349e55f83e9af24813e6cb368df6a80d38951b2a334dfcdf26815558": 580, 295 | "scriptHash-84aebcfd3e00d0f87af918fc4b5e00135f407e379893df7e7d392c6a": 580, 296 | "scriptHash-e8165b3328027ee0d74b1f07298cb092fd99aa7697a1436f5997f625": 580 297 | }, 298 | "threshold": { 299 | "numerator": 2, 300 | "denominator": 3 301 | } 302 | } 303 | } 304 | -------------------------------------------------------------------------------- /cardano-lib/mainnet/shelley-genesis.json: -------------------------------------------------------------------------------- 1 | { 2 | "activeSlotsCoeff": 0.05, 3 | "protocolParams": { 4 | "protocolVersion": { 5 | "minor": 0, 6 | "major": 2 7 | }, 8 | "decentralisationParam": 1, 9 | "eMax": 18, 10 | "extraEntropy": { 11 | "tag": "NeutralNonce" 12 | }, 13 | "maxTxSize": 16384, 14 | "maxBlockBodySize": 65536, 15 | "maxBlockHeaderSize": 1100, 16 | "minFeeA": 44, 17 | "minFeeB": 155381, 18 | "minUTxOValue": 1000000, 19 | "poolDeposit": 500000000, 20 | "minPoolCost": 340000000, 21 | "keyDeposit": 2000000, 22 | "nOpt": 150, 23 | "rho": 0.003, 24 | "tau": 0.20, 25 | "a0": 0.3 26 | }, 27 | "genDelegs": { 28 | "ad5463153dc3d24b9ff133e46136028bdc1edbb897f5a7cf1b37950c": { 29 | "delegate": "d9e5c76ad5ee778960804094a389f0b546b5c2b140a62f8ec43ea54d", 30 | "vrf": "64fa87e8b29a5b7bfbd6795677e3e878c505bc4a3649485d366b50abadec92d7" 31 | }, 32 | "b9547b8a57656539a8d9bc42c008e38d9c8bd9c8adbb1e73ad529497": { 33 | "delegate": "855d6fc1e54274e331e34478eeac8d060b0b90c1f9e8a2b01167c048", 34 | "vrf": "66d5167a1f426bd1adcc8bbf4b88c280d38c148d135cb41e3f5a39f948ad7fcc" 35 | }, 36 | "60baee25cbc90047e83fd01e1e57dc0b06d3d0cb150d0ab40bbfead1": { 37 | "delegate": "7f72a1826ae3b279782ab2bc582d0d2958de65bd86b2c4f82d8ba956", 38 | "vrf": "c0546d9aa5740afd569d3c2d9c412595cd60822bb6d9a4e8ce6c43d12bd0f674" 39 | }, 40 | "f7b341c14cd58fca4195a9b278cce1ef402dc0e06deb77e543cd1757": { 41 | "delegate": "69ae12f9e45c0c9122356c8e624b1fbbed6c22a2e3b4358cf0cb5011", 42 | "vrf": "6394a632af51a32768a6f12dac3485d9c0712d0b54e3f389f355385762a478f2" 43 | }, 44 | "162f94554ac8c225383a2248c245659eda870eaa82d0ef25fc7dcd82": { 45 | "delegate": "4485708022839a7b9b8b639a939c85ec0ed6999b5b6dc651b03c43f6", 46 | "vrf": "aba81e764b71006c515986bf7b37a72fbb5554f78e6775f08e384dbd572a4b32" 47 | }, 48 | "2075a095b3c844a29c24317a94a643ab8e22d54a3a3a72a420260af6": { 49 | "delegate": "6535db26347283990a252313a7903a45e3526ec25ddba381c071b25b", 50 | "vrf": "fcaca997b8105bd860876348fc2c6e68b13607f9bbd23515cd2193b555d267af" 51 | }, 52 | "268cfc0b89e910ead22e0ade91493d8212f53f3e2164b2e4bef0819b": { 53 | "delegate": "1d4f2e1fda43070d71bb22a5522f86943c7c18aeb4fa47a362c27e23", 54 | "vrf": "63ef48bc5355f3e7973100c371d6a095251c80ceb40559f4750aa7014a6fb6db" 55 | } 56 | }, 57 | "updateQuorum": 5, 58 | "networkId": "Mainnet", 59 | "initialFunds": {}, 60 | "maxLovelaceSupply": 45000000000000000, 61 | "networkMagic": 764824073, 62 | "epochLength": 432000, 63 | "systemStart": "2017-09-23T21:44:51Z", 64 | "slotsPerKESPeriod": 129600, 65 | "slotLength": 1, 66 | "maxKESEvolutions": 62, 67 | "securityParam": 2160 68 | } 69 | -------------------------------------------------------------------------------- /cardano-lib/preprod-config-bp.nix: -------------------------------------------------------------------------------- 1 | ########################################################## 2 | ####### Preprod ######## 3 | ####### Cardano Node Block Producer Configuration ######## 4 | ########################################################## 5 | 6 | import ./preprod-config.nix // { 7 | ##### Core protocol parameters ##### 8 | PeerSharing = false; 9 | TargetNumberOfKnownPeers = 100; 10 | TargetNumberOfRootPeers = 100; 11 | } 12 | -------------------------------------------------------------------------------- /cardano-lib/preprod-config.nix: -------------------------------------------------------------------------------- 1 | ########################################################## 2 | ############### Preprod ############### 3 | ############### Cardano Node Configuration ############### 4 | ########################################################## 5 | 6 | with builtins; { 7 | ##### Locations ##### 8 | 9 | ByronGenesisFile = ./preprod + "/byron-genesis.json"; 10 | ByronGenesisHash = "d4b8de7a11d929a323373cbab6c1a9bdc931beffff11db111cf9d57356ee1937"; 11 | ConwayGenesisFile = ./preprod + "/conway-genesis.json"; 12 | ConwayGenesisHash = "0eb6adaec3fcb1fe286c1b4ae0da2a117eafc3add51e17577d36dd39eddfc3db"; 13 | ShelleyGenesisFile = ./preprod + "/shelley-genesis.json"; 14 | ShelleyGenesisHash = "162d29c4e1cf6b8a84f2d692e67a3ac6bc7851bc3e6e4afe64d15778bed8bd86"; 15 | AlonzoGenesisFile = ./preprod + "/alonzo-genesis.json"; 16 | AlonzoGenesisHash = "7e94a15f55d1e82d10f09203fa1d40f8eede58fd8066542cf6566008068ed874"; 17 | 18 | ##### Core protocol parameters ##### 19 | 20 | # This is the instance of the Ouroboros family that we are running. 21 | # The node also supports various test and mock instances. 22 | # "RealPBFT" is the real (ie not mock) (permissive) OBFT protocol, which 23 | # is what we use on mainnet in Byron era. 24 | Protocol = "Cardano"; 25 | 26 | # The mainnet does not include the network magic into addresses. Testnets do. 27 | RequiresNetworkMagic = "RequiresMagic"; 28 | EnableP2P = true; 29 | PeerSharing = true; 30 | TargetNumberOfActivePeers = 20; 31 | TargetNumberOfEstablishedPeers = 30; 32 | TargetNumberOfKnownPeers = 150; 33 | TargetNumberOfRootPeers = 60; 34 | 35 | # The consensus mode. If set to "GenesisMode", a path to a peer snapshot 36 | # file will need to be declared in the p2p topology file under key 37 | # `peerSnapshotFile`. A `CheckpointsFile` and corresponding 38 | # `CheckpointsFileHash` is not required for preprod. 39 | ConsensusMode = "GenesisMode"; 40 | 41 | # Default parameter values for "GenesisMode" 42 | SyncTargetNumberOfActivePeers = 0; 43 | SyncTargetNumberOfActiveBigLedgerPeers = 30; 44 | SyncTargetNumberOfEstablishedBigLedgerPeers = 40; 45 | SyncTargetNumberOfKnownBigLedgerPeers = 100; 46 | MinBigLedgerPeersForTrustedState = 5; 47 | 48 | # Default Ledger Configuration 49 | # Additional configuration options can be found at: 50 | # https://ouroboros-consensus.cardano.intersectmbo.org/docs/for-developers/utxo-hd/migrating 51 | LedgerDB = { 52 | # The time interval between snapshots, in seconds. 53 | SnapshotInterval = (fromJSON (readFile ./preprod/shelley-genesis.json)).securityParam * 2; 54 | 55 | # The number of disk snapshots to keep. 56 | NumOfDiskSnapshots = 2; 57 | 58 | # When querying the store for a big range of UTxOs (such as with 59 | # QueryUTxOByAddress), the store will be read in batches of this size. 60 | QueryBatchSize = 100000; 61 | 62 | # The backend can either be in memory with `V2InMemory` or on disk with 63 | # `V1LMDB`. 64 | Backend = "V2InMemory"; 65 | }; 66 | 67 | ##### Update system parameters ##### 68 | 69 | # This protocol version number gets used by block producing nodes as part 70 | # part of the system for agreeing on and synchronising protocol updates. 71 | LastKnownBlockVersion-Major = 2; 72 | LastKnownBlockVersion-Minor = 0; 73 | LastKnownBlockVersion-Alt = 0; 74 | } 75 | -------------------------------------------------------------------------------- /cardano-lib/preprod/byron-genesis.json: -------------------------------------------------------------------------------- 1 | { "bootStakeholders": 2 | { "05d1c10e4bf3cdd4de54712531c53be75a1609b25f396ffbbe5becf1": 1 3 | , "3bf1193b19be416283b8c0516d2f8b80939ffccb1c9b05946f54c83a": 1 4 | , "7bdd769bd872e8e6336c23f1e566c19a96e72137174b891fad9f4b99": 1 5 | , "9ddc1e29c59df0ddd9347fe8b8a736d247f286414684eddc02885348": 1 6 | , "a118c0d2737c8a77c0d982a0d299bc42614cea4e0c23614ba24a05ca": 1 7 | , "b0b2df3c9cf4dfe2ae04409913b3c3125509acbbfa0722449570aaeb": 1 8 | , "e0a65f21229e44c2bf6eec5b14e2775003b674ae53de18d22814346a": 1 9 | } 10 | , "heavyDelegation": 11 | { "05d1c10e4bf3cdd4de54712531c53be75a1609b25f396ffbbe5becf1": 12 | { "omega": 0 13 | , "issuerPk": 14 | "UFsjehyxQAIMxEL25RxqD0itM0RCdzWprVt1W+zopM5b7U9ru9AMr/zf9lAjWaFlNOpRgrrbz7r5tRbt8wUmSg==" 15 | , "delegatePk": 16 | "iwlg0jS9pn1SQyxdGiasor+1uaCflm2Vkqe/DHKKHs2EDqxcP+in7doCSnQDttN3BZkIKLNUgzKj+FAiHCCYvw==" 17 | , "cert": 18 | "633fc347138ee155d038b9d1040ee1e45cea5b1e8627046c95f7fe4ba949b0569437962568eadef9d49e22becbf30192425c008d10e03004612633dbc307340b" 19 | } 20 | , "3bf1193b19be416283b8c0516d2f8b80939ffccb1c9b05946f54c83a": 21 | { "omega": 0 22 | , "issuerPk": 23 | "pAIACMG6WCa4mz0tVoeekLXYuWkdxk/rgDuZ/x7ugh3CvEuhpGf2LRRRWilaGdraH1sCbnuMCmAHrBTbPDFmxA==" 24 | , "delegatePk": 25 | "0ajebKqP2bF1xZhi7N1avNBHe4S4Kg5S+uzGs8hRAKR1IW/7ZOp0U3AhQFuzKLD3BuSq1xV3leMWeBzKEg2slg==" 26 | , "cert": 27 | "eb5c4d76c7bfca2ab790a76f7dc4c6d9f7d0956d4af3b8c649804ef98beeb138d8916982c9142747b7a07e69f52b2c3776d64a7d74494e0f72eefaebf6bf5d07" 28 | } 29 | , "7bdd769bd872e8e6336c23f1e566c19a96e72137174b891fad9f4b99": 30 | { "omega": 0 31 | , "issuerPk": 32 | "P7JjeSPHjexNW5MsCaySrURaqV2gCgXttEe0CgfFnVZFGHaS9A4xEUrQ83VTLPjk+HV0Di19DjQ+DhS1M6Mf7A==" 33 | , "delegatePk": 34 | "jvMgwt9mVKYYjEXpxjnApoa/WoZSlVh9OZ3+sF/nSrZ5YaaWsmjIvOyTcrxzqpsTZewAez36BTnqwA0VSjFRjA==" 35 | , "cert": 36 | "9ef9f0e5ca23cd9365ec7a23f1b2d159da0d58e0242cb817c3bc946ba1c9e3629f1976f09a88370247bbc458c810d21a889e3ff6dd189ceea784bc9ab6dc9b0a" 37 | } 38 | , "9ddc1e29c59df0ddd9347fe8b8a736d247f286414684eddc02885348": 39 | { "omega": 0 40 | , "issuerPk": 41 | "Xro6BbV6hMh3RTZnst4ABhtQ2vr83YPXoLfQ8JWeunvvcuudGBQvLeqwVfGXrBWoMOOKroFV48ygfSEq2xhREA==" 42 | , "delegatePk": 43 | "mq5iXU0VvLNzPUIOBk8c0zjzhuCvBJ/NQrRVpp0orTZkg9F3uiuAG0E24NZmLl6eCiTyyAoOeNTCNbTAjyAfTA==" 44 | , "cert": 45 | "939dcfe5555ee661b9db5d817a70d5c3fa9d1d97c2ae5849696d915606b530f7e9edda5d02a01e61524a766f9c356084616ba058a3de70ea51bf29cd187a5f07" 46 | } 47 | , "a118c0d2737c8a77c0d982a0d299bc42614cea4e0c23614ba24a05ca": 48 | { "omega": 0 49 | , "issuerPk": 50 | "eqAAtu1X79MxCSa/i/RSApLGsnhDYqLJLu93f3wSzR5/M7calZS8DHFrAtJgzYbkg9nwKF1HQQ8bO/1LOJ9O4w==" 51 | , "delegatePk": 52 | "lCuzqqsPZEK5BrZbpt2/eWnKpmLZCWiSYhGj1WUy8R2OjLStw/UDT7xiV/pbEIZoncfQJN9yJqpQH8KOui0fYw==" 53 | , "cert": 54 | "b96ad354a6989df5de8d0888414843736d0a4a6626a1e595e8785a70b10a38eb4632159aabf84959983e8852fd4d390eba6c423fac8ea117913cec46353bd90e" 55 | } 56 | , "b0b2df3c9cf4dfe2ae04409913b3c3125509acbbfa0722449570aaeb": 57 | { "omega": 0 58 | , "issuerPk": 59 | "Y+Vaj0IaMeq0+oWjQr5hiEl4Ek+cWsKq7mufTO4wue2R6A6AMlqEDIV7vYsd3NZWomG5DGcwSAw2Ev1Mz26LIA==" 60 | , "delegatePk": 61 | "YYtiXfMN5TiV/ynno3cNylbC/wZtSqBaaXGQXe7O9tu33RDqH5F15Sk+reyXvxaxZ683mns+1K8DLNB7mezB6g==" 62 | , "cert": 63 | "ca38e688e759183b57d08ca6568248b91c8ddd81e56d0d31c3f3a26eca35754387c5f301ef017dafae453a93757d39a0e2d326ebe59cf31d5c1b22fc8616ac00" 64 | } 65 | , "e0a65f21229e44c2bf6eec5b14e2775003b674ae53de18d22814346a": 66 | { "omega": 0 67 | , "issuerPk": 68 | "vynbl3q/BFvwehgMzpp3NoWOuN5RwDUYCbNop0RR0jlEXomgPOrlXCwMTrwrI8Dcfzq5q1fK/1hOfv9IwDMPAA==" 69 | , "delegatePk": 70 | "1N1ppBBxvC3I5kqX9L1jeVJM4MK2ZXKAQ6Bn400+IYr4mh4zTYciCsTJTyvY8IKIBBEcT3GYW6ZlaYy7XbY5kg==" 71 | , "cert": 72 | "82b10bbea2dd80441315230354e3e4af0ac87d02c9e6424fc9432be21a6183c81555d3a1b373566aef7a8065a126d57c42629be780becc61bc1b8f3ce5b5170d" 73 | } 74 | } 75 | , "startTime": 1654041600 76 | , "nonAvvmBalances": 77 | { "FHnt4NL7yPXhCzCHVywZLqVsvwuG3HvwmjKXQJBrXh3h2aigv6uxkePbpzRNV8q": 78 | "0" 79 | , "FHnt4NL7yPXuJGViM3KwSPwrwECD9q5vNetX3QJDYRWgiX3RHi5i5VV32dnETDK": 80 | "0" 81 | , "FHnt4NL7yPXuYUxBF33VX5dZMBDAab2kvSNLRzCskvuKNCSDknzrQvKeQhGUw5a": 82 | "30000000000000000" 83 | , "FHnt4NL7yPY8exfnuJ8ACyoU7xCN93tKXSv357UrTp1nddGbkWxJpQfrt62xYFX": 84 | "0" 85 | , "FHnt4NL7yPYFpVcAXZADrKdsqCAFvcRFYkTcqkn2guGmj8akQMiMVjhSUECvD1F": 86 | "0" 87 | , "FHnt4NL7yPYH2vP2FLEfH2pt3K6meM7fgtjRiLBidaqpP5ogPzxLNsZy68e1KdW": 88 | "0" 89 | , "FHnt4NL7yPYHrcxPtPufYYFWLhqvHGnZ5NFSz2KZpWQgSq4VLsUgWnkEmfUtd1E": 90 | "0" 91 | , "FHnt4NL7yPYJiN5Y8VsQr6LP6YgN51BHBPegNjVwKkq6AooCkbTpfZ2bqkVkfXU": 92 | "0" 93 | } 94 | , "blockVersionData": 95 | { "scriptVersion": 0 96 | , "slotDuration": "20000" 97 | , "maxBlockSize": "2000000" 98 | , "maxHeaderSize": "2000000" 99 | , "maxTxSize": "4096" 100 | , "maxProposalSize": "700" 101 | , "mpcThd": "20000000000000" 102 | , "heavyDelThd": "300000000000" 103 | , "updateVoteThd": "1000000000000" 104 | , "updateProposalThd": "100000000000000" 105 | , "updateImplicit": "10000" 106 | , "softforkRule": 107 | { "initThd": "900000000000000" 108 | , "minThd": "600000000000000" 109 | , "thdDecrement": "50000000000000" 110 | } 111 | , "txFeePolicy": 112 | { "summand": "155381000000000" , "multiplier": "43946000000" } 113 | , "unlockStakeEpoch": "18446744073709551615" 114 | } 115 | , "protocolConsts": { "k": 2160 , "protocolMagic": 1 } 116 | , "avvmDistr": {} 117 | } -------------------------------------------------------------------------------- /cardano-lib/preprod/conway-genesis.json: -------------------------------------------------------------------------------- 1 | { 2 | "poolVotingThresholds": { 3 | "committeeNormal": 0.51, 4 | "committeeNoConfidence": 0.51, 5 | "hardForkInitiation": 0.51, 6 | "motionNoConfidence": 0.51, 7 | "ppSecurityGroup": 0.51 8 | }, 9 | "dRepVotingThresholds": { 10 | "motionNoConfidence": 0.67, 11 | "committeeNormal": 0.67, 12 | "committeeNoConfidence": 0.6, 13 | "updateToConstitution": 0.75, 14 | "hardForkInitiation": 0.6, 15 | "ppNetworkGroup": 0.67, 16 | "ppEconomicGroup": 0.67, 17 | "ppTechnicalGroup": 0.67, 18 | "ppGovGroup": 0.75, 19 | "treasuryWithdrawal": 0.67 20 | }, 21 | "committeeMinSize": 7, 22 | "committeeMaxTermLength": 146, 23 | "govActionLifetime": 6, 24 | "govActionDeposit": 100000000000, 25 | "dRepDeposit": 500000000, 26 | "dRepActivity": 20, 27 | "minFeeRefScriptCostPerByte": 15, 28 | "plutusV3CostModel": [ 29 | 100788, 30 | 420, 31 | 1, 32 | 1, 33 | 1000, 34 | 173, 35 | 0, 36 | 1, 37 | 1000, 38 | 59957, 39 | 4, 40 | 1, 41 | 11183, 42 | 32, 43 | 201305, 44 | 8356, 45 | 4, 46 | 16000, 47 | 100, 48 | 16000, 49 | 100, 50 | 16000, 51 | 100, 52 | 16000, 53 | 100, 54 | 16000, 55 | 100, 56 | 16000, 57 | 100, 58 | 100, 59 | 100, 60 | 16000, 61 | 100, 62 | 94375, 63 | 32, 64 | 132994, 65 | 32, 66 | 61462, 67 | 4, 68 | 72010, 69 | 178, 70 | 0, 71 | 1, 72 | 22151, 73 | 32, 74 | 91189, 75 | 769, 76 | 4, 77 | 2, 78 | 85848, 79 | 123203, 80 | 7305, 81 | -900, 82 | 1716, 83 | 549, 84 | 57, 85 | 85848, 86 | 0, 87 | 1, 88 | 1, 89 | 1000, 90 | 42921, 91 | 4, 92 | 2, 93 | 24548, 94 | 29498, 95 | 38, 96 | 1, 97 | 898148, 98 | 27279, 99 | 1, 100 | 51775, 101 | 558, 102 | 1, 103 | 39184, 104 | 1000, 105 | 60594, 106 | 1, 107 | 141895, 108 | 32, 109 | 83150, 110 | 32, 111 | 15299, 112 | 32, 113 | 76049, 114 | 1, 115 | 13169, 116 | 4, 117 | 22100, 118 | 10, 119 | 28999, 120 | 74, 121 | 1, 122 | 28999, 123 | 74, 124 | 1, 125 | 43285, 126 | 552, 127 | 1, 128 | 44749, 129 | 541, 130 | 1, 131 | 33852, 132 | 32, 133 | 68246, 134 | 32, 135 | 72362, 136 | 32, 137 | 7243, 138 | 32, 139 | 7391, 140 | 32, 141 | 11546, 142 | 32, 143 | 85848, 144 | 123203, 145 | 7305, 146 | -900, 147 | 1716, 148 | 549, 149 | 57, 150 | 85848, 151 | 0, 152 | 1, 153 | 90434, 154 | 519, 155 | 0, 156 | 1, 157 | 74433, 158 | 32, 159 | 85848, 160 | 123203, 161 | 7305, 162 | -900, 163 | 1716, 164 | 549, 165 | 57, 166 | 85848, 167 | 0, 168 | 1, 169 | 1, 170 | 85848, 171 | 123203, 172 | 7305, 173 | -900, 174 | 1716, 175 | 549, 176 | 57, 177 | 85848, 178 | 0, 179 | 1, 180 | 955506, 181 | 213312, 182 | 0, 183 | 2, 184 | 270652, 185 | 22588, 186 | 4, 187 | 1457325, 188 | 64566, 189 | 4, 190 | 20467, 191 | 1, 192 | 4, 193 | 0, 194 | 141992, 195 | 32, 196 | 100788, 197 | 420, 198 | 1, 199 | 1, 200 | 81663, 201 | 32, 202 | 59498, 203 | 32, 204 | 20142, 205 | 32, 206 | 24588, 207 | 32, 208 | 20744, 209 | 32, 210 | 25933, 211 | 32, 212 | 24623, 213 | 32, 214 | 43053543, 215 | 10, 216 | 53384111, 217 | 14333, 218 | 10, 219 | 43574283, 220 | 26308, 221 | 10, 222 | 16000, 223 | 100, 224 | 16000, 225 | 100, 226 | 962335, 227 | 18, 228 | 2780678, 229 | 6, 230 | 442008, 231 | 1, 232 | 52538055, 233 | 3756, 234 | 18, 235 | 267929, 236 | 18, 237 | 76433006, 238 | 8868, 239 | 18, 240 | 52948122, 241 | 18, 242 | 1995836, 243 | 36, 244 | 3227919, 245 | 12, 246 | 901022, 247 | 1, 248 | 166917843, 249 | 4307, 250 | 36, 251 | 284546, 252 | 36, 253 | 158221314, 254 | 26549, 255 | 36, 256 | 74698472, 257 | 36, 258 | 333849714, 259 | 1, 260 | 254006273, 261 | 72, 262 | 2174038, 263 | 72, 264 | 2261318, 265 | 64571, 266 | 4, 267 | 207616, 268 | 8310, 269 | 4, 270 | 1293828, 271 | 28716, 272 | 63, 273 | 0, 274 | 1, 275 | 1006041, 276 | 43623, 277 | 251, 278 | 0, 279 | 1 280 | ], 281 | "constitution": { 282 | "anchor": { 283 | "dataHash": "ca41a91f399259bcefe57f9858e91f6d00e1a38d6d9c63d4052914ea7bd70cb2", 284 | "url": "ipfs://bafkreifnwj6zpu3ixa4siz2lndqybyc5wnnt3jkwyutci4e2tmbnj3xrdm" 285 | }, 286 | "script": "fa24fb305126805cf2164c161d852a0e7330cf988f1fe558cf7d4a64" 287 | }, 288 | "committee": { 289 | "members": { 290 | "scriptHash-a6a5e006fd4e8f51062dc431362369b2a43140abced8aa2ff2256d7b": 229, 291 | "scriptHash-6095e643ea6f1cccb6e463ec34349026b3a48621aac5d512655ab1bf": 229, 292 | "scriptHash-94c0de47e7ae32e3f7234ada5cf976506b68e3bb88c54dc53b4ba984": 229, 293 | "scriptHash-5098dfd0deba725fadd692198fc33ee959fbe7e6edf1b5a695e06e61": 229, 294 | "scriptHash-5a71f17f4ce4c1c0be053575d717ade6ad8a1d5453d02a65ce40d4b1": 229, 295 | "scriptHash-2f4a6c6f098e20ee4bfd5b39942c164575f8ceb348e754df5d0ec04f": 229, 296 | "scriptHash-94f51c795a6c11adb9c1e30f0b6def4230cbd0b8bc800098e2d2307b": 229 297 | }, 298 | "threshold": { 299 | "numerator": 2, 300 | "denominator": 3 301 | } 302 | } 303 | } 304 | -------------------------------------------------------------------------------- /cardano-lib/preprod/shelley-genesis.json: -------------------------------------------------------------------------------- 1 | { 2 | "activeSlotsCoeff": 0.05, 3 | "epochLength": 432000, 4 | "genDelegs": { 5 | "637f2e950b0fd8f8e3e811c5fbeb19e411e7a2bf37272b84b29c1a0b": { 6 | "delegate": "aae9293510344ddd636364c2673e34e03e79e3eefa8dbaa70e326f7d", 7 | "vrf": "227116365af2ed943f1a8b5e6557bfaa34996f1578eec667a5e2b361c51e4ce7" 8 | }, 9 | "8a4b77c4f534f8b8cc6f269e5ebb7ba77fa63a476e50e05e66d7051c": { 10 | "delegate": "d15422b2e8b60e500a82a8f4ceaa98b04e55a0171d1125f6c58f8758", 11 | "vrf": "0ada6c25d62db5e1e35d3df727635afa943b9e8a123ab83785e2281605b09ce2" 12 | }, 13 | "b00470cd193d67aac47c373602fccd4195aad3002c169b5570de1126": { 14 | "delegate": "b3b539e9e7ed1b32fbf778bf2ebf0a6b9f980eac90ac86623d11881a", 15 | "vrf": "0ff0ce9b820376e51c03b27877cd08f8ba40318f1a9f85a3db0b60dd03f71a7a" 16 | }, 17 | "b260ffdb6eba541fcf18601923457307647dce807851b9d19da133ab": { 18 | "delegate": "7c64eb868b4ef566391a321c85323f41d2b95480d7ce56ad2abcb022", 19 | "vrf": "7fb22abd39d550c9a022ec8104648a26240a9ff9c88b8b89a6e20d393c03098e" 20 | }, 21 | "ced1599fd821a39593e00592e5292bdc1437ae0f7af388ef5257344a": { 22 | "delegate": "de7ca985023cf892f4de7f5f1d0a7181668884752d9ebb9e96c95059", 23 | "vrf": "c301b7fc4d1b57fb60841bcec5e3d2db89602e5285801e522fce3790987b1124" 24 | }, 25 | "dd2a7d71a05bed11db61555ba4c658cb1ce06c8024193d064f2a66ae": { 26 | "delegate": "1e113c218899ee7807f4028071d0e108fc790dade9fd1a0d0b0701ee", 27 | "vrf": "faf2702aa4893c877c622ab22dfeaf1d0c8aab98b837fe2bf667314f0d043822" 28 | }, 29 | "f3b9e74f7d0f24d2314ea5dfbca94b65b2059d1ff94d97436b82d5b4": { 30 | "delegate": "fd637b08cc379ef7b99c83b416458fcda8a01a606041779331008fb9", 31 | "vrf": "37f2ea7c843a688159ddc2c38a2f997ab465150164a9136dca69564714b73268" 32 | } 33 | }, 34 | "initialFunds": {}, 35 | "maxKESEvolutions": 62, 36 | "maxLovelaceSupply": 45000000000000000, 37 | "networkId": "Testnet", 38 | "networkMagic": 1, 39 | "protocolParams": { 40 | "protocolVersion": { 41 | "minor": 0, 42 | "major": 2 43 | }, 44 | "decentralisationParam": 1, 45 | "eMax": 18, 46 | "extraEntropy": { 47 | "tag": "NeutralNonce" 48 | }, 49 | "maxTxSize": 16384, 50 | "maxBlockBodySize": 65536, 51 | "maxBlockHeaderSize": 1100, 52 | "minFeeA": 44, 53 | "minFeeB": 155381, 54 | "minUTxOValue": 1000000, 55 | "poolDeposit": 500000000, 56 | "minPoolCost": 340000000, 57 | "keyDeposit": 2000000, 58 | "nOpt": 150, 59 | "rho": 0.003, 60 | "tau": 0.20, 61 | "a0": 0.3 62 | }, 63 | "securityParam": 2160, 64 | "slotLength": 1, 65 | "slotsPerKESPeriod": 129600, 66 | "staking": { 67 | "pools": {}, 68 | "stake": {} 69 | }, 70 | "systemStart": "2022-06-01T00:00:00Z", 71 | "updateQuorum": 5 72 | } 73 | -------------------------------------------------------------------------------- /cardano-lib/preview-config-bp.nix: -------------------------------------------------------------------------------- 1 | ########################################################## 2 | ####### Preview ######## 3 | ####### Cardano Node Block Producer Configuration ######## 4 | ########################################################## 5 | 6 | import ./preview-config.nix // { 7 | ##### Core protocol parameters ##### 8 | PeerSharing = false; 9 | TargetNumberOfKnownPeers = 100; 10 | TargetNumberOfRootPeers = 100; 11 | } 12 | -------------------------------------------------------------------------------- /cardano-lib/preview-config.nix: -------------------------------------------------------------------------------- 1 | ########################################################## 2 | ############### Preview ############### 3 | ############### Cardano Node Configuration ############### 4 | ########################################################## 5 | 6 | with builtins; { 7 | ##### Locations ##### 8 | 9 | ByronGenesisFile = ./preview + "/byron-genesis.json"; 10 | ByronGenesisHash = "83de1d7302569ad56cf9139a41e2e11346d4cb4a31c00142557b6ab3fa550761"; 11 | ConwayGenesisFile = ./preview + "/conway-genesis.json"; 12 | ConwayGenesisHash = "9cc5084f02e27210eacba47af0872e3dba8946ad9460b6072d793e1d2f3987ef"; 13 | ShelleyGenesisFile = ./preview + "/shelley-genesis.json"; 14 | ShelleyGenesisHash = "363498d1024f84bb39d3fa9593ce391483cb40d479b87233f868d6e57c3a400d"; 15 | AlonzoGenesisFile = ./preview + "/alonzo-genesis.json"; 16 | AlonzoGenesisHash = "7e94a15f55d1e82d10f09203fa1d40f8eede58fd8066542cf6566008068ed874"; 17 | 18 | ### Core protocol parameters ##### 19 | Protocol = "Cardano"; 20 | 21 | RequiresNetworkMagic = "RequiresMagic"; 22 | EnableP2P = true; 23 | PeerSharing = true; 24 | TargetNumberOfActivePeers = 20; 25 | TargetNumberOfEstablishedPeers = 30; 26 | TargetNumberOfKnownPeers = 150; 27 | TargetNumberOfRootPeers = 60; 28 | ExperimentalHardForksEnabled = false; 29 | ExperimentalProtocolsEnabled = false; 30 | TestShelleyHardForkAtEpoch = 0; 31 | TestAllegraHardForkAtEpoch = 0; 32 | TestAlonzoHardForkAtEpoch = 0; 33 | TestMaryHardForkAtEpoch = 0; 34 | 35 | # The consensus mode. If set to "GenesisMode", a path to a peer snapshot 36 | # file will need to be declared in the p2p topology file under key 37 | # `peerSnapshotFile`. A `CheckpointsFile` and corresponding 38 | # `CheckpointsFileHash` is not required for preview. 39 | ConsensusMode = "GenesisMode"; 40 | 41 | # Default parameter values for "GenesisMode" 42 | SyncTargetNumberOfActivePeers = 0; 43 | SyncTargetNumberOfActiveBigLedgerPeers = 30; 44 | SyncTargetNumberOfEstablishedBigLedgerPeers = 40; 45 | SyncTargetNumberOfKnownBigLedgerPeers = 100; 46 | MinBigLedgerPeersForTrustedState = 5; 47 | 48 | # Default Ledger Configuration 49 | # Additional configuration options can be found at: 50 | # https://ouroboros-consensus.cardano.intersectmbo.org/docs/for-developers/utxo-hd/migrating 51 | LedgerDB = { 52 | # The time interval between snapshots, in seconds. 53 | SnapshotInterval = (fromJSON (readFile ./preview/shelley-genesis.json)).securityParam * 2; 54 | 55 | # The number of disk snapshots to keep. 56 | NumOfDiskSnapshots = 2; 57 | 58 | # When querying the store for a big range of UTxOs (such as with 59 | # QueryUTxOByAddress), the store will be read in batches of this size. 60 | QueryBatchSize = 100000; 61 | 62 | # The backend can either be in memory with `V2InMemory` or on disk with 63 | # `V1LMDB`. 64 | Backend = "V2InMemory"; 65 | }; 66 | 67 | ##### Update system parameters ##### 68 | 69 | LastKnownBlockVersion-Major = 3; 70 | LastKnownBlockVersion-Minor = 1; 71 | LastKnownBlockVersion-Alt = 0; 72 | } 73 | -------------------------------------------------------------------------------- /cardano-lib/preview/byron-genesis.json: -------------------------------------------------------------------------------- 1 | { "bootStakeholders": 2 | { "021e737009040bf7f1e7b1bcc148f29d748d4a6b561902c95e4a9f36": 1 3 | , "0bc82ced9544980b9ffe7f64b1538bbda6804a5cc32c8035485e184b": 1 4 | , "18ed9844deef98cf9ba8b39791dede0538d2d2fa79bf67ef37dcc826": 1 5 | , "66cfa84ad0ee5ca8586244c8393007cf3d9622d77cfa03fd4f35065b": 1 6 | , "76c4d6c68c0ef81ae364411a84e52ce66089ed006ca29adfc0227901": 1 7 | , "8cc6b89fec65cc83d34b7bab2e6494db631d8476a86625767dd0c2a0": 1 8 | , "e90060fdc085ac9f63cdb3b32ba1d84e0f7eb98561687b213b4c8770": 1 9 | } 10 | , "heavyDelegation": 11 | { "021e737009040bf7f1e7b1bcc148f29d748d4a6b561902c95e4a9f36": 12 | { "omega": 0 13 | , "issuerPk": 14 | "6hSFCotivD08t02n43RMiaF9LzwtYVrFMu/WX6ShfEsxfdXFL5Y6c+DwHSZOCywU0RJz5er2icIO03UytC9NTg==" 15 | , "delegatePk": 16 | "JEnSVQTPGriTx1+lAMkKhCNsMBDNPGw+NiEvNPh4ui6IdvxrO+WkQPTy5U865XB4VFvi/zb7d+H1bilnztQNBg==" 17 | , "cert": 18 | "558952d17442e8cc73f0c7dd606e329b38ed2ec0c1f83fe2567d28b21ef2223d2d23640cd0531f75832b50e519631c48643fcfaa7168851645dce07b90d87f0e" 19 | } 20 | , "0bc82ced9544980b9ffe7f64b1538bbda6804a5cc32c8035485e184b": 21 | { "omega": 0 22 | , "issuerPk": 23 | "MJ7IskKU8GKk0Eeg3zhfSOK1DDVXOMHD2V/zhEpODUtL9YB0Y7sXnbZfg3+Df05hskP5Jz+dZvdC6DH/dP9jmQ==" 24 | , "delegatePk": 25 | "hwO7NJL7LfAk5e/QG61FKcdORoK60tvprE3063Muh4EQKrWA6l7t23B2GziK8D0hRO0j5W1Gzpn8WW69XLIlKA==" 26 | , "cert": 27 | "2bccf50d0c3cbb03dd29cfba817e8ba615db3d7722b41b264ad08722e548cfe83d069b29d13e490823d7519ecdd9940ea49573f6027056c4bd58da1adf75020e" 28 | } 29 | , "18ed9844deef98cf9ba8b39791dede0538d2d2fa79bf67ef37dcc826": 30 | { "omega": 0 31 | , "issuerPk": 32 | "pXbW4Jak8maeuWiosvrurykKnqDSHswUjroonSDS3fTnWS+BKe+vjT4zZJNKhQ33KbagiHVJ5CJUNggfsCtG2g==" 33 | , "delegatePk": 34 | "rbJAZp3kWCUvp8dnLR6qsgpGU+qKAFow4NHYKWiKCkfm1qFCFONob50N1IbNWCGWAhg38ZPTvBazTasjsfj6yQ==" 35 | , "cert": 36 | "89e1638e31fd3d402cecb897ba773d8c2c11c2d3cff2462b266e21461539b1a4fe8fb528e159b9af473799b51e49aa5b5816a88f10c484aa7cef7ad12850830a" 37 | } 38 | , "66cfa84ad0ee5ca8586244c8393007cf3d9622d77cfa03fd4f35065b": 39 | { "omega": 0 40 | , "issuerPk": 41 | "/LGZjmmcAMRisP7Rf454GM2QUKgj2aAyqE+iQo2PIEhcistFOlT+idtbLTceZAnQcwwPJDtTcNi+EnPQyscZOg==" 42 | , "delegatePk": 43 | "rinFUiKKCPPFY0ULEKn1SPRgLVmOS3jdTXDtrxK6VI1I11G3uBS1Olxi0mQSN3kf+B3hm/xHkuUDVNaSXNiBeQ==" 44 | , "cert": 45 | "3e7f30bb68c5bc4d23c2a730ac154a188a1fd45aac3f438efd380303171443d2ca4f50e5a1ff66b40ae3da64697f2599956ae06c21b73fa828b8c0dc9fb27302" 46 | } 47 | , "76c4d6c68c0ef81ae364411a84e52ce66089ed006ca29adfc0227901": 48 | { "omega": 0 49 | , "issuerPk": 50 | "9EE85tTLdSSR4T1Xoy6n9wr6jlbavCdfp9oQKusskO3DSSyNqRYS7QzYQ96j/WnphUey63082YkKijMfF9A4eA==" 51 | , "delegatePk": 52 | "dvyHDkXg8LFtb0K6Sitl8OGSEZPvfCVQYLDR6Au6t6/ROvlerMKQ8uri4fG7hQQzbHKtdKWgv94t+zuFJTQ1fw==" 53 | , "cert": 54 | "5ec0ed46ae7e575bdb089f1bceca3b2689b13a7162fe08578fe60ba64607fffaa507412a97652c3c81cc0ef93ff404cf809a628ae19faba1a035fca0505c1d04" 55 | } 56 | , "8cc6b89fec65cc83d34b7bab2e6494db631d8476a86625767dd0c2a0": 57 | { "omega": 0 58 | , "issuerPk": 59 | "Hr5S5PAxf9HSB4FzmtZzaFcXrNrctrI5XUrDrnCkOUTX6rhbtOMkXU3sWVDOvU6LNSSr3/Ws2+iCYZIr7LmTWg==" 60 | , "delegatePk": 61 | "FaLH2b5H/XS31YRnm98N6fP4Etx6m+GbniVAXMwOp8KhYXPKBJBsX/EjIy3pSkvRBhGCjsycB0yrDxWMi5ZsIQ==" 62 | , "cert": 63 | "10f06304cceb42071605ebba67b308c7568e5e6fe0d773c58f7e8c13bc8d8a340f70a4fd5e1b4a1c1db1de5c7646802bbc929d6c82d7adb8a77cb6ad77eac50a" 64 | } 65 | , "e90060fdc085ac9f63cdb3b32ba1d84e0f7eb98561687b213b4c8770": 66 | { "omega": 0 67 | , "issuerPk": 68 | "B2R+VXzy3c8bxncdOpQ2Z/tblxRNQO8AXQ0OsJDQvZYnLeGQcLD78kyYLpi3nfuS4SfnLar23NV4yiEVwaw+Yw==" 69 | , "delegatePk": 70 | "nACHGIBacymrKwn07iW/a5ZKJCPZ2cKQqeXw3ivR7WOYVUuufWhZlCoUTZ7rtBqoDaexblUQwkC7hA7AmNA3FA==" 71 | , "cert": 72 | "b5440daa05f7fae557df46e4f1b7c5802b86f465daad1137e315abf6e72f1c877207276abb8dcba86e18e42d39b34c2f0fa82ba2919944cdc8e2e5264baa450b" 73 | } 74 | } 75 | , "startTime": 1666656000 76 | , "nonAvvmBalances": 77 | { "FHnt4NL7yPXjpZtYj1YUiX9QYYUZGXDT9gA2PJXQFkTSMx3EgawXK5BUrCHdhe2": 78 | "0" 79 | , "FHnt4NL7yPXk7D87qAWEmfnL7wSQ9AzBU2mjZt3eM48NSCbygxgzAU6vCGiRZEW": 80 | "0" 81 | , "FHnt4NL7yPXpazQsTdJ3Gp1twQUo4N5rrgGbRNSzchjchPiApc1k4CvqDMcdd7H": 82 | "0" 83 | , "FHnt4NL7yPXtNo1wLCLZyGTMfAvB14h8onafiYkM7B69ZwvGgXeUyQWfi7FPrif": 84 | "0" 85 | , "FHnt4NL7yPXtmi4mAjD43V3NB3shDs1gCuHNcMLPsRWjaw1b2yRV2xad8S8V6aq": 86 | "0" 87 | , "FHnt4NL7yPXvDWHa8bVs73UEUdJd64VxWXSFNqetECtYfTd9TtJguJ14Lu3feth": 88 | "30000000000000000" 89 | , "FHnt4NL7yPXvNSRpCYydjRr7koQCrsTtkovk5uYMimgqMJX2DyrEEBqiXaTd8rG": 90 | "0" 91 | , "FHnt4NL7yPY9rTvdsCeyRnsbzp4bN7XdmAZeU5PzA1qR2asYmN6CsdxJw4YoDjG": 92 | "0" 93 | } 94 | , "blockVersionData": 95 | { "scriptVersion": 0 96 | , "slotDuration": "20000" 97 | , "maxBlockSize": "2000000" 98 | , "maxHeaderSize": "2000000" 99 | , "maxTxSize": "4096" 100 | , "maxProposalSize": "700" 101 | , "mpcThd": "20000000000000" 102 | , "heavyDelThd": "300000000000" 103 | , "updateVoteThd": "1000000000000" 104 | , "updateProposalThd": "100000000000000" 105 | , "updateImplicit": "10000" 106 | , "softforkRule": 107 | { "initThd": "900000000000000" 108 | , "minThd": "600000000000000" 109 | , "thdDecrement": "50000000000000" 110 | } 111 | , "txFeePolicy": 112 | { "summand": "155381000000000" , "multiplier": "43946000000" } 113 | , "unlockStakeEpoch": "18446744073709551615" 114 | } 115 | , "protocolConsts": { "k": 432 , "protocolMagic": 2 } 116 | , "avvmDistr": {} 117 | } 118 | -------------------------------------------------------------------------------- /cardano-lib/preview/conway-genesis.json: -------------------------------------------------------------------------------- 1 | { 2 | "poolVotingThresholds": { 3 | "committeeNormal": 0.51, 4 | "committeeNoConfidence": 0.51, 5 | "hardForkInitiation": 0.51, 6 | "motionNoConfidence": 0.51, 7 | "ppSecurityGroup": 0.51 8 | }, 9 | "dRepVotingThresholds": { 10 | "motionNoConfidence": 0.67, 11 | "committeeNormal": 0.67, 12 | "committeeNoConfidence": 0.6, 13 | "updateToConstitution": 0.75, 14 | "hardForkInitiation": 0.6, 15 | "ppNetworkGroup": 0.67, 16 | "ppEconomicGroup": 0.67, 17 | "ppTechnicalGroup": 0.67, 18 | "ppGovGroup": 0.75, 19 | "treasuryWithdrawal": 0.67 20 | }, 21 | "committeeMinSize": 0, 22 | "committeeMaxTermLength": 365, 23 | "govActionLifetime": 30, 24 | "govActionDeposit": 100000000000, 25 | "dRepDeposit": 500000000, 26 | "dRepActivity": 20, 27 | "minFeeRefScriptCostPerByte": 15, 28 | "plutusV3CostModel": [ 29 | 100788, 30 | 420, 31 | 1, 32 | 1, 33 | 1000, 34 | 173, 35 | 0, 36 | 1, 37 | 1000, 38 | 59957, 39 | 4, 40 | 1, 41 | 11183, 42 | 32, 43 | 201305, 44 | 8356, 45 | 4, 46 | 16000, 47 | 100, 48 | 16000, 49 | 100, 50 | 16000, 51 | 100, 52 | 16000, 53 | 100, 54 | 16000, 55 | 100, 56 | 16000, 57 | 100, 58 | 100, 59 | 100, 60 | 16000, 61 | 100, 62 | 94375, 63 | 32, 64 | 132994, 65 | 32, 66 | 61462, 67 | 4, 68 | 72010, 69 | 178, 70 | 0, 71 | 1, 72 | 22151, 73 | 32, 74 | 91189, 75 | 769, 76 | 4, 77 | 2, 78 | 85848, 79 | 123203, 80 | 7305, 81 | -900, 82 | 1716, 83 | 549, 84 | 57, 85 | 85848, 86 | 0, 87 | 1, 88 | 1, 89 | 1000, 90 | 42921, 91 | 4, 92 | 2, 93 | 24548, 94 | 29498, 95 | 38, 96 | 1, 97 | 898148, 98 | 27279, 99 | 1, 100 | 51775, 101 | 558, 102 | 1, 103 | 39184, 104 | 1000, 105 | 60594, 106 | 1, 107 | 141895, 108 | 32, 109 | 83150, 110 | 32, 111 | 15299, 112 | 32, 113 | 76049, 114 | 1, 115 | 13169, 116 | 4, 117 | 22100, 118 | 10, 119 | 28999, 120 | 74, 121 | 1, 122 | 28999, 123 | 74, 124 | 1, 125 | 43285, 126 | 552, 127 | 1, 128 | 44749, 129 | 541, 130 | 1, 131 | 33852, 132 | 32, 133 | 68246, 134 | 32, 135 | 72362, 136 | 32, 137 | 7243, 138 | 32, 139 | 7391, 140 | 32, 141 | 11546, 142 | 32, 143 | 85848, 144 | 123203, 145 | 7305, 146 | -900, 147 | 1716, 148 | 549, 149 | 57, 150 | 85848, 151 | 0, 152 | 1, 153 | 90434, 154 | 519, 155 | 0, 156 | 1, 157 | 74433, 158 | 32, 159 | 85848, 160 | 123203, 161 | 7305, 162 | -900, 163 | 1716, 164 | 549, 165 | 57, 166 | 85848, 167 | 0, 168 | 1, 169 | 1, 170 | 85848, 171 | 123203, 172 | 7305, 173 | -900, 174 | 1716, 175 | 549, 176 | 57, 177 | 85848, 178 | 0, 179 | 1, 180 | 955506, 181 | 213312, 182 | 0, 183 | 2, 184 | 270652, 185 | 22588, 186 | 4, 187 | 1457325, 188 | 64566, 189 | 4, 190 | 20467, 191 | 1, 192 | 4, 193 | 0, 194 | 141992, 195 | 32, 196 | 100788, 197 | 420, 198 | 1, 199 | 1, 200 | 81663, 201 | 32, 202 | 59498, 203 | 32, 204 | 20142, 205 | 32, 206 | 24588, 207 | 32, 208 | 20744, 209 | 32, 210 | 25933, 211 | 32, 212 | 24623, 213 | 32, 214 | 43053543, 215 | 10, 216 | 53384111, 217 | 14333, 218 | 10, 219 | 43574283, 220 | 26308, 221 | 10, 222 | 16000, 223 | 100, 224 | 16000, 225 | 100, 226 | 962335, 227 | 18, 228 | 2780678, 229 | 6, 230 | 442008, 231 | 1, 232 | 52538055, 233 | 3756, 234 | 18, 235 | 267929, 236 | 18, 237 | 76433006, 238 | 8868, 239 | 18, 240 | 52948122, 241 | 18, 242 | 1995836, 243 | 36, 244 | 3227919, 245 | 12, 246 | 901022, 247 | 1, 248 | 166917843, 249 | 4307, 250 | 36, 251 | 284546, 252 | 36, 253 | 158221314, 254 | 26549, 255 | 36, 256 | 74698472, 257 | 36, 258 | 333849714, 259 | 1, 260 | 254006273, 261 | 72, 262 | 2174038, 263 | 72, 264 | 2261318, 265 | 64571, 266 | 4, 267 | 207616, 268 | 8310, 269 | 4, 270 | 1293828, 271 | 28716, 272 | 63, 273 | 0, 274 | 1, 275 | 1006041, 276 | 43623, 277 | 251, 278 | 0, 279 | 1 280 | ], 281 | "constitution": { 282 | "anchor": { 283 | "dataHash": "ca41a91f399259bcefe57f9858e91f6d00e1a38d6d9c63d4052914ea7bd70cb2", 284 | "url": "ipfs://bafkreifnwj6zpu3ixa4siz2lndqybyc5wnnt3jkwyutci4e2tmbnj3xrdm" 285 | }, 286 | "script": "fa24fb305126805cf2164c161d852a0e7330cf988f1fe558cf7d4a64" 287 | }, 288 | "committee": { 289 | "members": { 290 | "scriptHash-ff9babf23fef3f54ec29132c07a8e23807d7b395b143ecd8ff79f4c7": 1000 291 | }, 292 | "threshold": { 293 | "numerator": 2, 294 | "denominator": 3 295 | } 296 | } 297 | } 298 | -------------------------------------------------------------------------------- /cardano-lib/preview/shelley-genesis.json: -------------------------------------------------------------------------------- 1 | { 2 | "activeSlotsCoeff": 0.05, 3 | "epochLength": 86400, 4 | "genDelegs": { 5 | "12b0f443d02861948a0fce9541916b014e8402984c7b83ad70a834ce": { 6 | "delegate": "7c54a168c731f2f44ced620f3cca7c2bd90731cab223d5167aa994e6", 7 | "vrf": "62d546a35e1be66a2b06e29558ef33f4222f1c466adbb59b52d800964d4e60ec" 8 | }, 9 | "3df542796a64e399b60c74acfbdb5afa1e114532fa36b46d6368ef3a": { 10 | "delegate": "c44bc2f3cc7e98c0f227aa399e4035c33c0d775a0985875fff488e20", 11 | "vrf": "4f9d334decadff6eba258b2df8ae1f02580a2628bce47ae7d957e1acd3f42a3c" 12 | }, 13 | "93fd5083ff20e7ab5570948831730073143bea5a5d5539852ed45889": { 14 | "delegate": "82a02922f10105566b70366b07c758c8134fa91b3d8ae697dfa5e8e0", 15 | "vrf": "8a57e94a9b4c65ec575f35d41edb1df399fa30fdf10775389f5d1ef670ca3f9f" 16 | }, 17 | "a86cab3ea72eabb2e8aafbbf4abbd2ba5bdfd04eea26a39b126a78e4": { 18 | "delegate": "10257f6d3bae913514bdc96c9170b3166bf6838cca95736b0e418426", 19 | "vrf": "1b54aad6b013145a0fc74bb5c2aa368ebaf3999e88637d78e09706d0cc29874a" 20 | }, 21 | "b799804a28885bd49c0e1b99d8b3b26de0fac17a5cf651ecf0c872f0": { 22 | "delegate": "ebe606e22d932d51be2c1ce87e7d7e4c9a7d1f7df4a5535c29e23d22", 23 | "vrf": "b3fc06a1f8ee69ff23185d9af453503be8b15b2652e1f9fb7c3ded6797a2d6f9" 24 | }, 25 | "d125812d6ab973a2c152a0525b7fd32d36ff13555a427966a9cac9b1": { 26 | "delegate": "e302198135fb5b00bfe0b9b5623426f7cf03179ab7ba75f945d5b79b", 27 | "vrf": "b45ca2ed95f92248fa0322ce1fc9f815a5a5aa2f21f1adc2c42c4dccfc7ba631" 28 | }, 29 | "ef27651990a26449a40767d5e06cdef1670a3f3ff4b951d385b51787": { 30 | "delegate": "0e0b11e80d958732e587585d30978d683a061831d1b753878f549d05", 31 | "vrf": "b860ec844f6cd476c4fabb4aa1ca72d5c74d82f3835aed3c9515a35b6e048719" 32 | } 33 | }, 34 | "initialFunds": {}, 35 | "maxKESEvolutions": 62, 36 | "maxLovelaceSupply": 45000000000000000, 37 | "networkId": "Testnet", 38 | "networkMagic": 2, 39 | "protocolParams": { 40 | "protocolVersion": { 41 | "minor": 0, 42 | "major": 6 43 | }, 44 | "decentralisationParam": 1, 45 | "eMax": 18, 46 | "extraEntropy": { 47 | "tag": "NeutralNonce" 48 | }, 49 | "maxTxSize": 16384, 50 | "maxBlockBodySize": 65536, 51 | "maxBlockHeaderSize": 1100, 52 | "minFeeA": 44, 53 | "minFeeB": 155381, 54 | "minUTxOValue": 1000000, 55 | "poolDeposit": 500000000, 56 | "minPoolCost": 340000000, 57 | "keyDeposit": 2000000, 58 | "nOpt": 150, 59 | "rho": 0.003, 60 | "tau": 0.20, 61 | "a0": 0.3 62 | }, 63 | "securityParam": 432, 64 | "slotLength": 1, 65 | "slotsPerKESPeriod": 129600, 66 | "systemStart": "2022-10-25T00:00:00Z", 67 | "updateQuorum": 5 68 | } 69 | -------------------------------------------------------------------------------- /cardano-lib/testnet-template/Readme.md: -------------------------------------------------------------------------------- 1 | # Generate new testnet 2 | 3 | ``` 4 | cardano-cli genesis create-cardano \ 5 | --genesis-dir . \ 6 | --gen-genesis-keys 3 \ 7 | --supply 30000000000000000 \ 8 | --testnet-magic 42 \ 9 | --slot-coefficient 0.05 \ 10 | --byron-template byron.json \ 11 | --shelley-template shelley.json \ 12 | --alonzo-template alonzo.json \ 13 | --conway-template conway.json \ 14 | --security-param 108 \ 15 | --slot-length 1000 \ 16 | --node-config-template config.json 17 | ``` 18 | -------------------------------------------------------------------------------- /cardano-lib/testnet-template/alonzo.json: -------------------------------------------------------------------------------- 1 | { 2 | "lovelacePerUTxOWord": 34482, 3 | "executionPrices": { 4 | "prSteps": { 5 | "numerator": 721, 6 | "denominator": 10000000 7 | }, 8 | "prMem": { 9 | "numerator": 577, 10 | "denominator": 10000 11 | } 12 | }, 13 | "maxTxExUnits": { 14 | "exUnitsMem": 10000000, 15 | "exUnitsSteps": 10000000000 16 | }, 17 | "maxBlockExUnits": { 18 | "exUnitsMem": 50000000, 19 | "exUnitsSteps": 40000000000 20 | }, 21 | "maxValueSize": 5000, 22 | "collateralPercentage": 150, 23 | "maxCollateralInputs": 3, 24 | "costModels": { 25 | "PlutusV1": { 26 | "sha2_256-memory-arguments": 4, 27 | "equalsString-cpu-arguments-constant": 1000, 28 | "cekDelayCost-exBudgetMemory": 100, 29 | "lessThanEqualsByteString-cpu-arguments-intercept": 103599, 30 | "divideInteger-memory-arguments-minimum": 1, 31 | "appendByteString-cpu-arguments-slope": 621, 32 | "blake2b-cpu-arguments-slope": 29175, 33 | "iData-cpu-arguments": 150000, 34 | "encodeUtf8-cpu-arguments-slope": 1000, 35 | "unBData-cpu-arguments": 150000, 36 | "multiplyInteger-cpu-arguments-intercept": 61516, 37 | "cekConstCost-exBudgetMemory": 100, 38 | "nullList-cpu-arguments": 150000, 39 | "equalsString-cpu-arguments-intercept": 150000, 40 | "trace-cpu-arguments": 150000, 41 | "mkNilData-memory-arguments": 32, 42 | "lengthOfByteString-cpu-arguments": 150000, 43 | "cekBuiltinCost-exBudgetCPU": 29773, 44 | "bData-cpu-arguments": 150000, 45 | "subtractInteger-cpu-arguments-slope": 0, 46 | "unIData-cpu-arguments": 150000, 47 | "consByteString-memory-arguments-intercept": 0, 48 | "divideInteger-memory-arguments-slope": 1, 49 | "divideInteger-cpu-arguments-model-arguments-slope": 118, 50 | "listData-cpu-arguments": 150000, 51 | "headList-cpu-arguments": 150000, 52 | "chooseData-memory-arguments": 32, 53 | "equalsInteger-cpu-arguments-intercept": 136542, 54 | "sha3_256-cpu-arguments-slope": 82363, 55 | "sliceByteString-cpu-arguments-slope": 5000, 56 | "unMapData-cpu-arguments": 150000, 57 | "lessThanInteger-cpu-arguments-intercept": 179690, 58 | "mkCons-cpu-arguments": 150000, 59 | "appendString-memory-arguments-intercept": 0, 60 | "modInteger-cpu-arguments-model-arguments-slope": 118, 61 | "ifThenElse-cpu-arguments": 1, 62 | "mkNilPairData-cpu-arguments": 150000, 63 | "lessThanEqualsInteger-cpu-arguments-intercept": 145276, 64 | "addInteger-memory-arguments-slope": 1, 65 | "chooseList-memory-arguments": 32, 66 | "constrData-memory-arguments": 32, 67 | "decodeUtf8-cpu-arguments-intercept": 150000, 68 | "equalsData-memory-arguments": 1, 69 | "subtractInteger-memory-arguments-slope": 1, 70 | "appendByteString-memory-arguments-intercept": 0, 71 | "lengthOfByteString-memory-arguments": 4, 72 | "headList-memory-arguments": 32, 73 | "listData-memory-arguments": 32, 74 | "consByteString-cpu-arguments-intercept": 150000, 75 | "unIData-memory-arguments": 32, 76 | "remainderInteger-memory-arguments-minimum": 1, 77 | "bData-memory-arguments": 32, 78 | "lessThanByteString-cpu-arguments-slope": 248, 79 | "encodeUtf8-memory-arguments-intercept": 0, 80 | "cekStartupCost-exBudgetCPU": 100, 81 | "multiplyInteger-memory-arguments-intercept": 0, 82 | "unListData-memory-arguments": 32, 83 | "remainderInteger-cpu-arguments-model-arguments-slope": 118, 84 | "cekVarCost-exBudgetCPU": 29773, 85 | "remainderInteger-memory-arguments-slope": 1, 86 | "cekForceCost-exBudgetCPU": 29773, 87 | "sha2_256-cpu-arguments-slope": 29175, 88 | "equalsInteger-memory-arguments": 1, 89 | "indexByteString-memory-arguments": 1, 90 | "addInteger-memory-arguments-intercept": 1, 91 | "chooseUnit-cpu-arguments": 150000, 92 | "sndPair-cpu-arguments": 150000, 93 | "cekLamCost-exBudgetCPU": 29773, 94 | "fstPair-cpu-arguments": 150000, 95 | "quotientInteger-memory-arguments-minimum": 1, 96 | "decodeUtf8-cpu-arguments-slope": 1000, 97 | "lessThanInteger-memory-arguments": 1, 98 | "lessThanEqualsInteger-cpu-arguments-slope": 1366, 99 | "fstPair-memory-arguments": 32, 100 | "modInteger-memory-arguments-intercept": 0, 101 | "unConstrData-cpu-arguments": 150000, 102 | "lessThanEqualsInteger-memory-arguments": 1, 103 | "chooseUnit-memory-arguments": 32, 104 | "sndPair-memory-arguments": 32, 105 | "addInteger-cpu-arguments-intercept": 197209, 106 | "decodeUtf8-memory-arguments-slope": 8, 107 | "equalsData-cpu-arguments-intercept": 150000, 108 | "mapData-cpu-arguments": 150000, 109 | "mkPairData-cpu-arguments": 150000, 110 | "quotientInteger-cpu-arguments-constant": 148000, 111 | "consByteString-memory-arguments-slope": 1, 112 | "cekVarCost-exBudgetMemory": 100, 113 | "indexByteString-cpu-arguments": 150000, 114 | "unListData-cpu-arguments": 150000, 115 | "equalsInteger-cpu-arguments-slope": 1326, 116 | "cekStartupCost-exBudgetMemory": 100, 117 | "subtractInteger-cpu-arguments-intercept": 197209, 118 | "divideInteger-cpu-arguments-model-arguments-intercept": 425507, 119 | "divideInteger-memory-arguments-intercept": 0, 120 | "cekForceCost-exBudgetMemory": 100, 121 | "blake2b-cpu-arguments-intercept": 2477736, 122 | "remainderInteger-cpu-arguments-constant": 148000, 123 | "tailList-cpu-arguments": 150000, 124 | "encodeUtf8-cpu-arguments-intercept": 150000, 125 | "equalsString-cpu-arguments-slope": 1000, 126 | "lessThanByteString-memory-arguments": 1, 127 | "multiplyInteger-cpu-arguments-slope": 11218, 128 | "appendByteString-cpu-arguments-intercept": 396231, 129 | "lessThanEqualsByteString-cpu-arguments-slope": 248, 130 | "modInteger-memory-arguments-slope": 1, 131 | "addInteger-cpu-arguments-slope": 0, 132 | "equalsData-cpu-arguments-slope": 10000, 133 | "decodeUtf8-memory-arguments-intercept": 0, 134 | "chooseList-cpu-arguments": 150000, 135 | "constrData-cpu-arguments": 150000, 136 | "equalsByteString-memory-arguments": 1, 137 | "cekApplyCost-exBudgetCPU": 29773, 138 | "quotientInteger-memory-arguments-slope": 1, 139 | "verifySignature-cpu-arguments-intercept": 3345831, 140 | "unMapData-memory-arguments": 32, 141 | "mkCons-memory-arguments": 32, 142 | "sliceByteString-memory-arguments-slope": 1, 143 | "sha3_256-memory-arguments": 4, 144 | "ifThenElse-memory-arguments": 1, 145 | "mkNilPairData-memory-arguments": 32, 146 | "equalsByteString-cpu-arguments-slope": 247, 147 | "appendString-cpu-arguments-intercept": 150000, 148 | "quotientInteger-cpu-arguments-model-arguments-slope": 118, 149 | "cekApplyCost-exBudgetMemory": 100, 150 | "equalsString-memory-arguments": 1, 151 | "multiplyInteger-memory-arguments-slope": 1, 152 | "cekBuiltinCost-exBudgetMemory": 100, 153 | "remainderInteger-memory-arguments-intercept": 0, 154 | "sha2_256-cpu-arguments-intercept": 2477736, 155 | "remainderInteger-cpu-arguments-model-arguments-intercept": 425507, 156 | "lessThanEqualsByteString-memory-arguments": 1, 157 | "tailList-memory-arguments": 32, 158 | "mkNilData-cpu-arguments": 150000, 159 | "chooseData-cpu-arguments": 150000, 160 | "unBData-memory-arguments": 32, 161 | "blake2b-memory-arguments": 4, 162 | "iData-memory-arguments": 32, 163 | "nullList-memory-arguments": 32, 164 | "cekDelayCost-exBudgetCPU": 29773, 165 | "subtractInteger-memory-arguments-intercept": 1, 166 | "lessThanByteString-cpu-arguments-intercept": 103599, 167 | "consByteString-cpu-arguments-slope": 1000, 168 | "appendByteString-memory-arguments-slope": 1, 169 | "trace-memory-arguments": 32, 170 | "divideInteger-cpu-arguments-constant": 148000, 171 | "cekConstCost-exBudgetCPU": 29773, 172 | "encodeUtf8-memory-arguments-slope": 8, 173 | "quotientInteger-cpu-arguments-model-arguments-intercept": 425507, 174 | "mapData-memory-arguments": 32, 175 | "appendString-cpu-arguments-slope": 1000, 176 | "modInteger-cpu-arguments-constant": 148000, 177 | "verifySignature-cpu-arguments-slope": 1, 178 | "unConstrData-memory-arguments": 32, 179 | "quotientInteger-memory-arguments-intercept": 0, 180 | "equalsByteString-cpu-arguments-constant": 150000, 181 | "sliceByteString-memory-arguments-intercept": 0, 182 | "mkPairData-memory-arguments": 32, 183 | "equalsByteString-cpu-arguments-intercept": 112536, 184 | "appendString-memory-arguments-slope": 1, 185 | "lessThanInteger-cpu-arguments-slope": 497, 186 | "modInteger-cpu-arguments-model-arguments-intercept": 425507, 187 | "modInteger-memory-arguments-minimum": 1, 188 | "sha3_256-cpu-arguments-intercept": 0, 189 | "verifySignature-memory-arguments": 1, 190 | "cekLamCost-exBudgetMemory": 100, 191 | "sliceByteString-cpu-arguments-intercept": 150000 192 | } 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /cardano-lib/testnet-template/byron.json: -------------------------------------------------------------------------------- 1 | { 2 | "heavyDelThd": "300000000000", 3 | "maxBlockSize": "2000000", 4 | "maxTxSize": "4096", 5 | "maxHeaderSize": "2000000", 6 | "maxProposalSize": "700", 7 | "mpcThd": "20000000000000", 8 | "scriptVersion": 0, 9 | "slotDuration": "200", 10 | "softforkRule": { 11 | "initThd": "900000000000000", 12 | "minThd": "600000000000000", 13 | "thdDecrement": "50000000000000" 14 | }, 15 | "txFeePolicy": { 16 | "multiplier": "43946000000", 17 | "summand": "155381000000000" 18 | }, 19 | "unlockStakeEpoch": "18446744073709551615", 20 | "updateImplicit": "10000", 21 | "updateProposalThd": "100000000000000", 22 | "updateVoteThd": "1000000000000" 23 | } 24 | -------------------------------------------------------------------------------- /cardano-lib/testnet-template/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "ByronGenesisFile": "byron-genesis.json", 3 | "ShelleyGenesisFile": "shelley-genesis.json", 4 | "AlonzoGenesisFile": "alonzo-genesis.json", 5 | "ConwayGenesisFile": "conway-genesis.json", 6 | "ApplicationName": "cardano-sl", 7 | "ApplicationVersion": 0, 8 | "LastKnownBlockVersion-Alt": 0, 9 | "LastKnownBlockVersion-Major": 3, 10 | "LastKnownBlockVersion-Minor": 1, 11 | "LedgerDB": { 12 | "Backend": "V2InMemory", 13 | "NumOfDiskSnapshots": 2, 14 | "QueryBatchSize": 100000, 15 | "SnapshotInterval": 216 16 | }, 17 | "MaxConcurrencyDeadline": 4, 18 | "MaxKnownMajorProtocolVersion": 2, 19 | "PBftSignatureThreshold": 1.1, 20 | "Protocol": "Cardano", 21 | "RequiresNetworkMagic": "RequiresMagic", 22 | "TestShelleyHardForkAtEpoch": 0, 23 | "TestAllegraHardForkAtEpoch": 0, 24 | "TestMaryHardForkAtEpoch": 0, 25 | "TestAlonzoHardForkAtEpoch": 0, 26 | "EnableP2P": true, 27 | "ExperimentalProtocolsEnabled": true, 28 | "ExperimentalHardForksEnabled": true, 29 | "TargetNumberOfActivePeers": 20, 30 | "TargetNumberOfEstablishedPeers": 40, 31 | "TargetNumberOfKnownPeers": 100, 32 | "TargetNumberOfRootPeers": 100, 33 | "TraceAcceptPolicy": true, 34 | "TraceBlockFetchClient": false, 35 | "TraceBlockFetchDecisions": false, 36 | "TraceBlockFetchProtocol": false, 37 | "TraceBlockFetchProtocolSerialised": false, 38 | "TraceBlockFetchServer": false, 39 | "TraceChainDb": true, 40 | "TraceChainSyncBlockServer": false, 41 | "TraceChainSyncClient": false, 42 | "TraceChainSyncHeaderServer": false, 43 | "TraceChainSyncProtocol": false, 44 | "TraceConnectionManager": true, 45 | "TraceDNSResolver": true, 46 | "TraceDNSSubscription": true, 47 | "TraceDiffusionInitialization": true, 48 | "TraceErrorPolicy": true, 49 | "TraceForge": true, 50 | "TraceHandshake": false, 51 | "TraceInboundGovernor": true, 52 | "TraceIpSubscription": true, 53 | "TraceLedgerPeers": true, 54 | "TraceLocalChainSyncProtocol": false, 55 | "TraceLocalErrorPolicy": true, 56 | "TraceLocalHandshake": false, 57 | "TraceLocalRootPeers": true, 58 | "TraceLocalTxSubmissionProtocol": false, 59 | "TraceLocalTxSubmissionServer": false, 60 | "TraceMempool": false, 61 | "TraceMux": false, 62 | "TracePeerSelection": true, 63 | "TracePeerSelectionActions": true, 64 | "TracePublicRootPeers": true, 65 | "TraceServer": true, 66 | "TraceTxInbound": false, 67 | "TraceTxOutbound": false, 68 | "TraceTxSubmissionProtocol": false, 69 | "TracingVerbosity": "NormalVerbosity", 70 | "TurnOnLogMetrics": true, 71 | "TurnOnLogging": true, 72 | "defaultBackends": ["KatipBK"], 73 | "defaultScribes": [["StdoutSK", "cardano"]], 74 | "hasEKG": 12788, 75 | "hasPrometheus": ["0.0.0.0", 12798], 76 | "minSeverity": "Debug", 77 | "options": { 78 | "mapBackends": { 79 | "cardano.node.metrics": ["EKGViewBK"], 80 | "cardano.node.resources": ["EKGViewBK"] 81 | }, 82 | "mapSubtrace": { 83 | "cardano.node.metrics": { 84 | "subtrace": "Neutral" 85 | } 86 | } 87 | }, 88 | "rotation": { 89 | "rpKeepFilesNum": 10, 90 | "rpLogLimitBytes": 5000000, 91 | "rpMaxAgeHours": 24 92 | }, 93 | "setupBackends": ["KatipBK"], 94 | "setupScribes": [ 95 | { 96 | "scFormat": "ScText", 97 | "scKind": "StdoutSK", 98 | "scName": "cardano" 99 | } 100 | ] 101 | } 102 | -------------------------------------------------------------------------------- /cardano-lib/testnet-template/conway.json: -------------------------------------------------------------------------------- 1 | { 2 | "poolVotingThresholds": { 3 | "committeeNormal": 0.60, 4 | "committeeNoConfidence": 0.51, 5 | "hardForkInitiation": 0.51, 6 | "motionNoConfidence": 0.60, 7 | "ppSecurityGroup": 0.60 8 | }, 9 | "dRepVotingThresholds": { 10 | "motionNoConfidence": 0.67, 11 | "committeeNormal": 0.67, 12 | "committeeNoConfidence": 0.60, 13 | "updateToConstitution": 0.75, 14 | "hardForkInitiation": 0.60, 15 | "ppNetworkGroup": 0.67, 16 | "ppEconomicGroup": 0.67, 17 | "ppTechnicalGroup": 0.67, 18 | "ppGovGroup": 0.75, 19 | "treasuryWithdrawal": 0.67 20 | }, 21 | "committeeMinSize": 7, 22 | "committeeMaxTermLength": 73, 23 | "govActionLifetime": 6, 24 | "govActionDeposit": 50000000000, 25 | "dRepDeposit": 500000000, 26 | "dRepActivity": 20, 27 | "minFeeRefScriptCostPerByte": 44, 28 | "constitution": { 29 | "anchor": { 30 | "url": "", 31 | "dataHash": "0000000000000000000000000000000000000000000000000000000000000000" 32 | } 33 | }, 34 | "committee": { 35 | "members": { 36 | }, 37 | "threshold": 0.67 38 | }, 39 | "plutusV3CostModel": [ 40 | 100788, 41 | 420, 42 | 1, 43 | 1, 44 | 1000, 45 | 173, 46 | 0, 47 | 1, 48 | 1000, 49 | 59957, 50 | 4, 51 | 1, 52 | 11183, 53 | 32, 54 | 207616, 55 | 8310, 56 | 4, 57 | 201305, 58 | 8356, 59 | 4, 60 | 962335, 61 | 18, 62 | 2780678, 63 | 6, 64 | 442008, 65 | 1, 66 | 52538055, 67 | 3756, 68 | 18, 69 | 267929, 70 | 18, 71 | 76433006, 72 | 8868, 73 | 18, 74 | 52948122, 75 | 18, 76 | 1995836, 77 | 36, 78 | 3227919, 79 | 12, 80 | 901022, 81 | 1, 82 | 166917843, 83 | 4307, 84 | 36, 85 | 284546, 86 | 36, 87 | 158221314, 88 | 26549, 89 | 36, 90 | 74698472, 91 | 36, 92 | 333849714, 93 | 1, 94 | 254006273, 95 | 72, 96 | 2174038, 97 | 72, 98 | 1006041, 99 | 43623, 100 | 251, 101 | 0, 102 | 1, 103 | 16000, 104 | 100, 105 | 16000, 106 | 100, 107 | 16000, 108 | 100, 109 | 16000, 110 | 100, 111 | 16000, 112 | 100, 113 | 16000, 114 | 100, 115 | 16000, 116 | 100, 117 | 16000, 118 | 100, 119 | 100, 120 | 100, 121 | 16000, 122 | 100, 123 | 94375, 124 | 32, 125 | 132994, 126 | 32, 127 | 61462, 128 | 4, 129 | 72010, 130 | 178, 131 | 0, 132 | 1, 133 | 22151, 134 | 32, 135 | 91189, 136 | 769, 137 | 4, 138 | 2, 139 | 85848, 140 | 228465, 141 | 122, 142 | 0, 143 | 1, 144 | 1, 145 | 1000, 146 | 42921, 147 | 4, 148 | 2, 149 | 24548, 150 | 29498, 151 | 38, 152 | 1, 153 | 898148, 154 | 27279, 155 | 1, 156 | 51775, 157 | 558, 158 | 1, 159 | 39184, 160 | 1000, 161 | 60594, 162 | 1, 163 | 141895, 164 | 32, 165 | 83150, 166 | 32, 167 | 15299, 168 | 32, 169 | 76049, 170 | 1, 171 | 13169, 172 | 4, 173 | 1293828, 174 | 28716, 175 | 63, 176 | 0, 177 | 1, 178 | 2261318, 179 | 64571, 180 | 4, 181 | 22100, 182 | 10, 183 | 28999, 184 | 74, 185 | 1, 186 | 28999, 187 | 74, 188 | 1, 189 | 43285, 190 | 552, 191 | 1, 192 | 44749, 193 | 541, 194 | 1, 195 | 33852, 196 | 32, 197 | 68246, 198 | 32, 199 | 72362, 200 | 32, 201 | 7243, 202 | 32, 203 | 7391, 204 | 32, 205 | 11546, 206 | 32, 207 | 85848, 208 | 228465, 209 | 122, 210 | 0, 211 | 1, 212 | 1, 213 | 90434, 214 | 519, 215 | 0, 216 | 1, 217 | 74433, 218 | 32, 219 | 85848, 220 | 228465, 221 | 122, 222 | 0, 223 | 1, 224 | 1, 225 | 85848, 226 | 228465, 227 | 122, 228 | 0, 229 | 1, 230 | 1, 231 | 955506, 232 | 213312, 233 | 0, 234 | 2, 235 | 270652, 236 | 22588, 237 | 4, 238 | 1457325, 239 | 64566, 240 | 4, 241 | 20467, 242 | 1, 243 | 4, 244 | 0, 245 | 141992, 246 | 32, 247 | 100788, 248 | 420, 249 | 1, 250 | 1, 251 | 81663, 252 | 32, 253 | 59498, 254 | 32, 255 | 20142, 256 | 32, 257 | 24588, 258 | 32, 259 | 20744, 260 | 32, 261 | 25933, 262 | 32, 263 | 24623, 264 | 32, 265 | 43053543, 266 | 10, 267 | 53384111, 268 | 14333, 269 | 10, 270 | 43574283, 271 | 26308, 272 | 10 273 | ] 274 | } 275 | -------------------------------------------------------------------------------- /cardano-lib/testnet-template/shelley.json: -------------------------------------------------------------------------------- 1 | { 2 | "activeSlotsCoeff": 0.05, 3 | "protocolParams": { 4 | "protocolVersion": { 5 | "minor": 0, 6 | "major": 6 7 | }, 8 | "decentralisationParam": 1, 9 | "eMax": 18, 10 | "extraEntropy": { 11 | "tag": "NeutralNonce" 12 | }, 13 | "maxTxSize": 16384, 14 | "maxBlockBodySize": 65536, 15 | "maxBlockHeaderSize": 1100, 16 | "minFeeA": 44, 17 | "minFeeB": 155381, 18 | "minUTxOValue": 1000000, 19 | "poolDeposit": 500000000, 20 | "minPoolCost": 340000000, 21 | "keyDeposit": 2000000, 22 | "nOpt": 150, 23 | "rho": 0.003, 24 | "tau": 0.2, 25 | "a0": 0.3 26 | }, 27 | "genDelegs": {}, 28 | "updateQuorum": 3, 29 | "networkId": "Testnet", 30 | "initialFunds": {}, 31 | "maxLovelaceSupply": 45000000000000000, 32 | "networkMagic": 42, 33 | "epochLength": 432000, 34 | "systemStart": "1970-01-01T00:00:00Z", 35 | "slotsPerKESPeriod": 129600, 36 | "slotLength": 1, 37 | "maxKESEvolutions": 62, 38 | "securityParam": 108 39 | } 40 | -------------------------------------------------------------------------------- /cardano-lib/testnet-template/topology-empty-p2p.json: -------------------------------------------------------------------------------- 1 | { 2 | "localRoots": [ 3 | { 4 | "accessPoints": [], 5 | "advertise": false, 6 | "valency": 1 7 | } 8 | ], 9 | "publicRoots": [ 10 | { 11 | "accessPoints": [], 12 | "advertise": false 13 | } 14 | ], 15 | "useLedgerAfterSlot": -1 16 | } 17 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # ChangeLog 2 | 3 | Please read these notes when updating your project's `iohk-nix` 4 | version. There may have been changes which could break your build. 5 | 6 | ## 2023-04-20 7 | * Added `blst` library with dynamic, and static lirbaries, as well as pkg-config metadata. 8 | * Renamed `blst` to `libblst` 9 | * Added [haskell-nix](https://github.com/input-output-hk/haskell.nix) `extraPkgconfigMappings` for `libblst` and `libsodium`. 10 | This should allow us to drop the previously needed hack to map `libsodium-vrf` to `libsodium`. 11 | 12 | ## 2021-07-22 13 | * Renamed `libsodium` to `libsodium-vrf` in the crypto overlay. This 14 | allows much more sharing from the binary caches. 15 | 16 | Any package which has dependencies on the VRF fork of libsodium 17 | must now add a Haskell.nix module to select the forked package. 18 | For example: 19 | 20 | ```nix 21 | ({ lib, pkgs, ...}: { 22 | # Use our forked libsodium from iohk-nix crypto overlay. 23 | packages.cardano-crypto-praos.components.library.pkgconfig = lib.mkForce [ [ pkgs.libsodium-vrf ] ]; 24 | packages.cardano-crypto-class.components.library.pkgconfig = lib.mkForce [ [ pkgs.libsodium-vrf ] ]; 25 | }) 26 | ``` 27 | 28 | ## 2021-02-21 29 | * Reduce build closure size and the amount of code in iohk-nix. 30 | * Removed `haskell-nix-extra.stack-hpc-coveralls` - use 31 | ``` 32 | haskell-nix.tool "ghc865" "stack-hpc-coveralls" "1.2.0" 33 | ``` 34 | instead. 35 | * Removed `haskell-nix-extra.hpc-coveralls` - use 36 | ``` 37 | haskell-nix.tool "ghc865" "hpc-coveralls" "0.0.4.0" 38 | ``` 39 | instead. 40 | * Deprecated the `haskell-nix.haskellLib.extra.collectChecks` function 41 | in favour of `haskell-nix.haskellLib.collectChecks'`. 42 | * Removed `haskell-nix-extra.haskellBuildUtils.stackRebuild`. 43 | * Renamed `haskell-nix-extra.haskellBuildUtils.package` 44 | to `haskell-nix-extra.haskellBuildUtils`. 45 | * `haskellBuildUtils` changed build system from `callCabal2nix` 46 | to Haskell.nix. It requires another overlay 47 | to provide `pkg.haskell-nix`. 48 | * When using `haskellBuildUtils`, also add `haskellBuildUtils.roots` 49 | to your `release.nix`, so that eval-time dependencies are cached. 50 | 51 | ## 2021-01-04 52 | * Switch default nixpkgs to nixos-unstable 53 | 54 | ## 2020-11-11 55 | * Switch default nixpkgs to 20.09 56 | * `commonLib.commitIdFromGitRepo` is deprecated in favour of nixpkgs `lib.commitIdFromGitRepo`. 57 | 58 | ## 2020-07-14 59 | * Bump Haskell.nix to latest. There are [multiple API changes](https://github.com/input-output-hk/haskell.nix/blob/master/changelog.md). 60 | * Fix `stackNixRegenerate` script for latest Haskell.nix. 61 | 62 | ## 2020-05-27 63 | * Switch default nixpkgs to 20.03 64 | * Remove skeleton (moved to https://github.com/input-output-hk/cardano-skeleton/) 65 | 66 | ## 2020-02-19 67 | * remove support for haskell.nix (use overlays instead) 68 | * removes numerous deprecations related to removal of haskell.nix support 69 | 70 | ## 2020-02-06 71 | * migrate skeleton to cabalProject and haskell.nix as overlay. 72 | 73 | ## 2020-01-14 74 | * Add a timeout parameter to the `Build.doBuild`, in `iohk-nix-utils`. 75 | 76 | ## 2019-10-27 77 | * Changes `mkRequired` of `release-lib` to return an attribute set 78 | containing `required` and `build-version` 79 | 80 | ## 2019-10-08 81 | 82 | * Switched to niv for source management instead of json files 83 | 84 | 85 | ## 2019-07-25 86 | 87 | * Added a [skeleton project](./skeleton/README.md) which provides a 88 | reference on how to set up iohk-nix CI for projects. 89 | 90 | ## 2019-07-23 91 | 92 | * new `disabled-jobs` parameter to `release-nix`: all jobs with a path 93 | that starts with one of the values in the `disabled-jobs` list are ignored 94 | (and no longer built by hydra). 95 | 96 | ## 2019-07-22 97 | 98 | * The `check-nix-tools` CI script (run by `nix/regenerate.sh`) has been updated in 99 | [PR #131](https://github.com/input-output-hk/iohk-nix/pull/131). 100 | It should work in much the same way as before, but can push fixes (changes in generated nix code) 101 | to PR branches if credentials for the repo have been installed on 102 | the Buildkite agents. 103 | 104 | * `release-nix` now provides jobs that respectively aggregates all libs, exes, tests and benchmarks of the project for each supported system, eg.: 105 | - nix-tools.packages-tests.x86_64-linux 106 | - nix-tools.packages-libs.x86_64-darwin 107 | - nix-tools.x86_64-pc-mingw32-packages-exes.x86_64-linux 108 | 109 | ## 2019-04-09 110 | 111 | * Started changelog 112 | -------------------------------------------------------------------------------- /ci.nix: -------------------------------------------------------------------------------- 1 | let 2 | sources = import ./nix/sources.nix; 3 | nixpkgs = import sources.nixpkgs { }; 4 | iohk-nix = import ./. { }; 5 | inherit (nixpkgs.lib) flatten mapAttrs; 6 | 7 | in { 8 | jormungandr = nixpkgs.recurseIntoAttrs (mapAttrs (name: env: 9 | nixpkgs.recurseIntoAttrs { 10 | inherit (env.packages) jcli jcli-debug jormungandr jormungandr-debug; 11 | }) iohk-nix.jormungandrLib.environments); 12 | } 13 | -------------------------------------------------------------------------------- /ci/aggregates.nix: -------------------------------------------------------------------------------- 1 | # Produce a set with two pkgs.releaseTools.aggregate jobs from a `ciJobs` set: 2 | # one for required jobs (`required`) and one for all other jobs (`nonrequired`). 3 | { 4 | lib, 5 | releaseTools, 6 | # all the ci jobs: 7 | ciJobs, 8 | # path prefix of jobs that should not be required for CI to pass (end up in `nonrequired`): 9 | nonRequiredPaths ? map lib.hasPrefix [], 10 | }: let 11 | collectConstituents = excludeTest: 12 | lib.collect lib.isDerivation 13 | (lib.mapAttrsRecursiveCond (v: !(lib.isDerivation v)) 14 | (path: value: let 15 | stringPath = lib.concatStringsSep "." path; 16 | in 17 | if lib.isAttrs value && excludeTest stringPath 18 | then {} 19 | else value) 20 | ciJobs); 21 | nonRequiredTest = stringPath: lib.any (p: p stringPath) nonRequiredPaths; 22 | in { 23 | required = releaseTools.aggregate { 24 | name = "required"; 25 | meta.description = "All jobs required to pass CI"; 26 | constituents = collectConstituents nonRequiredTest; 27 | }; 28 | nonrequired = releaseTools.aggregate { 29 | name = "nonrequired"; 30 | meta.description = "Nonrequired jobs that should not affect CI status"; 31 | constituents = collectConstituents (p: !nonRequiredTest p); 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /ci/cabal-project-regenerate/cabal-project-regenerate.py: -------------------------------------------------------------------------------- 1 | #!/usr/local/python3 2 | # 3 | # This script is intended to be run as 4 | # 5 | # python3 update-cabal-project.py 6 | # 7 | # And it will iterate over all git references in the cabal.project file 8 | # and add a --sha256 entry to them. This then allows us to build this 9 | # project with haskell.nix in a restricted nix setup where network access 10 | # is only permitted if the sha256 of the download is known beforehand. 11 | 12 | import re 13 | import subprocess 14 | import json 15 | from os import path 16 | 17 | globalCache = {} 18 | 19 | if not path.exists("cabal.project"): 20 | print("ERROR: No cabal.project exists in current directory") 21 | exit(1) 22 | 23 | # TODO: copy to temporary location and replace if no errors 24 | buffer = open("cabal.project").read() 25 | 26 | # match looks like this: 27 | 28 | # source-repository-package 29 | # type: git 30 | # location: https://github.com/input-output-hk/iohk-monitoring-framework 31 | # tag: d5eb7ee92f0974aed5ac4a57a9bf5697ec065b7d 32 | # subdir: iohk-monitoring 33 | 34 | # subdir is optional, so is a --sha256 comment 35 | 36 | pattern = r'source-repository-package.*\n' \ 37 | + r'(?P .*)type: git.*\n' \ 38 | + r'\1location: (?P[^ \n]+).*\n' \ 39 | + r'\1tag: (?P[^ \n]+).*\n' \ 40 | + r'(\1--sha256:.*\n){0,1}' \ 41 | + r'(?P\1subdir: [^ \n]+\n){0,1}' \ 42 | + r'(\1--sha256:.*\n){0,1}' 43 | # ( .*--sha256:.*\n){0,1}""" 44 | 45 | def repl(match): 46 | dict = match.groupdict() 47 | if not dict["subdir"]: 48 | dict["subdir"] = '' 49 | if not (dict['loc'], dict['tag']) in globalCache: 50 | prefetchJSON = subprocess.run( 51 | ["nix-prefetch-git", "--fetch-submodules", "--quiet", dict['loc'], dict['tag']], 52 | capture_output=True, check=True).stdout 53 | globalCache[(dict['loc'], dict['tag'])] = json.loads(prefetchJSON)["sha256"] 54 | sha256 = globalCache[(dict['loc'], dict['tag'])] 55 | return """source-repository-package 56 | {pad}type: git 57 | {pad}location: {loc} 58 | {pad}tag: {tag} 59 | {pad}--sha256: {sha256} 60 | {subdir}""".format(**{**dict, **{"sha256": sha256}}) 61 | 62 | f = open("cabal.project",'w') 63 | f.write(re.sub(pattern, repl, buffer, flags = re.I + re.M)) 64 | f.close() 65 | -------------------------------------------------------------------------------- /ci/cabal-project-regenerate/default.nix: -------------------------------------------------------------------------------- 1 | { stdenv 2 | , lib 3 | , runtimeShell 4 | , writeScript 5 | , runCommand 6 | , python3 7 | , python3Packages 8 | , coreutils 9 | , diffutils 10 | , nix-prefetch-git 11 | }: 12 | let 13 | python = python3; 14 | cabalProjectRegenerate = runCommand "cabal-project-regenerate" {} '' 15 | mkdir -p $out/bin 16 | cp ${./cabal-project-regenerate.py} $out/cabal-project-regenerate.py 17 | cat << EOF > $out/bin/cabal-project-regenerate 18 | PATH=$PATH:${nix-prefetch-git}/bin 19 | ${python}/bin/python $out/cabal-project-regenerate.py 20 | EOF 21 | chmod +x $out/bin/cabal-project-regenerate 22 | ''; 23 | checkDeps = [ 24 | coreutils 25 | diffutils 26 | cabalProjectRegenerate 27 | nix-prefetch-git 28 | ]; 29 | checkCabalProject = writeScript "check-cabal-project" '' 30 | #!${runtimeShell} 31 | PATH=${lib.makeBinPath checkDeps} 32 | set -euo pipefail 33 | cp ./cabal.project ./cabal.project.old 34 | cabal-project-regenerate 35 | set +e 36 | diff -u cabal.project.old cabal.project > cabal.project.diff 37 | if [ $? != 0 ] 38 | then 39 | echo "Changes required to cabal.project" 40 | cat cabal.project.diff 41 | exit 1 42 | else 43 | echo "No changes needed to cabal.project" 44 | exit 0 45 | fi 46 | ''; 47 | in { inherit cabalProjectRegenerate checkCabalProject; } 48 | -------------------------------------------------------------------------------- /ci/check-hydra.nix: -------------------------------------------------------------------------------- 1 | { substituteAll 2 | , jq 3 | , lib 4 | , coreutils 5 | , time 6 | , gnutar 7 | , gzip 8 | , fetchFromGitHub 9 | }: 10 | let 11 | rev = "0768891e3cd3ef067d28742098f1dea8462fca75"; 12 | hydra-src = fetchFromGitHub { 13 | inherit rev; 14 | owner = "input-output-hk"; 15 | repo = "hydra"; 16 | sha256 = "1aw3p7jm2gsakdqqx4pzhkfx12hh1nxk3wkabcvml5ci814f6jic"; 17 | }; 18 | hydra = (import "${hydra-src}/release.nix" { 19 | hydraSrc = { 20 | outPath = hydra-src; 21 | rev = builtins.substring 0 6 rev; 22 | revCount = 1234; 23 | }; 24 | }).build.x86_64-linux; 25 | check-hydra = substituteAll { 26 | src = ./check-hydra.sh; 27 | tools = lib.makeBinPath [ jq hydra coreutils time gnutar gzip ]; 28 | isExecutable = true; 29 | postInstall = '' 30 | patchShebangs $out 31 | ''; 32 | }; 33 | in check-hydra 34 | -------------------------------------------------------------------------------- /ci/check-hydra.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | export PATH=@tools@ 4 | 5 | if [ -z "$1" ]; then 6 | input=release.nix 7 | else 8 | input=$1 9 | shift 10 | fi 11 | 12 | echo '~~~ Evaluating '$input 13 | command time --format '%e' -o eval-time.txt hydra-eval-jobs \ 14 | --option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" \ 15 | -I . "$input" \ 16 | "$@" > eval.json 17 | EVAL_EXIT_CODE="$?" 18 | if [ "$EVAL_EXIT_CODE" != 0 ] 19 | then 20 | rm eval.json eval-time.txt 21 | echo -e "\\e[31;1mERROR: Failed to evaluate $input\\e[0m" 22 | exit 1 23 | fi 24 | EVAL_TIME=$(cat eval-time.txt) 25 | jq . < eval.json 26 | ERRORS=$(jq -r 'map_values(.error)|to_entries[]|select(.value)|@text "\(.key): \(.value)"' < eval.json) 27 | NUM_ERRORS=$(jq -r '[ map_values(.error)|to_entries[]|select(.value) ] |length' < eval.json) 28 | rm eval.json eval-time.txt 29 | 30 | if [ "$NUM_ERRORS" != 0 ] 31 | then 32 | echo -e "\\e[31;1mERROR: evaluation completed in $EVAL_TIME seconds with $NUM_ERRORS errors\\e[0m" 33 | echo "$ERRORS" 34 | exit 1 35 | else 36 | echo -e "\\e[32;1mOK: evaluation completed in $EVAL_TIME seconds with no errors\\e[0m" 37 | exit 0 38 | fi 39 | -------------------------------------------------------------------------------- /ci/check-source-repo-tags-on-master.nix: -------------------------------------------------------------------------------- 1 | { lib 2 | , runCommand 3 | }: 4 | let 5 | inherit (builtins) 6 | readDir readFile listToAttrs concatMap match head elemAt fetchGit 7 | ; 8 | inherit (lib) 9 | optional splitString nameValuePair foldr take drop hasPrefix 10 | ; 11 | 12 | rawCabalProject = origSrcDir: 13 | if ((readDir origSrcDir)."cabal.project" or "") == "regular" 14 | then readFile (origSrcDir + "/cabal.project") 15 | else null; 16 | 17 | parseBlockLines = blockLines: listToAttrs (concatMap (s: 18 | let pair = match " *([^:]*): *(.*)" s; 19 | in optional (pair != null) (nameValuePair 20 | (head pair) 21 | (elemAt pair 1))) blockLines); 22 | 23 | span = pred: list: 24 | let n = foldr (x: acc: if pred x then acc + 1 else 0) 0 list; 25 | in { fst = take n list; snd = drop n list; }; 26 | 27 | parseBlock = block: 28 | let 29 | x = span (hasPrefix " ") (splitString "\n" block); 30 | in 31 | parseBlockLines x.fst; 32 | 33 | parseRepos = projectFile: 34 | let 35 | blocks = splitString "\nsource-repository-package\n" projectFile; 36 | in 37 | map parseBlock (drop 1 blocks); 38 | 39 | fetchOnMaster = repo: 40 | fetchGit { 41 | url = repo.location; 42 | rev = repo.tag; 43 | ref = "master"; 44 | }; 45 | 46 | in 47 | { src }: 48 | let 49 | projectFile = rawCabalProject src; 50 | repos = parseRepos projectFile; 51 | in 52 | runCommand "check-tag-on-master-branch" 53 | (listToAttrs (map (r: 54 | nameValuePair "${r.location}" (fetchOnMaster r) 55 | ) repos)) 56 | '' 57 | mkdir -p $out 58 | '' 59 | -------------------------------------------------------------------------------- /ci/check-stack-project.nix: -------------------------------------------------------------------------------- 1 | # This is a a CI check script that runs after nix/regenerate.sh in the project 2 | # repository. If anything changes, then it uploads the patch to Buildkite. If 3 | # run on a PR branch, and there is a SSH key present, it will attempt to push 4 | # the changes back to the PR. 5 | 6 | { lib, runtimeShell, writeScript, coreutils, nixStable, git, gawk }: 7 | 8 | with lib; 9 | 10 | writeScript "check-stack-project.sh" '' 11 | #!${runtimeShell} 12 | 13 | set -euo pipefail 14 | 15 | export PATH="${makeBinPath [ runtimeShell coreutils nixStable git gawk ]}:$PATH" 16 | 17 | if [ -z "''${BUILDKITE:-}" ]; then 18 | # Go to top of project repo, unless running under CI. 19 | # If running under CI, assume the pipeline has set the correct directory. 20 | cd $(git rev-parse --show-toplevel) 21 | fi 22 | 23 | # The generated files will appear somewhere under ./nix 24 | git add -A nix 25 | 26 | # Check if there are changes staged for commit. 27 | if git diff-index --ignore-all-space --cached --quiet HEAD --; then 28 | echo "Generated Nix code is up-to-date." 29 | exit 0 30 | else 31 | echo "Committing changes..." 32 | commit_message="Regenerate nix" 33 | 34 | # If on a PR branch, search for a previous regen commit to fix up. 35 | commit_fixup="" 36 | if [ -n "''${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-}" ]; then 37 | git fetch -v origin $BUILDKITE_PULL_REQUEST_BASE_BRANCH 38 | commit_fixup=$(git log --pretty=oneline --no-decorate origin/$BUILDKITE_PULL_REQUEST_BASE_BRANCH..HEAD | awk "/$commit_message/ { print \$1; }") 39 | fi 40 | 41 | # Create the commit 42 | export GIT_COMMITTER_NAME="IOHK" 43 | export GIT_COMMITTER_EMAIL="devops+stack-project@iohk.io" 44 | export GIT_AUTHOR_NAME="$GIT_COMMITTER_NAME" 45 | export GIT_AUTHOR_EMAIL="$GIT_COMMITTER_EMAIL" 46 | if [ -n "$commit_fixup" ]; then 47 | git commit --no-gpg-sign --fixup "$commit_fixup" 48 | else 49 | git commit --no-gpg-sign --message "$commit_message" 50 | fi 51 | 52 | # If running in Buildkite... 53 | if [ -n "''${BUILDKITE_JOB_ID:-}" ]; then 54 | 55 | # Upload the patch as a Buildkite artifact 56 | patch="$BUILDKITE_PIPELINE_SLUG-nix-$BUILDKITE_BUILD_NUMBER.patch" 57 | git format-patch --stdout -1 HEAD > "$patch" 58 | buildkite-agent artifact upload "$patch" --job "$BUILDKITE_JOB_ID" 59 | 60 | echo 61 | echo "Error: The generated nix files are not up to date." 62 | echo 63 | echo "Now trying to push the updates back to the repo..." 64 | 65 | # Push the changes back to the pull request 66 | if [ -n "''${BUILDKITE_PULL_REQUEST_REPO:-}" ]; then 67 | sshkey="/run/keys/buildkite-$BUILDKITE_PIPELINE_SLUG-ssh-private" 68 | if [ -e $sshkey ]; then 69 | echo "Authenticating using SSH with $sshkey" 70 | export GIT_SSH_COMMAND="ssh -i $sshkey -F /dev/null" 71 | remote=$(echo $BUILDKITE_PULL_REQUEST_REPO | sed -e 's=^[a-z]*://github.com/=git@github.com:=') 72 | git push $remote HEAD:$BUILDKITE_BRANCH 73 | exit 0 74 | else 75 | echo "There is no SSH key at $sshkey" 76 | echo "The updates can't be pushed." 77 | echo 78 | echo "To add SSH keys, see: " 79 | echo "https://github.com/input-output-hk/ci-ops/blob/0a35ebc25df1ca9e764ddd4739be3eb965ecbe2d/modules/buildkite-agent-containers.nix#L225-L230" 80 | echo 81 | echo "Error: The generated nix files are not up to date." 82 | printf 'Apply the patch \033]1339;url=artifact://'$patch';content='$patch'\a from the build artifacts.\n' 83 | fi 84 | fi 85 | 86 | fi 87 | 88 | exit 1 89 | fi 90 | '' 91 | -------------------------------------------------------------------------------- /ci/hydra-eval-errors/bin/hydra-eval-errors.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import requests 3 | import os 4 | from time import sleep 5 | import json 6 | 7 | class ApiNotFoundError(Exception): 8 | pass 9 | 10 | class HydraEvalMonitor: 11 | def __init__(self, repo, job, hydra_url="https://hydra.iohk.io", jobset="Cardano"): 12 | self.hydraUrl = hydra_url 13 | self.repo = repo 14 | self.jobset = jobset 15 | self.jobPath = None 16 | self.evalId = None 17 | self.eval = None 18 | self.jobName = job 19 | self.job = self.getJob(job) 20 | print(f"Jobset found: \033]1339;url='{self.hydraUrl}/{self.jobPath}'\a\n") 21 | 22 | def getApi(self, path): 23 | hydra_result = requests.get(f"{self.hydraUrl}/{path}", headers={"Content-Type": "application/json"}) 24 | if hydra_result.status_code == 200: 25 | return json.loads(hydra_result.text) 26 | else: 27 | raise ApiNotFoundError(f"Failed to find result for {path}") 28 | 29 | def getJob(self, job, retries=60, retry_time=60): 30 | print(f"Attempting to find hydra job {job}") 31 | retry_count = 0 32 | self.jobPath = f"jobset/{self.jobset}/{job}" 33 | while retry_count < retries: 34 | try: 35 | job = self.getApi(self.jobPath) 36 | return job 37 | except ApiNotFoundError as e: 38 | if retry_count < retries: 39 | retry_count = retry_count + 1 40 | print(f"Hydra job not created yet - sleeping {retry_time} seconds") 41 | sleep(retry_time) 42 | else: 43 | raise e 44 | 45 | def loadEvalByCommit(self, commit, retries=60, retry_time=60): 46 | print(f"Attempting to find eval for commit: {commit}") 47 | retry_count = 0 48 | found = False 49 | while not found and retry_count < retries: 50 | try: 51 | hydra_evals = self.getApi(f"{self.jobPath}/evals") 52 | for hydra_eval in hydra_evals["evals"]: 53 | if hydra_eval["jobsetevalinputs"][self.repo]["revision"] == commit: 54 | found = True 55 | self.evalId = hydra_eval["id"] 56 | self.eval = self.getApi(f"eval/{self.evalId}") 57 | if not found: 58 | raise ApiNotFoundError(f"Eval not created") 59 | except ApiNotFoundError as e: 60 | print(f"Hydra eval not created yet for {commit} - sleeping {retry_time} seconds") 61 | retry_count = retry_count + 1 62 | sleep(retry_time) 63 | if retry_count == retries: 64 | print("Retried 1 hour - exiting") 65 | errormsg = self.job["errormsg"] 66 | print("Errors below may be incomplete") 67 | print(f"An error occurred in evaluation:\n{errormsg}") 68 | raise e 69 | 70 | def getBuild(self, build_id): 71 | pass 72 | 73 | def checkRequiredExists(self): 74 | for build in self.eval["builds"]: 75 | hydra_build = self.getApi(f"build/{build}") 76 | if hydra_build["job"] == "required": 77 | return True 78 | return False 79 | 80 | def getErrors(self): 81 | try: 82 | return self.job["errormsg"] 83 | except Exception as e: 84 | print("An error occurred with loading eval") 85 | raise e 86 | 87 | 88 | def main(): 89 | BUILDKITE_BRANCH = os.getenv("BUILDKITE_BRANCH", None) 90 | BUILDKITE_COMMIT = os.getenv("BUILDKITE_COMMIT", None) 91 | BUILDKITE_PR = os.getenv("BUILDKITE_PULL_REQUEST", None) 92 | BUILDKITE_REPO = os.getenv("BUILDKITE_PIPELINE_NAME", None) 93 | 94 | if BUILDKITE_REPO == "iohk-monitoring-framework": 95 | BUILDKITE_REPO = "iohk-monitoring" 96 | 97 | if BUILDKITE_BRANCH == "bors/staging": 98 | job = f"{BUILDKITE_REPO}-bors-staging" 99 | elif BUILDKITE_BRANCH == "bors/trying": 100 | job = f"{BUILDKITE_REPO}-bors-trying" 101 | elif BUILDKITE_BRANCH == "master": 102 | job = f"{BUILDKITE_REPO}" 103 | elif BUILDKITE_BRANCH == "develop": 104 | job = f"{BUILDKITE_REPO}" 105 | elif BUILDKITE_PR == "false": 106 | print("Please open a PR for hydra to evaluate") 107 | raise BaseException 108 | else: 109 | job = f"{BUILDKITE_REPO}-pr-{BUILDKITE_PR}" 110 | print(f"PR: {BUILDKITE_PR}") 111 | hydraEvalMonitor = HydraEvalMonitor(job=job,repo=BUILDKITE_REPO) 112 | hydraEvalMonitor.loadEvalByCommit(BUILDKITE_COMMIT) 113 | errors = hydraEvalMonitor.getErrors() 114 | if hydraEvalMonitor.checkRequiredExists(): 115 | print(f"A required jobset was found. Eval errors are ignored:\n{errors}") 116 | else: 117 | print(f"No required jobset was found. check eval errors below:\n{errors}") 118 | raise BaseException 119 | 120 | main() 121 | -------------------------------------------------------------------------------- /ci/hydra-eval-errors/default.nix: -------------------------------------------------------------------------------- 1 | { python3Packages }: 2 | 3 | python3Packages.buildPythonApplication rec { 4 | pname = "hydra-eval-errors"; 5 | version = "0.0.0"; 6 | 7 | src = ./.; 8 | propagatedBuildInputs = [ python3Packages.requests ]; 9 | } 10 | -------------------------------------------------------------------------------- /ci/hydra-eval-errors/setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | 3 | setuptools.setup( 4 | name="hydra-eval-errors", 5 | version="0.0.0", 6 | author="Samuel Leathers", 7 | author_email="samuel.leathers@iohk.io", 8 | description="hydra-eval-errors", 9 | long_description="hydra-eval-errors", 10 | url="https://github.com/input-output-hk/iohk-nix", 11 | packages=setuptools.find_packages(), 12 | scripts=['bin/hydra-eval-errors.py'], 13 | #entry_points={ 14 | # "console_scripts": [ 15 | # "hydra-eval-errors = hydra-eval-errors.script:main", 16 | # ] 17 | #}, 18 | classifiers=[ 19 | "Programming Language :: Python :: 3", 20 | "License :: OSI Approved :: Apache License", 21 | "Operating System :: OS Independent", 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /ci/sha256map-regenerate/default.nix: -------------------------------------------------------------------------------- 1 | { stdenv 2 | , lib 3 | , python3 4 | , git 5 | , nix-prefetch-git 6 | }: 7 | stdenv.mkDerivation { 8 | name = "sha256map-regenerate"; 9 | src = ./sha256map-regenerate.py; 10 | dontUnpack = true; 11 | dontConfigure = true; 12 | dontBuild = true; 13 | installPhase = '' 14 | bin="$out/bin/$name" 15 | mkdir -p $out/bin 16 | sed \ 17 | -e '1c #!${python3}/bin/python' \ 18 | -e '2i import os; os.environ["PATH"] += os.pathsep + os.pathsep.join([${lib.concatMapStringsSep ", " (p: "\"${p}/bin\"") [ git nix-prefetch-git ]}])' \ 19 | < "$src" \ 20 | > "$bin" 21 | chmod 755 "$bin" 22 | patchShebangs "$bin" 23 | ''; 24 | } 25 | -------------------------------------------------------------------------------- /ci/sha256map-regenerate/sha256map-regenerate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # This script is intended to be run as 4 | # 5 | # python3 sha256map-regenerate.py 6 | # 7 | # And it will iterate over all git references in the stack.yaml file 8 | # (TODO: or cabal.project) and generate a set of sha256 value for them 9 | # in the nix/sha256map.nix file, that can then be imported as such: 10 | # haskell-nix.stackProject' { sha256map = import ./sha256map.nix; } 11 | # This then allows us to build this project with haskell.nix in a 12 | # restricted nix setup where network access is only permitted if the 13 | # sha256 of the download is known beforehand. 14 | 15 | import re 16 | import subprocess 17 | import json 18 | import sys 19 | 20 | # Read stack.yaml from stin 21 | project = sys.stdin.read() 22 | 23 | # match looks like this: 24 | 25 | #- git: https://github.com/input-output-hk/cardano-base 26 | # commit: e8a48cf0500b03c744c7fc6f2fedb86e8bdbe055 27 | 28 | pattern = r'\- git: (?P[^ \n]+).*\n' \ 29 | + r'(?P .*)commit: (?P[^ \n]+).*\n' 30 | 31 | def sha256entry(match): 32 | dict = match.groupdict() 33 | prefetchJSON = subprocess.run( 34 | ["nix-prefetch-git", "--fetch-submodules", "--quiet", dict['loc'], dict['tag']], 35 | capture_output=True, check=True).stdout 36 | sha256 = json.loads(prefetchJSON)["sha256"] 37 | return '"{loc}"."{tag}" = "{sha256}";'.format(**{**dict, **{"sha256": sha256}}) 38 | 39 | # Write sha256map to stdout 40 | print("{") 41 | for x in sorted([sha256entry(match) for match in re.finditer(pattern, project)]): 42 | print(" ", x) 43 | print("}") 44 | -------------------------------------------------------------------------------- /default.nix: -------------------------------------------------------------------------------- 1 | { config ? {} 2 | , system ? builtins.currentSystem 3 | , crossSystem ? null 4 | , sourcesOverride ? {} 5 | # Set application for getting a specific application nixkgs-src.json 6 | , application ? "" 7 | # Override nixpkgs-src.json to a file in your repo 8 | , nixpkgsOverride ? "" 9 | , nixpkgsJsonOverride ? "" 10 | # Modify nixpkgs with overlays 11 | , nixpkgsOverlays ? [] 12 | , defaultSources ? import ./nix/sources.nix { pkgs = pkgsDefault; } 13 | , pkgsDefault ? import defaultSources.nixpkgs { inherit config system crossSystem; } 14 | }: 15 | 16 | let 17 | upstreamedDeprecation = p: builtins.trace "WARNING: commonLib.${p} is deprecated. Please use it from nixpkgs directly instead."; 18 | sources = defaultSources // sourcesOverride; 19 | 20 | commonLib = rec { 21 | fetchNixpkgs = throw "Please use niv to pin nixpkgs instead."; 22 | # Equivalent of but pinned instead of system 23 | inherit (sources) nixpkgs; 24 | inherit pkgsDefault; 25 | getPkgs = let 26 | system' = system; 27 | config' = config; 28 | crossSystem' = crossSystem; 29 | in { args ? {} 30 | , extraOverlays ? nixpkgsOverlays 31 | , system ? system' 32 | , config ? config' 33 | , crossSystem ? crossSystem' }: import nixpkgs ({ 34 | config = config; 35 | overlays = extraOverlays; 36 | inherit system crossSystem; 37 | } // args); 38 | getPkgsDefault = let 39 | system' = system; 40 | config' = config; 41 | crossSystem' = crossSystem; 42 | in { args ? {} 43 | , system ? system' 44 | , config ? config' 45 | , crossSystem ? crossSystem' }: import nixpkgs ({ 46 | inherit system crossSystem config; 47 | } // args); 48 | pkgs = getPkgs {}; 49 | getPackages = pkgs.callPackage ./get-packages.nix {}; 50 | maybeEnv = import ./maybe-env.nix; 51 | 52 | commitIdFromGitRepo = upstreamedDeprecation "commitIdFromGitRepo" pkgs.lib.commitIdFromGitRepo; 53 | # A variant of lib.commitIdFromGitRepo which provides a default rev, instead of 54 | # throwing an exception in cases of error. 55 | # Example usage: commitIdFromGitRepoOrZero ./.git 56 | commitIdFromGitRepoOrZero = path: 57 | let 58 | zero = "0000000000000000000000000000000000000000"; 59 | res = builtins.tryEval (pkgs.lib.commitIdFromGitRepo path); 60 | in 61 | if builtins.pathExists path 62 | then (if res.success then res.value else zero) 63 | else zero; 64 | 65 | # Development tools 66 | inherit (haskell-nix-extra-packages) stack-hpc-coveralls hpc-coveralls; 67 | hlint = upstreamedDeprecation "hlint" pkgsDefault.hlint; 68 | openapi-spec-validator = upstreamedDeprecation "openapi-spec-validator" pkgsDefault.python3Packages.openapi-spec-validator; 69 | inherit (import sources.cardano-repo-tool {inherit system;}) cardano-repo-tool; 70 | stack-cabal-sync-shell = pkgsDefault.callPackage ./pkgs/stack-cabal-sync-shell.nix { inherit cardano-repo-tool; }; 71 | supervisord = pkgsDefault.callPackage ./supervisord {}; 72 | fixStylishHaskell = pkgsDefault.callPackage ./tests/fix-stylish-haskell.nix {}; 73 | 74 | # Check scripts 75 | check-hydra = builtins.trace "check-hydra is deprecated. Please use hydraEvalErrors" pkgsDefault.callPackage ./ci/check-hydra.nix {}; 76 | checkStackProject = pkgsDefault.callPackage ./ci/check-stack-project.nix {}; 77 | hydraEvalErrors = pkgsDefault.callPackage ./ci/hydra-eval-errors {}; 78 | checkRepoTagsOnMasterBranches = pkgsDefault.callPackage ./ci/check-source-repo-tags-on-master.nix {}; 79 | inherit (pkgsDefault.callPackage ./ci/cabal-project-regenerate {}) cabalProjectRegenerate checkCabalProject; 80 | }; 81 | 82 | 83 | cardanoLib = commonLib.pkgsDefault.callPackage ./cardano-lib {}; 84 | jormungandrLib = commonLib.pkgsDefault.callPackage ./jormungandr-lib { inherit rust-packages; }; 85 | 86 | tests = { 87 | hlint = ./tests/hlint.nix; 88 | shellcheck = ./tests/shellcheck.nix; 89 | stylish-haskell = ./tests/stylish-haskell.nix; 90 | }; 91 | 92 | overlays = { 93 | rust-packages = rust-packages.overlays; 94 | haskell-nix-extra = [(import ./overlays/haskell-nix-extra)]; 95 | crypto = [(import ./overlays/crypto)]; 96 | iohkNix = [(pkgs: super: { 97 | iohkNix = import ./. { 98 | inherit (pkgs) config system; 99 | pkgsDefault = pkgs; 100 | }; 101 | iohk-nix.lib = import ./lib pkgs.lib; 102 | })]; 103 | utils = [(import ./overlays/utils)]; 104 | }; 105 | 106 | rust-packages = rec { 107 | overlays = [ 108 | (commonLib.pkgsDefault.callPackage ./overlays/rust/mozilla.nix {}) 109 | (import ./overlays/rust) 110 | ]; 111 | pkgs = import sources."nixpkgs-19.09" { 112 | inherit overlays config system crossSystem; 113 | }; 114 | }; 115 | 116 | # This attribute is here for iohk-nix/release.nix Hydra builds. 117 | # Projects should generally use the haskell-nix-extra overlay directly. 118 | haskell-nix-extra-packages = let 119 | baseOverlays = overlays; 120 | baseConfig = config; 121 | haskellNix = (import defaultSources."haskell.nix" { 122 | inherit system sourcesOverride; 123 | }).nixpkgsArgs; 124 | in rec { 125 | overlays = haskellNix.overlays ++ baseOverlays.haskell-nix-extra; 126 | config = haskellNix.config // baseConfig; 127 | pkgs = import defaultSources.nixpkgs { 128 | inherit overlays config system crossSystem; 129 | }; 130 | inherit (pkgs) stackNixRegenerate haskellBuildUtils; 131 | } // pkgsDefault.lib.genAttrs 132 | [ "stack-hpc-coveralls" "hpc-coveralls" ] 133 | (pkg: throw "ERROR: iohk-nix `haskell-nix-extra-packages.${pkg}` has been removed."); 134 | 135 | shell = import ./shell.nix; 136 | 137 | self = { 138 | inherit 139 | overlays 140 | sources 141 | shell 142 | tests 143 | rust-packages 144 | haskell-nix-extra-packages 145 | cardanoLib 146 | jormungandrLib; 147 | 148 | inherit (pkgsDefault) 149 | niv; 150 | 151 | inherit (commonLib) 152 | # Package sets 153 | nixpkgs 154 | pkgs 155 | pkgsDefault 156 | 157 | # Library functions 158 | fetchNixpkgs 159 | getPkgs 160 | getPkgsDefault 161 | getPackages 162 | maybeEnv 163 | commitIdFromGitRepo 164 | commitIdFromGitRepoOrZero 165 | cabalProjectRegenerate 166 | supervisord 167 | 168 | # Packages 169 | stack-hpc-coveralls 170 | hpc-coveralls 171 | hlint 172 | stylish-haskell 173 | openapi-spec-validator 174 | cardano-repo-tool 175 | stack-cabal-sync-shell 176 | 177 | # Scripts 178 | check-hydra 179 | checkCabalProject 180 | hydraEvalErrors 181 | checkRepoTagsOnMasterBranches 182 | checkStackProject 183 | fixStylishHaskell; 184 | release-lib = ./lib/release-lib.nix; 185 | }; 186 | in self 187 | -------------------------------------------------------------------------------- /fetch-tarball-with-override.nix: -------------------------------------------------------------------------------- 1 | # overriding logic so we can pass -I to nix, and overide the 2 | # relevant import. That is if we want to override for example 3 | # `custom_nixpkgs` or `hackage`, we can simply provide -I hackage=/path/to/hackage.nix 4 | # and have nix use that instead of the one we reference here. 5 | # Same for haskell and stackage. 6 | override: srcJson: 7 | let 8 | try = builtins.tryEval (builtins.findFile builtins.nixPath override); 9 | in if try.success then 10 | builtins.trace "using search host <${override}>" try.value 11 | else 12 | let 13 | spec = builtins.fromJSON (builtins.readFile srcJson); 14 | in builtins.fetchTarball { 15 | url = "${spec.url}/archive/${spec.rev}.tar.gz"; 16 | inherit (spec) sha256; 17 | } 18 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "blst": { 4 | "flake": false, 5 | "locked": { 6 | "lastModified": 1739372843, 7 | "narHash": "sha256-IlbNMLBjs/dvGogcdbWQIL+3qwy7EXJbIDpo4xBd4bY=", 8 | "owner": "supranational", 9 | "repo": "blst", 10 | "rev": "8c7db7fe8d2ce6e76dc398ebd4d475c0ec564355", 11 | "type": "github" 12 | }, 13 | "original": { 14 | "owner": "supranational", 15 | "ref": "v0.3.14", 16 | "repo": "blst", 17 | "type": "github" 18 | } 19 | }, 20 | "nixpkgs": { 21 | "locked": { 22 | "lastModified": 1684171562, 23 | "narHash": "sha256-BMUWjVWAUdyMWKk0ATMC9H0Bv4qAV/TXwwPUvTiC5IQ=", 24 | "owner": "nixos", 25 | "repo": "nixpkgs", 26 | "rev": "55af203d468a6f5032a519cba4f41acf5a74b638", 27 | "type": "github" 28 | }, 29 | "original": { 30 | "owner": "nixos", 31 | "ref": "release-22.11", 32 | "repo": "nixpkgs", 33 | "type": "github" 34 | } 35 | }, 36 | "root": { 37 | "inputs": { 38 | "blst": "blst", 39 | "nixpkgs": "nixpkgs", 40 | "secp256k1": "secp256k1", 41 | "sodium": "sodium" 42 | } 43 | }, 44 | "secp256k1": { 45 | "flake": false, 46 | "locked": { 47 | "lastModified": 1683999695, 48 | "narHash": "sha256-9nJJVENMXjXEJZzw8DHzin1DkFkF8h9m/c6PuM7Uk4s=", 49 | "owner": "bitcoin-core", 50 | "repo": "secp256k1", 51 | "rev": "acf5c55ae6a94e5ca847e07def40427547876101", 52 | "type": "github" 53 | }, 54 | "original": { 55 | "owner": "bitcoin-core", 56 | "ref": "v0.3.2", 57 | "repo": "secp256k1", 58 | "type": "github" 59 | } 60 | }, 61 | "sodium": { 62 | "flake": false, 63 | "locked": { 64 | "lastModified": 1675156279, 65 | "narHash": "sha256-0uRcN5gvMwO7MCXVYnoqG/OmeBFi8qRVnDWJLnBb9+Y=", 66 | "owner": "input-output-hk", 67 | "repo": "libsodium", 68 | "rev": "dbb48cce5429cb6585c9034f002568964f1ce567", 69 | "type": "github" 70 | }, 71 | "original": { 72 | "owner": "input-output-hk", 73 | "repo": "libsodium", 74 | "rev": "dbb48cce5429cb6585c9034f002568964f1ce567", 75 | "type": "github" 76 | } 77 | } 78 | }, 79 | "root": "root", 80 | "version": 7 81 | } 82 | -------------------------------------------------------------------------------- /jormungandr-lib/calculate_hashes.nix: -------------------------------------------------------------------------------- 1 | { version, sha256, cargoSha256 }@args: 2 | let 3 | inherit (import ../. { }) jormungandrLib; 4 | inherit (jormungandrLib) makeJcli; 5 | common = f: f (makeJcli args); 6 | in { 7 | src = (makeJcli args).src; 8 | cargoDeps = (makeJcli args).cargoDeps; 9 | } 10 | -------------------------------------------------------------------------------- /jormungandr-lib/genesis-beta.yaml: -------------------------------------------------------------------------------- 1 | { 2 | "blockchain_configuration": { 3 | "block0_date": 1573743671, 4 | "slot_duration": 2, 5 | "slots_per_epoch": 7200, 6 | "linear_fees": { 7 | "coefficient": 50, 8 | "certificate": 10000, 9 | "constant": 1000 10 | }, 11 | "consensus_leader_ids": [ 12 | "ed25519_pk1yp27asjmj5t03jh0vg4wreak6t07x506t8q6wjzj5pzxd79pgtrs6uqdf3", 13 | "ed25519_pk1vxucp4sdclzjk0djw8png65zyng7svhkzdsltwukh97a0r3vdgcqay79e2" 14 | ], 15 | "max_number_of_transactions_per_block": 255, 16 | "kes_update_speed": 86400, 17 | "consensus_genesis_praos_active_slot_coeff": 0.1, 18 | "bft_slots_ratio": 0, 19 | "block0_consensus": "genesis_praos", 20 | "discrimination": "test", 21 | "epoch_stability_depth": 10 22 | }, 23 | "initial": [ 24 | { 25 | "fund": [ 26 | { 27 | "value": 10000000000000, 28 | "address": "ca1s59x75zsqdp333ea82g8czapn2p25gwng3lj08npapkhxz4kk4gt62d2p2t" 29 | }, 30 | { 31 | "value": 10000000000000, 32 | "address": "ca1skqrzpahwj35wsdq5kesajfceajv4eap2k54w3499xrczg7pk7vu6yhe3cr" 33 | }, 34 | { 35 | "value": 10000000000000, 36 | "address": "ca1sh4n33twz24prp28e425ccmrffdf7cl69nh04yfqqyrsxw2h3zv3sk0lwul" 37 | }, 38 | { 39 | "value": 10000000000000, 40 | "address": "ca1s4s0yjaj400l27mj3pgth2nkupxwvhtswadxtsfrgt4meyxxwxxkcmkknwe" 41 | }, 42 | { 43 | "value": 10000000000000, 44 | "address": "ca1s48gpwslmxz8m86628lv9jztkqc38kf0ddusf9kfs3khvsy4syyec4cmqul" 45 | }, 46 | { 47 | "value": 10000000000000, 48 | "address": "ca1s4aym4603ahkar7a6efewvhql7feul44r9dj65dll9958m0zk9jn5eufhgw" 49 | }, 50 | { 51 | "value": 10000000000000, 52 | "address": "ca1s55yxjppct84czhnjxqxxr6d9aurtjd5nwchm6x48merz4ykamj66jnqrtq" 53 | } 54 | ] 55 | }, 56 | { 57 | "legacy_fund": [ 58 | { 59 | "value": 100000000000, 60 | "address": "DdzFFzCqrhtCWeg6PywoAR8wrza9DawkU2KgQddh7oi43LZy1kbZgZYK2hakgtXZu8Q7ptnhFjgV3ZgRgSypFhwtK9paG3ui17PiVUmB" 61 | }, 62 | { 63 | "value": 100000000000, 64 | "address": "DdzFFzCqrht1zDLWxw9hLEgzKogvkGH3KNNTCjADNreP8FTczsxMd7VG1k4qRHezZNQhgx6fHUa1NA54acajnENFymHxcEZrvgjG1p23" 65 | } 66 | ] 67 | }, 68 | { 69 | "cert": "signedcert1qvqqqqqqqqqqqqqqqqqqq0p5avfqqqqqqqqqqqqqqqqqqqqqqqqqr8r60xxpa29qsnk3gevljuwtr2s7q2z3jcm26ufjt8n5407e6jeekjghgeg9g4dv5g2pehkfxvxmuagwggct8d33cgat2dkjywa885pszzn02pgqxscccu7n4yrupwse4q42y8f5gle8nes7smtnp2mt259aqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqpqz3nq07fxg9q9lvpmh4uj5hqeel4pg2llkxv3e2x8zg4kz4gcxuhusfdxu83lr3vdxvs46eu0vh243p9qgkpxrex7v3z93khrvfeq5g0lc3u5j" 70 | }, 71 | { 72 | "cert": "signedcert1qvqqqqqqqqqqqqqqqqqqq0p5avfqqqqqqqqqqqqqqqqqqqqqqqqqresf8656vn4cuaq705f466z99gctlpm6zy2dvlw4fjw9fm4uedr9arhmym2zeym9t3pnwd5vflkcn7mmfvypwyxm0x36j0h598shmt9qrqp3q7mhfg68gxs2tvcweyuv7ex2u7s4t22hg6jjnpupy0qm0xwdqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqpqztwxgpm7nanwaqllcevywx9zas08kgyp6rcgtakh4d65qwn04nrh46cdhrujc9hcsn5s2aqcyzzezv0qv4u70qwse5xhpn4ytq0uystn4cmqf" 73 | }, 74 | { 75 | "cert": "signedcert1qvqqqqqqqqqqqqqqqqqqq0p5avfqqqqqqqqqqqqqqqqqqqqqqqqqzc3vfzra9n7xeftl77lreaqkfkkfhuygz4hxps205urhdl06p029x623740txq7rskrr3q28020ywdpxj8stzxc4k58gdzamrhgd0azsr6ecc4hp92s3s4ru642vvd355k5lv0azemh6jysqzpcr89tc3xgcqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqpqqefn2unw3ymawt83865alm4na2d4k2nlkxuskjf8v0859rgpxs83ql7jpr9js78wxuawgnl2ptvq0uhjggdjw0wygqf9lgq53mdusqxayhqxh" 76 | }, 77 | { 78 | "cert": "signedcert1qvqqqqqqqqqqqqqqqqqqq0p5avfqqqqqqqqqqqqqqqqqqqqqqqqqzl8gd5cp5rg9j9se3evhrkltsd926z2crpkhkqdw29r7auvg0xmx5uuax4fqgagaqzx3ls6c7u0sughq2mdz4wfuaw84v2gavjzepu0qzc8jfwe2hhl40degs59m4fmwqn8xt4c8wkn9cy3596aujrr8rrtvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqpqp2eyayzdsph65638axxmujpade85uu52xvv9ygkhzagczxsaedxa0vvumde6rjun6cv2nt2n3d7elknnrdcuuykep5g0mk9chthd8gxr40m25" 79 | }, 80 | { 81 | "cert": "signedcert1qvqqqqqqqqqqqqqqqqqqq0p5avfqqqqqqqqqqqqqqqqqqqqqqqqqrsqg5s8cfrzyqtm6egvzyxhf6mdmpypz2crfwx22shnvurpkdjm2th6lh5qevc6aksllccmxu3t89nc9zq06vqse75umeh4zd00qcraqzn5qhg0anpranad9rlkzep9mqvgnmyhkk7gyjmycgmtkgz2czzvuqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqpqqanvcsyz04klsq908kjkmd3exnvqd69xfs3renyryrl2wj6lp3ygv7dknq5x45aeze5xma9qka5pvdu7psf02kdwedct0jhpncwavc0693ap5" 82 | }, 83 | { 84 | "cert": "signedcert1qvqqqqqqqqqqqqqqqqqqq0p5avfqqqqqqqqqqqqqqqqqqqqqqqqqrg4uvnjnfjvepsrf38qnj5dqalrtd963ahel4jmrundy0t7jgk6j4e5qv4l8d7jwa9g77nufy3amm98y0z348hqttxne7ysztdxchv6sz7jd6a8c7mmw3lwav5uhxts0lyu70663jked2xlljj6rah3tzef6qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqpqzr89rmaa6xy0ez0nhy4gqeqezjmt0ccyjjmj0wam8zjh048hhn8gg8cj7rwtm6f27sghu0emwqyn7r38wd8ne9wj8avf3x8tqvyx5cgzdcw24" 85 | }, 86 | { 87 | "cert": "signedcert1qvqqqqqqqqqqqqqqqqqqq0p5avfqqqqqqqqqqqqqqqqqqqqqqqqqrcxclu0nzfh7tv8pqlsnhyyrzggx6qn2zxsmecy8smemzhns2jgp6ns8s26v7zqdh9mc0t4czjeeepq0znfakzzwyfrjdwxuz4hqz76sz2zrfqsu9n6upteerqrrpaxj77p4ex6fhvtaar2nau332jtwaeddqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqpqqqanqx6lmtg7lfndvuzrp29sgw62xmtw9zrrcvmlm36x3ml5y6xwju5s8xf2y8pg8rtax6epfcs8q0yj43xxhs66hxyqew4c4nq43s932zkfg" 88 | }, 89 | { 90 | "cert": "signedcert1qy9x75zsqdp333ea82g8czapn2p25gwng3lj08npapkhxz4kk4gt6q07pjnzytwkta8l7vrd84uw4xqws6vz7jy47vt5n3ftsslufr8jscqmqncg7t940st9fjxml2ql57hz33yn7e85zp6jf9t0vf8wl7gwz960l4sus0j0rf9d5vhjhcy6m4x22wr763fk2ynmq3ncm9cz9hprqyzjula8" 91 | }, 92 | { 93 | "cert": "signedcert1qxqrzpahwj35wsdq5kesajfceajv4eap2k54w3499xrczg7pk7vu6q09f9dafxpxnyng3wnzpqcsdp3axlqjyym9wwq6dt920z4quj7z3vqapa0lejqjcf80zfn72wrp84c30z009nllwq269gj02hcp28zpspt87v3jpawu2s5gggu88vwf536wtdke07r74zz6v3dfj9tm0u67pu3qz2lk" 94 | }, 95 | { 96 | "cert": "signedcert1q84n33twz24prp28e425ccmrffdf7cl69nh04yfqqyrsxw2h3zv3sqv60hhtcz8lp0jzc790574v4kceccs6cpvj4c7py39hq83h4gwt7sqndrmqeq5jw5ex2fkrchv58tvljt5ljepkejmg7e6vaqw8yrcd3evtjwd8yv62r8h6kdn8tz9chns8pdrz3hj8ruf7xtxaa6kt35p8pse8scsf" 97 | }, 98 | { 99 | "cert": "signedcert1q9s0yjaj400l27mj3pgth2nkupxwvhtswadxtsfrgt4meyxxwxxkcqvvgy4fxk8e5fkqrlmgutjk8mpg8u2cdq3270sh3e2d6p9m4yls3yqhul0yqxqrksx9ma08m386ta7f2fsttvj4rhljhyqk96suua6wdl66enup8n6hn5e9qrfumgr03k6sdd660sy8cdd94zs9w0jp8weeq5uzcyrl" 100 | }, 101 | { 102 | "cert": "signedcert1q98gpwslmxz8m86628lv9jztkqc38kf0ddusf9kfs3khvsy4syyecq2fsm68w3qernzn792rq70jeraqeakpl6p56qvtnddh3qdcdgf85gq4yemm6kd8qutwtrswt007tm6ep4a84f5f55kxcllzvq0gahqweke4lqj9z0m4vr0gk5evkjyyru5ua55e23s4h63qyyqrrkp2wcccqszkzmqy" 103 | }, 104 | { 105 | "cert": "signedcert1q9aym4603ahkar7a6efewvhql7feul44r9dj65dll9958m0zk9jn5qwskylvff3ewt9t49yw9cttr3l04rh7ewv2mwdgkxzdu08uzmqxquqehjh270lvd3jpwdvvj8e5v93xg2v2vv2g8vsa344c6wdq57zpezjsj0zrpe32pen5lmw8qyht5klnveg952utfdeupvrhsurrn9zvpqs6mcy6" 106 | }, 107 | { 108 | "cert": "signedcert1qy5yxjppct84czhnjxqxxr6d9aurtjd5nwchm6x48merz4ykamj66qwtge83cpw0lwrq42559jdz996sn55n3tpuvk7wwdh5jeskvlwgzuq32ern6fjq6ekhynhnqmqp8042jv2jxkxyx7eg83atanp6tlraredust3sqevl485ajn7wqxhw3t6j3uvh8rpaz8elyrgth3q3dql2pg9w3uke" 109 | } 110 | ] 111 | } 112 | -------------------------------------------------------------------------------- /jormungandr-lib/genesis-itn_rewards_v1.yaml: -------------------------------------------------------------------------------- 1 | { 2 | "blockchain_configuration": { 3 | "reward_parameters": { 4 | "linear": { 5 | "epoch_rate": 1, 6 | "epoch_start": 1, 7 | "ratio": "0/1", 8 | "constant": 3835616440000 9 | } 10 | }, 11 | "treasury_parameters": { 12 | "ratio": "1/10", 13 | "fixed": 0 14 | }, 15 | "block0_date": 1576264417, 16 | "slot_duration": 2, 17 | "block_content_max_size": 1024000, 18 | "fees_go_to": "treasury", 19 | "slots_per_epoch": 43200, 20 | "treasury": 0, 21 | "linear_fees": { 22 | "per_certificate_fees": { 23 | "certificate_pool_registration": 500000000, 24 | "certificate_stake_delegation": 400000, 25 | "certificate_owner_stake_delegation": null 26 | }, 27 | "coefficient": 100000, 28 | "certificate": 10000, 29 | "constant": 200000 30 | }, 31 | "consensus_leader_ids": [ 32 | "ed25519_pk14ya2jjezjpg3wed96f94le5gmd4xtv0a3j63kqd5thar5cjk4k6qckq07z", 33 | "ed25519_pk1pzth90w8aqx5e4885hfq6sm44mqh537zs0guwnu6gsr7jvq85ngsp674y8" 34 | ], 35 | "kes_update_speed": 86400, 36 | "consensus_genesis_praos_active_slot_coeff": 0.1, 37 | "total_reward_supply": 701917808520000, 38 | "reward_constraints": { 39 | "pool_participation_capping": { 40 | "max": 100, 41 | "min": 100 42 | }, 43 | "reward_drawing_limit_max": "4109589/10000000000" 44 | }, 45 | "block0_consensus": "genesis_praos", 46 | "discrimination": "test", 47 | "epoch_stability_depth": 10 48 | }, 49 | "initial": [] 50 | } -------------------------------------------------------------------------------- /jormungandr-lib/genesis-qa.yaml: -------------------------------------------------------------------------------- 1 | { 2 | "blockchain_configuration": { 3 | "reward_parameters": { 4 | "linear": { 5 | "epoch_rate": 1, 6 | "epoch_start": 1, 7 | "ratio": "0/1", 8 | "constant": 3835616440000 9 | } 10 | }, 11 | "treasury_parameters": { 12 | "ratio": "1/10", 13 | "fixed": 0 14 | }, 15 | "block0_date": 1576234895, 16 | "slot_duration": 2, 17 | "block_content_max_size": 1024000, 18 | "fees_go_to": "treasury", 19 | "slots_per_epoch": 750, 20 | "treasury": 0, 21 | "linear_fees": { 22 | "per_certificate_fees": { 23 | "certificate_pool_registration": 500000000, 24 | "certificate_stake_delegation": 400000, 25 | "certificate_owner_stake_delegation": null 26 | }, 27 | "coefficient": 100000, 28 | "certificate": 10000, 29 | "constant": 200000 30 | }, 31 | "consensus_leader_ids": [ 32 | "ed25519_pk12q442ewj2clmpesqgt5k53nrh9zur3vjfae7d7ve9psy2efnwcnqmqy473", 33 | "ed25519_pk1mev6hvhwvq95a3086qqt6sdhtslkq6p20kdvneascxgy4r3needqa0djhj" 34 | ], 35 | "kes_update_speed": 86400, 36 | "consensus_genesis_praos_active_slot_coeff": 0.1, 37 | "total_reward_supply": 701917808520000, 38 | "reward_constraints": { 39 | "pool_participation_capping": { 40 | "max": 100, 41 | "min": 100 42 | }, 43 | "reward_drawing_limit_max": "4109589/10000000000" 44 | }, 45 | "block0_consensus": "genesis_praos", 46 | "discrimination": "test", 47 | "epoch_stability_depth": 10 48 | }, 49 | "initial": [ 50 | { 51 | "fund": [ 52 | { 53 | "value": 1, 54 | "address": "ca1sk9m4muwlylr5zlcrdhwuznxkq583archny4lk5ru5zpfjx9png7cvnkmew" 55 | }, 56 | { 57 | "value": 1, 58 | "address": "ca1s4t67wa9la8fz4xvgdz9x5ahvdjzdl5e6ngyf8pmk2x96fcuvng4qc4r8nc" 59 | }, 60 | { 61 | "value": 1, 62 | "address": "ca1s5z8mmergszjrtsjt4v085udgke7dhnzcaa3apc06ul2lgnyjkmvy9h20sd" 63 | }, 64 | { 65 | "value": 1, 66 | "address": "ca1s5k4r5pjxe50pf6juklvaygeadw5wu3pkyp6t70uqr6qxm06tqpt6fzwsqy" 67 | }, 68 | { 69 | "value": 1, 70 | "address": "ca1s4v2zgj4umpp2yhdyy4wwejfe32hpp5ay4dm0dcxep7q8rzf3a9l5e873ed" 71 | }, 72 | { 73 | "value": 1, 74 | "address": "ca1skzn6q7erq22lrp3xk3mjzpdu38vfdkmrr62nkwsvwl2ettykyuf5az5gwe" 75 | } 76 | ] 77 | }, 78 | { 79 | "legacy_fund": [ 80 | { 81 | "value": 1000000000000000, 82 | "address": "DdzFFzCqrhtCWeg6PywoAR8wrza9DawkU2KgQddh7oi43LZy1kbZgZYK2hakgtXZu8Q7ptnhFjgV3ZgRgSypFhwtK9paG3ui17PiVUmB" 83 | }, 84 | { 85 | "value": 1000000000000000, 86 | "address": "DdzFFzCqrht1zDLWxw9hLEgzKogvkGH3KNNTCjADNreP8FTczsxMd7VG1k4qRHezZNQhgx6fHUa1NA54acajnENFymHxcEZrvgjG1p23" 87 | }, 88 | { 89 | "value": 500000000000000, 90 | "address": "2w1sdSJu3GVhFy8dRXtQx8FG3DiCph25SLjnde5BTKrECbB4hjzQHfXRtGs2STenXy9rgsUVVE3p7TA8ejA7WQLRqTBz3iZH6B9" 91 | }, 92 | { 93 | "value": 500000000000000, 94 | "address": "2w1sdSJu3GVhVdQ3a59QppJdZHCdT1LTcXoNzocht5BKXRwj24dCtghsyD4vHTkaRNNAHw2NpKyNRjTN5dUaPixbsTWAVAwqiDv" 95 | } 96 | ] 97 | }, 98 | { 99 | "cert": "signedcert1qvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqz9hm00yrwh3u4aeaaprmt8m6dnxhqhhpr75ywn9v7a2qjpsvn8glwwk6ewf0xczx99hgq2txmst3e64rwf2x4zzcev3f9vwanxf53gjsrza6a780j036p0upkmhwpfntq2rc73utej2lm2p72pq5erzse50vqqqqqqqqqqqqqqqqqqqqqqqqqpjqqqqqqqqqqqryqqqqqqqqqqqqqqqpqptklh348rx72mku20xpv5y04l65a4eelgp74syjsgvhg266ere5vcgmzgntr98de6h9e9q5tz96dkwek60ypp33nt4wftvgvje4t9gxh50nmk" 100 | }, 101 | { 102 | "cert": "signedcert1qvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzdkxkrfgerwcq3m75rpvsztp594k95tu3cj0lvmtfyw5rd7naupy7ax4qur7xwxmqq4wa292qrc7za3q272usg3jp6yucp5gezkrhu8sz4a08wjl7n532nxyx3zn2wmkxepxl6vaf5zynsam9rzayuwxf52sqqqqqqqqqqqqqqqqqqqqqqqqqpjqqqqqqqqqqqryqqqqqqqqqqqqqqqpqqlxca4gq2lem99cg4c93swwyz3mqrk9tkenw7698nlzduk22r42kxe9vl5800c57r26ucs4dwha3nu334u457l786swgm5zcfnxsvsr2xvahk" 103 | }, 104 | { 105 | "cert": "signedcert1qvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqrrjystdcr2z4jwnwamazratqupv3c0uca07j34zx2zuyrjd2sm655zzpyvd3fu536euqaf3x7yzdurtlxxc7mkggzrkfzy7d2gsrmncqzpraau35gpfp4cf96k8n6wx5tvlxme3vw7c7su8aw0405fjftdkzqqqqqqqqqqqqqqqqqqqqqqqqqqyqqqqqqqqqqqryqqqqqqqqqqqqqqqpqppxanczpxvklnv7g0dvplks38nyafxnkj7k8cderpnvg3vrj439vhycaka79l76533w3e03kg7m50y3s9u4wlksup74kv2mlsrhr4cx73s73k" 106 | }, 107 | { 108 | "cert": "signedcert1qvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr9ke2ldsn8wlyga9adrju73akshnlt2xdgps63efhh9cftw8qycmwm6u8syhln2npxzgsv57lqtallj8dlxd7szth5t55e7vvuyl4gjqzt236qerv68s5afwt0kwjyv7kh28wgsmzqa9l87qpaqrdha9sq4aqqqqqqqqqqqqqqqqqqqqqqqqqq9qqqqqqqqqqqryqqqqqqqqqqqqqqqpqzd9wp75kwdtgc99fvvdd2kgmzfprs6xexm66dtavguzmh89q3tnvz5n5wewggfcjzfxa3vlv2x2wjmsj7xcszyp4az5lyzpn534akg29j6t6m" 109 | }, 110 | { 111 | "cert": "signedcert1qvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzf4rnnsgwa5w0j98mglemjhllaawfgd4d2yg9ccsyd8rl097wnzdclx3hn3pnfc33w9v2x43l83xh2mges3whj90mutumcrz7jxrj2gqzk9pyf27dss4ztkjz2h8veyuc4tss6wj2kahkurvslqr33yc7jl6qqqqqqqqqqqqqqqqqqqqqqqqqqxqqqqqqqqqqqryqqqqqqqqqqqqqqqpqq5rj3h8qvjlsuz35amgqw53t6l326ad4j6nxqsfe76vu60st7enyqv3h4hupud5jnjgaektjs4hfpzy0yz90ece7w7agtu9wsweg8s2lw7ah2" 112 | }, 113 | { 114 | "cert": "signedcert1qvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqre9yxch9hmx3tx0ev9fxefql09gm72yp7lq93gr9ue3ee0l3s833js05z3m64we5qujdd5feq7upgexy4sdf385xt4cakzl9zksnw0gqrpfaq0v3s9903scntgaepqk7gnkykmd33a9fm8gx804v44jtzwy6qqqqqqqqqqqqqqqqqqqqqqqqqqgqqqqqqqqqqqryqqqqqqqqqqqqqqqpqqp3r20rvwhjf5039gjd88zejs8ft33qjq33hxllw3vc7vfcgygjc2pz54qpxu9vhav5e3hh3w72xfukxkygnpvdfjp2kfhhpwd9kmgddp90td" 115 | }, 116 | { 117 | "cert": "signedcert1qx9m4muwlylr5zlcrdhwuznxkq583archny4lk5ru5zpfjx9png7cq0kmqjsvfjf04txyrg5xkllpx754pg0q4yu0hrzpwhjcy857txk7sqcarxfcdndt86gvflzudlzxu86fmrdfwmlq68awcawr7eh3an80aq4z54lr6gupuwre3p3626eepm3lm934qgtlu4x58nz4vxajjf7qgr3ve55" 118 | }, 119 | { 120 | "cert": "signedcert1q9t67wa9la8fz4xvgdz9x5ahvdjzdl5e6ngyf8pmk2x96fcuvng4qqdtr8gk2e0f7sksq6sjj0g7daf6lyu92g4medkyhhf9pgpnrxs0dcqewzwjqqk6dmuqc5d59j0a3wcvhl7ejz4sl6ja7wzxgpm9xe890clyl8nut5vt2hchk0zef7mplg92m45kzhxxzjxdjn0nuj000se7pc5mqlaa" 121 | }, 122 | { 123 | "cert": "signedcert1qyz8mmergszjrtsjt4v085udgke7dhnzcaa3apc06ul2lgnyjkmvyqfzpv72hp2zlcwakvrskudjlskzaphvyqfjefq7y80pr2gtq5vhcyqnc2f7ws6rh0ql2p50p0ur2tev8q48a7aeld7cxlnzvwj49yqx3r22epemv2a6wtnapg9xp9pasrx8qsqzky8ne7uv2w2fdzfk56xfqvkfvf78" 124 | }, 125 | { 126 | "cert": "signedcert1qyk4r5pjxe50pf6juklvaygeadw5wu3pkyp6t70uqr6qxm06tqpt6qwftzgctwltqjaqxrh4fr3wncadhndcasewqaq503wm2vcc4nwqesq782zf4ldp9k8hcgqc6lmf8fymfgsphlns3u9vwdrem0dkw74ue2w2556qkk8chfujhk8yewvl6rccnzyf99s2p2zegsya7hyj2v9kqy7dc042" 127 | }, 128 | { 129 | "cert": "signedcert1q9v2zgj4umpp2yhdyy4wwejfe32hpp5ay4dm0dcxep7q8rzf3a9l5qwml92qn0uervktn2d059pl9qu0wf4k6x2s6jrah0u56p6rydx6ryq4sspez9m54jyrl5qrwlrwku5x0mmh574l5n633nwkz6pmachsv6nkzm3ujtzas358g2w60hupesmjku7qpp5cxthlryv8976nd7w7p59qdkf6" 130 | }, 131 | { 132 | "cert": "signedcert1qxzn6q7erq22lrp3xk3mjzpdu38vfdkmrr62nkwsvwl2ettykyuf5qgp20hy4435qjh39v075kzqe6555xl3lr2uha4s5hwesdnpkvt54yqnujzpzgp0mp2l35srzy3daz7t9p49jp9aun7fzcm0f4ql9t3ee0pd5tgsqphgxpyelnu0v0gfv3sw7sdt78enmxdynhffnxpjm5uapssmec3y" 133 | } 134 | ] 135 | } 136 | -------------------------------------------------------------------------------- /jormungandr-lib/sync.cr: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env nix-shell 2 | #!nix-shell -I nixpkgs=./nix -p rsync crystal -i crystal 3 | 4 | require "file_utils" 5 | require "http/client" 6 | require "json" 7 | 8 | class JormungandrVersions 9 | EMPTY_HASH = "0000000000000000000000000000000000000000000000000000" 10 | VERSIONS_FILE = "jormungandr-lib/versions.json" 11 | 12 | JSON.mapping(versions: Hash(String, Version)) 13 | 14 | def self.update! 15 | from_json(File.read(VERSIONS_FILE)).update! 16 | puts "Updated all versions in #{VERSIONS_FILE}" 17 | end 18 | 19 | class Version 20 | JSON.mapping(version: String, rev: String, sha256: String, cargoSha256: String) 21 | 22 | def initialize(@version, @rev, @sha256 : String = EMPTY_HASH, @cargoSha256 : String = EMPTY_HASH) 23 | @version = version_without_v 24 | end 25 | 26 | def calculate_sha256 27 | return unless sha256 == EMPTY_HASH 28 | puts "Calculating sha256 for #{version}" 29 | calculate "src" { |sum| @sha256 = sum; yield } 30 | end 31 | 32 | def calculate_cargoSha256 33 | return unless cargoSha256 == EMPTY_HASH 34 | puts "Calculating cargoSha256 for #{version}" 35 | calculate "cargoDeps" { |sum| @cargoSha256 = sum; yield } 36 | end 37 | 38 | def calculate(name : String) 39 | args = [ 40 | "build", "-L", "-f", "./jormungandr-lib/calculate_hashes.nix", name, 41 | "--argstr", "version", version_without_v, 42 | "--argstr", "sha256", sha256.not_nil!, 43 | "--argstr", "cargoSha256", cargoSha256, 44 | ] 45 | 46 | puts "nix #{args.join(" ")}" 47 | 48 | Process.run("nix", args) do |process| 49 | output = process.error.gets_to_end 50 | output.match(/^\s*got:\s*sha256:(.\S+)/m).try(&.[1]).try do |sum| 51 | yield sum 52 | end 53 | 54 | output.match(/^\s*got:\s*sha256-(.\S+)/m).try(&.[1]).try do |sum| 55 | yield convert_to_old(sum) 56 | end 57 | end 58 | end 59 | 60 | def convert_to_old(hash) 61 | output = IO::Memory.new 62 | Process.run("nix-hash", [ "--to-base32", "--type", "sha256", hash ], output: output, error: STDERR) 63 | output.to_s.strip 64 | end 65 | 66 | def version_without_v 67 | version.gsub(/^v/, "") 68 | end 69 | end 70 | 71 | def github_releases 72 | HTTP::Client.get("https://api.github.com/repos/input-output-hk/jormungandr/releases") do |resp| 73 | GithubReleases.from_json(resp.body_io) 74 | end 75 | end 76 | 77 | def update! 78 | github_releases.each do |release| 79 | version = JormungandrVersions::Version.new(release.tag_name, release.rev) 80 | 81 | versions[release.nix_version]?.try do |existing_version| 82 | version.sha256 = existing_version.sha256 83 | version.cargoSha256 = existing_version.cargoSha256 84 | end 85 | 86 | version.calculate_sha256 do 87 | versions[release.nix_version] = version 88 | persist! 89 | end 90 | 91 | version.calculate_cargoSha256 do 92 | versions[release.nix_version] = version 93 | persist! 94 | end 95 | end 96 | end 97 | 98 | # TODO: use parallel execution 99 | def calculate_sha256_sums 100 | versions.values.each do |version| 101 | persist! if version.calculate_sha256 102 | end 103 | end 104 | 105 | # TODO: use parallel execution 106 | def calculate_cargoSha256_sums 107 | versions.values.each do |version| 108 | persist! if version.calculate_cargoSha256 109 | end 110 | end 111 | 112 | def persist! 113 | File.write(VERSIONS_FILE, self.to_pretty_json) 114 | end 115 | end 116 | 117 | alias GithubReleases = Array(GithubRelease) 118 | 119 | class GithubRelease 120 | JSON.mapping(tag_name: String) 121 | 122 | def nix_version : String 123 | tag_name.gsub(/(\d+)\./) { "#{$1}_" }.gsub("+", "_").gsub(".", "_") 124 | end 125 | 126 | def rev 127 | args = ["ls-remote", "https://github.com/input-output-hk/jormungandr", tag_name] 128 | puts "git #{args.join(" ")}" 129 | 130 | IO::Memory.new.tap { |memory| 131 | Process.run("git", args, output: memory, error: STDERR) 132 | }.to_s.split.first 133 | end 134 | end 135 | 136 | class JormungandrSynchronization 137 | NETWORKS = { 138 | "qa" => { 139 | server: "testnet-deployer", 140 | dir: "jormungandr-qa", 141 | }, 142 | "nightly" => { 143 | server: "testnet-deployer", 144 | dir: "jormungandr-nightly", 145 | }, 146 | "itn_rewards_v1" => { 147 | server: "mainnet-deployer", 148 | dir: "jormungandr-incentivized", 149 | }, 150 | "legacy" => { 151 | server: "testnet-deployer", 152 | dir: "jormungandr-legacy", 153 | }, 154 | "beta" => { 155 | server: "testnet-deployer", 156 | dir: "jormungandr-beta", 157 | }, 158 | } 159 | 160 | def self.sync! 161 | chan = Channel(Nil).new 162 | 163 | NETWORKS.each do |name, settings| 164 | puts "Synchronizing #{name} ..." 165 | spawn do 166 | new.sync(name, **settings) 167 | chan.send nil 168 | end 169 | end 170 | 171 | NETWORKS.size.times { chan.receive } 172 | end 173 | 174 | def sync(name, server, dir) 175 | unless sync_genesis_hash(name, server, dir) 176 | puts "#{name} is already synchronized" 177 | return 178 | end 179 | 180 | server_genesis = "#{server}:#{dir}/static/genesis.yaml" 181 | local_genesis = "jormungandr-lib/genesis-#{name}.yaml" 182 | bak = "#{local_genesis}.rsync.bak" 183 | 184 | if File.file?(local_genesis) 185 | FileUtils.cp local_genesis, bak 186 | end 187 | 188 | system(%(rsync -P #{server_genesis} #{bak})) 189 | 190 | if File.size(bak) / (1024.0 ** 2) > 1 191 | puts "truncating #{bak} genesis for because it's larger than 1 megabyte" 192 | 193 | File.open(bak, "r") do |in_io| 194 | content = Hash(String, JSON::Any).from_json(in_io) 195 | content["initial"] = JSON::Any.new(Array(JSON::Any).new) 196 | File.write(local_genesis, content.to_pretty_json) 197 | end 198 | else 199 | FileUtils.mv bak, local_genesis 200 | end 201 | end 202 | 203 | def sync_genesis_hash(name, server, dir) 204 | file = `nix eval --raw '((import ./. {}).jormungandrLib.environments.#{name}.genesisFile)'`.strip 205 | hash = `nix eval --raw '((import ./. {}).jormungandrLib.environments.#{name}.genesisHash)'`.strip 206 | 207 | cmd = "cd #{dir}; direnv exec . jcli genesis hash < static/block-0.bin" 208 | stdout, stderr = IO::Memory.new, IO::Memory.new 209 | process = Process.run("ssh", [server, cmd], error: stderr, output: stdout) 210 | 211 | unless process.success? 212 | puts "couldn't update hash for #{name}:" 213 | puts stderr.to_s 214 | return false 215 | end 216 | 217 | current_hash = stdout.to_s.strip 218 | 219 | if hash != current_hash 220 | old_default = File.read("jormungandr-lib/default.nix") 221 | File.write("jormungandr-lib/default.nix", old_default.gsub(hash, current_hash)) 222 | return true 223 | end 224 | 225 | false 226 | end 227 | end 228 | 229 | JormungandrVersions.update! 230 | 231 | puts "Now you can update your deployer with the correct version." 232 | puts "Hit return to continue fetching the genesis from the deployers." 233 | 234 | gets 235 | 236 | JormungandrSynchronization.sync! 237 | -------------------------------------------------------------------------------- /lib/default.nix: -------------------------------------------------------------------------------- 1 | lib: with lib; rec { 2 | 3 | systemdCompatModule.options = { 4 | systemd.services = mkOption {}; 5 | systemd.sockets = mkOption {}; 6 | assertions = []; 7 | users = mkOption {}; 8 | }; 9 | 10 | prefixNamesWith = p: mapAttrs' (n: v: nameValuePair "${p}${n}" v); 11 | 12 | collectExes = p: listToAttrs (concatMap (n: 13 | let s = lib.splitString ":" n; 14 | in if (lib.length s == 3) 15 | then [ (nameValuePair (lib.elemAt s 2) p.${n}) ] 16 | # exclude cross-compiled exes: 17 | else [] 18 | ) (attrNames p)); 19 | 20 | evalService = { pkgs, serviceName, modules, customConfigs }: 21 | let mkConfig = c: if (isAttrs c) 22 | then ( 23 | if c ? nixosModules.${serviceName} 24 | then c.nixosModules.${serviceName} 25 | else if c ? nixosModule 26 | then mkConfig c.nixosModule 27 | else if c ? services.${serviceName} then { 28 | services.${serviceName} = c.services.${serviceName}; 29 | } else {options, ...}: { 30 | services.${serviceName} = 31 | let validOptions = attrNames options.services.${serviceName}; 32 | in filterAttrs (n: _: elem n validOptions) c; 33 | }) 34 | else c; 35 | 36 | in (lib.modules.evalModules { 37 | prefix = []; 38 | modules = modules ++ [ 39 | { 40 | services.${serviceName}.enable = true; 41 | _module = { 42 | args = { inherit pkgs; }; 43 | check = false; 44 | }; 45 | } 46 | systemdCompatModule 47 | ] ++ (map mkConfig customConfigs); 48 | }).config.services.${serviceName}; 49 | } 50 | -------------------------------------------------------------------------------- /lib/release-lib.nix: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # This is a modified version of Nixpkgs release-lib. 3 | # 4 | # 1. The attrset of project derivations is now called "project" not 5 | # instead of "pkgs". 6 | # 7 | # 2. The arguments to pass to the project are now called "projectArgs" 8 | # instead of "nixpkgsArgs". 9 | # 10 | # 3. The Nixpkgs package set is available as "pkgs". 11 | # 12 | # 4. The "packagePlatforms" function ignores meta.platforms and just 13 | # uses the given supportedSystems. Old function available as 14 | # "packagePlatformsOrig". 15 | # 16 | # 5. There is a new "packagePlatformsCross" and corresponding 17 | # "supportedCrossSystems" argument. 18 | # 19 | # 6. Introduces a "mkRequiredJob" derivation for GitHub CI status 20 | # reporting. 21 | # 22 | ######################################################################## 23 | 24 | { pkgs ? import {} 25 | # What systems to use for building. 26 | , supportedSystems 27 | # What systems to use for cross-compilation builds. 28 | , supportedCrossSystems ? [ "x86_64-linux" ] 29 | # Hydra option 30 | , scrubJobs ? true 31 | # Your project's default.nix 32 | , packageSet 33 | # Arguments to pass to packageSet. 34 | , projectArgs ? { config = { allowUnfree = false; inHydra = true; }; } 35 | # Project source git revision, for "mkRequiredJob" 36 | , gitrev ? null 37 | }: 38 | 39 | with pkgs.lib; 40 | 41 | let 42 | release-lib = import (pkgs.path + "/pkgs/top-level/release-lib.nix") { 43 | inherit supportedSystems scrubJobs packageSet; 44 | nixpkgsArgs = projectArgs; 45 | }; 46 | 47 | in 48 | release-lib // rec { 49 | # The Nixpkgs package set, passed through for convenience. 50 | inherit pkgs; 51 | 52 | # Your project's package set. 53 | project = release-lib.pkgs; 54 | 55 | # Unlike the release-lib version, this ignores meta.platforms in 56 | # the derivations. 57 | packagePlatforms = mapAttrs (name: value: 58 | let res = builtins.tryEval ( 59 | if isDerivation value then 60 | supportedSystems 61 | else if value.recurseForDerivations or false || value.recurseForRelease or false then 62 | packagePlatforms value 63 | else 64 | []); 65 | in if res.success then res.value else [] 66 | ); 67 | packagePlatformsOrig = release-lib.packagePlatforms; 68 | 69 | # A version of packagePlatforms that uses supportedCrossSystems 70 | packagePlatformsCross = mapAttrs (name: value: 71 | let res = builtins.tryEval ( 72 | if isDerivation value then 73 | value.meta.hydraPlatforms 74 | or (supportedMatchesCross (value.meta.platforms or supportedCrossSystems)) 75 | else if value.recurseForDerivations or false || value.recurseForRelease or false then 76 | packagePlatformsCross value 77 | else 78 | []); 79 | in if res.success then res.value else [] 80 | ); 81 | 82 | # Given a list of 'meta.platforms'-style patterns, return the sublist of 83 | # `supportedCrossSystems` containing systems that matches at least one of the given 84 | # patterns. 85 | # 86 | # This is written in a funny way so that we only elaborate the systems once. 87 | supportedMatchesCross = let 88 | supportedPlatforms = map 89 | (system: systems.elaborate { inherit system; }) 90 | supportedCrossSystems; 91 | in metaPatterns: let 92 | anyMatch = platform: 93 | any (meta.platformMatch platform) metaPatterns; 94 | matchingPlatforms = filter anyMatch supportedPlatforms; 95 | in map ({ system, ...}: system) matchingPlatforms; 96 | 97 | # Creates a single aggregate job for the purpose of updating the 98 | # CI status in GitHub from IOHK Hydra. 99 | mkRequiredJob = constituents: let 100 | # This file seems pointless, but it forces Hydra to re-evaluate 101 | # every commit. The side-effect of that is that Hydra reports build 102 | # status to GitHub for every commit, which we want, and it wouldn't 103 | # normally do. 104 | build-version = pkgs.writeText "version.json" (builtins.toJSON 105 | (filterAttrs (n: _: n == "version") project // { inherit gitrev; })); 106 | in { 107 | inherit build-version; 108 | required = pkgs.releaseTools.aggregate ({ 109 | name = "github-required"; 110 | meta.description = "All jobs required to pass CI"; 111 | constituents = constituents ++ [ build-version ]; 112 | }); 113 | }; 114 | } 115 | -------------------------------------------------------------------------------- /maybe-env.nix: -------------------------------------------------------------------------------- 1 | # Gets the value of an environment variable, with a default if it's 2 | # unset or empty. 3 | env: default: 4 | let 5 | result = builtins.getEnv env; 6 | in if result != "" 7 | then result 8 | else default 9 | -------------------------------------------------------------------------------- /nix/default.nix: -------------------------------------------------------------------------------- 1 | { sources ? import ./sources.nix 2 | , system ? builtins.currentSystem 3 | , crossSystem ? null 4 | , config ? {} 5 | }: 6 | import sources.nixpkgs { 7 | inherit system crossSystem config; 8 | overlays = [ overlay ]; 9 | } 10 | -------------------------------------------------------------------------------- /nix/sources.json: -------------------------------------------------------------------------------- 1 | { 2 | "cardano-repo-tool": { 3 | "branch": "master", 4 | "description": "A tool for handling the update of Cardano related git repos", 5 | "homepage": "", 6 | "owner": "input-output-hk", 7 | "repo": "cardano-repo-tool", 8 | "rev": "9059370f40c0f6a9b2faa8fd2305b2b7b581b3bf", 9 | "sha256": "00blv2rkqajginv7r9vqz268rwmrls9vqc8p1h3p7iwpw2v0zhqg", 10 | "type": "tarball", 11 | "url": "https://github.com/input-output-hk/cardano-repo-tool/archive/9059370f40c0f6a9b2faa8fd2305b2b7b581b3bf.tar.gz", 12 | "url_template": "https://github.com///archive/.tar.gz" 13 | }, 14 | "haskell.nix": { 15 | "branch": "master", 16 | "description": "Alternative Haskell Infrastructure for Nixpkgs", 17 | "homepage": "https://input-output-hk.github.io/haskell.nix", 18 | "owner": "input-output-hk", 19 | "repo": "haskell.nix", 20 | "rev": "d68d84794999f7641b7c6500257e707f439bec36", 21 | "sha256": "1fx9ryv362d64wk7j02hqscg9gqavb3ijavmhjmzy65r32vlqb6n", 22 | "type": "tarball", 23 | "url": "https://github.com/input-output-hk/haskell.nix/archive/d68d84794999f7641b7c6500257e707f439bec36.tar.gz", 24 | "url_template": "https://github.com///archive/.tar.gz" 25 | }, 26 | "nixpkgs": { 27 | "branch": "nixos-21.11", 28 | "description": "Nix Packages collection", 29 | "homepage": null, 30 | "owner": "NixOS", 31 | "repo": "nixpkgs", 32 | "rev": "0d1d5d7e3679fec9d07f2eb804d9f9fdb98378d3", 33 | "sha256": "1h07qm69sf9ixfs79hqvacdg1ml7qmgmcvgwsaibqwaypsy5afn6", 34 | "type": "tarball", 35 | "url": "https://github.com/NixOS/nixpkgs/archive/0d1d5d7e3679fec9d07f2eb804d9f9fdb98378d3.tar.gz", 36 | "url_template": "https://github.com///archive/.tar.gz" 37 | }, 38 | "nixpkgs-19.09": { 39 | "branch": "nixos-19.09", 40 | "description": "Nix Packages collection", 41 | "homepage": null, 42 | "owner": "NixOS", 43 | "repo": "nixpkgs-channels", 44 | "rev": "84f47bfe9ae892042fcb04f319ffe208cd0dbfd9", 45 | "sha256": "0rh1kcasz78f2bbnd816705x027xkyrlm314x4jg8hjdhzyaky8f", 46 | "type": "tarball", 47 | "url": "https://github.com/NixOS/nixpkgs-channels/archive/84f47bfe9ae892042fcb04f319ffe208cd0dbfd9.tar.gz", 48 | "url_template": "https://github.com///archive/.tar.gz" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /nix/sources.nix: -------------------------------------------------------------------------------- 1 | # This file has been generated by Niv. 2 | 3 | let 4 | 5 | # 6 | # The fetchers. fetch_ fetches specs of type . 7 | # 8 | 9 | fetch_file = pkgs: name: spec: 10 | let 11 | name' = sanitizeName name + "-src"; 12 | in 13 | if spec.builtin or true then 14 | builtins_fetchurl { inherit (spec) url sha256; name = name'; } 15 | else 16 | pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; 17 | 18 | fetch_tarball = pkgs: name: spec: 19 | let 20 | name' = sanitizeName name + "-src"; 21 | in 22 | if spec.builtin or true then 23 | builtins_fetchTarball { name = name'; inherit (spec) url sha256; } 24 | else 25 | pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; 26 | 27 | fetch_git = name: spec: 28 | let 29 | ref = 30 | if spec ? ref then spec.ref else 31 | if spec ? branch then "refs/heads/${spec.branch}" else 32 | if spec ? tag then "refs/tags/${spec.tag}" else 33 | abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; 34 | in 35 | builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; 36 | 37 | fetch_local = spec: spec.path; 38 | 39 | fetch_builtin-tarball = name: throw 40 | ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. 41 | $ niv modify ${name} -a type=tarball -a builtin=true''; 42 | 43 | fetch_builtin-url = name: throw 44 | ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. 45 | $ niv modify ${name} -a type=file -a builtin=true''; 46 | 47 | # 48 | # Various helpers 49 | # 50 | 51 | # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 52 | sanitizeName = name: 53 | ( 54 | concatMapStrings (s: if builtins.isList s then "-" else s) 55 | ( 56 | builtins.split "[^[:alnum:]+._?=-]+" 57 | ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) 58 | ) 59 | ); 60 | 61 | # The set of packages used when specs are fetched using non-builtins. 62 | mkPkgs = sources: system: 63 | let 64 | sourcesNixpkgs = 65 | import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; 66 | hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; 67 | hasThisAsNixpkgsPath = == ./.; 68 | in 69 | if builtins.hasAttr "nixpkgs" sources 70 | then sourcesNixpkgs 71 | else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then 72 | import {} 73 | else 74 | abort 75 | '' 76 | Please specify either (through -I or NIX_PATH=nixpkgs=...) or 77 | add a package called "nixpkgs" to your sources.json. 78 | ''; 79 | 80 | # The actual fetching function. 81 | fetch = pkgs: name: spec: 82 | 83 | if ! builtins.hasAttr "type" spec then 84 | abort "ERROR: niv spec ${name} does not have a 'type' attribute" 85 | else if spec.type == "file" then fetch_file pkgs name spec 86 | else if spec.type == "tarball" then fetch_tarball pkgs name spec 87 | else if spec.type == "git" then fetch_git name spec 88 | else if spec.type == "local" then fetch_local spec 89 | else if spec.type == "builtin-tarball" then fetch_builtin-tarball name 90 | else if spec.type == "builtin-url" then fetch_builtin-url name 91 | else 92 | abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; 93 | 94 | # If the environment variable NIV_OVERRIDE_${name} is set, then use 95 | # the path directly as opposed to the fetched source. 96 | replace = name: drv: 97 | let 98 | saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; 99 | ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; 100 | in 101 | if ersatz == "" then drv else 102 | # this turns the string into an actual Nix path (for both absolute and 103 | # relative paths) 104 | if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; 105 | 106 | # Ports of functions for older nix versions 107 | 108 | # a Nix version of mapAttrs if the built-in doesn't exist 109 | mapAttrs = builtins.mapAttrs or ( 110 | f: set: with builtins; 111 | listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) 112 | ); 113 | 114 | # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 115 | range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); 116 | 117 | # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 118 | stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); 119 | 120 | # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 121 | stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); 122 | concatMapStrings = f: list: concatStrings (map f list); 123 | concatStrings = builtins.concatStringsSep ""; 124 | 125 | # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 126 | optionalAttrs = cond: as: if cond then as else {}; 127 | 128 | # fetchTarball version that is compatible between all the versions of Nix 129 | builtins_fetchTarball = { url, name ? null, sha256 }@attrs: 130 | let 131 | inherit (builtins) lessThan nixVersion fetchTarball; 132 | in 133 | if lessThan nixVersion "1.12" then 134 | fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) 135 | else 136 | fetchTarball attrs; 137 | 138 | # fetchurl version that is compatible between all the versions of Nix 139 | builtins_fetchurl = { url, name ? null, sha256 }@attrs: 140 | let 141 | inherit (builtins) lessThan nixVersion fetchurl; 142 | in 143 | if lessThan nixVersion "1.12" then 144 | fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) 145 | else 146 | fetchurl attrs; 147 | 148 | # Create the final "sources" from the config 149 | mkSources = config: 150 | mapAttrs ( 151 | name: spec: 152 | if builtins.hasAttr "outPath" spec 153 | then abort 154 | "The values in sources.json should not have an 'outPath' attribute" 155 | else 156 | spec // { outPath = replace name (fetch config.pkgs name spec); } 157 | ) config.sources; 158 | 159 | # The "config" used by the fetchers 160 | mkConfig = 161 | { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null 162 | , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) 163 | , system ? builtins.currentSystem 164 | , pkgs ? mkPkgs sources system 165 | }: rec { 166 | # The sources, i.e. the attribute set of spec name to spec 167 | inherit sources; 168 | 169 | # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers 170 | inherit pkgs; 171 | }; 172 | 173 | in 174 | mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } 175 | -------------------------------------------------------------------------------- /overlays/crypto/default.nix: -------------------------------------------------------------------------------- 1 | inputs: final: prev: { 2 | # We pin our own crypto libraries here, so that we have control over 3 | # the specific revisions we use (assuming a recent enough iohk-nix). 4 | # 5 | # This allows us to set the sepcific version/rev we want in the 6 | # flake.nix. We _do not_ pin the generic libsodium, and rely on 7 | # the upstream one provided by what ever nixpkgs pin is used. 8 | # 9 | libsodium-vrf = final.callPackage ./libsodium.nix { src = inputs.sodium; }; 10 | libblst = final.callPackage ./libblst.nix { src = inputs.blst; }; 11 | # we will follow nixpkg upstreams naming scheme where needed. We want to pin 12 | # this library, but also don't start dealing with multiple libraries with 13 | # different but same names, and then risk that we accidentally diverge. 14 | secp256k1 = final.callPackage ./libsecp256k1.nix { src = inputs.secp256k1; }; 15 | } 16 | -------------------------------------------------------------------------------- /overlays/crypto/libblst.nix: -------------------------------------------------------------------------------- 1 | { stdenv, lib, autoreconfHook, enableShared ? !stdenv.hostPlatform.isStatic && !stdenv.hostPlatform.isWindows, src }: 2 | 3 | stdenv.mkDerivation rec { 4 | pname = "blst"; 5 | version = src.shortRev; 6 | 7 | inherit src; 8 | 9 | # note on -D__BLST_PORTABLE__, this should allow us to have MULX, and similar 10 | # stuff run-time detected, and as such blst built on newer hardware should still 11 | # work on older. Notably Intel before Broadwell, and AMD before Ryzen, do not 12 | # support ADX, which means they lack MULX support, which blst uses. 13 | buildPhase = '' 14 | ./build.sh -D__BLST_PORTABLE__ ${lib.optionalString stdenv.hostPlatform.isWindows "flavour=mingw64"} 15 | '' + lib.optionalString enableShared '' 16 | ./build.sh -D__BLST_PORTABLE__ -shared ${lib.optionalString stdenv.hostPlatform.isWindows "flavour=mingw64"} 17 | ''; 18 | installPhase = '' 19 | mkdir -p $out/{lib,include} 20 | for lib in libblst.{a,so,dylib}; do 21 | if [ -f $lib ]; then 22 | cp $lib $out/lib/ 23 | fi 24 | done 25 | cp bindings/{blst.h,blst_aux.h} $out/include 26 | 27 | for lib in blst.dll; do 28 | if [ -f $lib ]; then 29 | mkdir -p $out/bin 30 | cp $lib $out/bin/ 31 | fi 32 | done 33 | '' + '' 34 | mkdir -p $out/lib/pkgconfig 35 | cat < $out/lib/pkgconfig/libblst.pc 36 | prefix=$out 37 | exec_prefix=''\\''${prefix} 38 | libdir=''\\''${exec_prefix}/lib 39 | includedir=''\\''${prefix}/include 40 | 41 | Name: libblst 42 | Description: ${meta.description} 43 | URL: ${meta.homepage} 44 | Version: ${version} 45 | 46 | Cflags: -I''\\''${includedir} 47 | Libs: -L''\\''${libdir} -lblst 48 | Libs.private: 49 | EOF 50 | ''; 51 | 52 | # ensure we have the right install id set. Otherwise the library 53 | # wouldn't be found during install. The alternative would be to work 54 | # lib.optional stdenv.isDarwin "LDFLAGS=-Wl,-install_name,$(out)/lib/libblst.dylib"; 55 | # into the setup.sh 56 | postFixup = lib.optionalString (stdenv.isDarwin && enableShared) '' 57 | install_name_tool -id $out/lib/libblst.dylib $out/lib/libblst.dylib 58 | ''; 59 | 60 | enableParallelBuilding = true; 61 | 62 | doCheck = true; 63 | 64 | meta = with lib; { 65 | description = "Multilingual BLS12-381 signature library"; 66 | homepage = "https://github.com/supranational/blst"; 67 | license = licenses.isc; 68 | platforms = platforms.all; 69 | }; 70 | } 71 | -------------------------------------------------------------------------------- /overlays/crypto/libsecp256k1.nix: -------------------------------------------------------------------------------- 1 | { lib, stdenv, autoreconfHook, src, 2 | enableStatic ? stdenv.hostPlatform.isStatic }: 3 | 4 | stdenv.mkDerivation rec { 5 | pname = "secp256k1"; 6 | version = src.shortRev; 7 | 8 | inherit src; 9 | 10 | nativeBuildInputs = [ autoreconfHook ]; 11 | 12 | configureFlags = [ 13 | "--enable-benchmark=no" 14 | "--enable-module-recovery" 15 | ] ++ lib.optional enableStatic [ 16 | "--enable-static" 17 | ]; 18 | 19 | doCheck = true; 20 | 21 | meta = with lib; { 22 | description = "Optimized C library for EC operations on curve secp256k1"; 23 | longDescription = '' 24 | Optimized C library for EC operations on curve secp256k1. Part of 25 | Bitcoin Core. This library is a work in progress and is being used 26 | to research best practices. Use at your own risk. 27 | ''; 28 | homepage = "https://github.com/bitcoin-core/secp256k1"; 29 | license = with licenses; [ mit ]; 30 | maintainers = with maintainers; [ ]; 31 | platforms = with platforms; all; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /overlays/crypto/libsodium.nix: -------------------------------------------------------------------------------- 1 | { stdenv, lib, autoreconfHook, src }: 2 | 3 | stdenv.mkDerivation rec { 4 | pname = "libsodium-vrf"; 5 | version = src.shortRev; 6 | 7 | inherit src; 8 | 9 | nativeBuildInputs = [ autoreconfHook ]; 10 | 11 | configureFlags = [ "--enable-static" ] 12 | # Fixes a compilation failure: "undefined reference to `__memcpy_chk'". Note 13 | # that the more natural approach of adding "stackprotector" to 14 | # `hardeningDisable` does not resolve the issue. 15 | ++ lib.optional stdenv.hostPlatform.isMinGW "CFLAGS=-fno-stack-protector"; 16 | 17 | outputs = [ "out" "dev" ]; 18 | separateDebugInfo = stdenv.isLinux && stdenv.hostPlatform.libc != "musl"; 19 | 20 | enableParallelBuilding = true; 21 | 22 | doCheck = true; 23 | 24 | meta = with lib; { 25 | description = "A modern and easy-to-use crypto library - VRF fork"; 26 | homepage = "http://doc.libsodium.org/"; 27 | license = licenses.isc; 28 | maintainers = [ "tdammers" "nclarke" ]; 29 | platforms = platforms.all; 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /overlays/haskell-nix-crypto/default.nix: -------------------------------------------------------------------------------- 1 | # /!\ This overlay depends on both the iohk-nix crypto and the haskell.nix overlays in prev, 2 | # so must be after them in the list of overlays to nixpkgs. 3 | final: prev: { 4 | # Make libraries from the crypto overlays available to 5 | # haskell-nix's pkg-config map when solving for dependencies with cabal. 6 | haskell-nix = prev.haskell-nix or {} // { 7 | extraPkgconfigMappings = prev.haskell-nix.extraPkgconfigMappings or {} // { 8 | "libblst" = [ "libblst" ]; 9 | # map libsoidum to our libsodium-vrf, if you include the iohk-nix 10 | # crypto overlay, you _do_ want the custom libsoidum. 11 | "libsodium" = [ "libsodium-vrf" ]; 12 | # for secp256k1, haskell.nix already has that mapping, thus we don't 13 | # need to inject anything extra here. 14 | }; 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /overlays/haskell-nix-extra/default.nix: -------------------------------------------------------------------------------- 1 | let 2 | compiler-nix-name = "ghc8107"; 3 | index-state = "2021-12-13T00:00:00Z"; 4 | in final: prev: with final; with lib; { 5 | 6 | haskell-nix = recursiveUpdate prev.haskell-nix { 7 | # TODO: remove this haskellLib.extra 8 | haskellLib.extra = rec { 9 | collectChecks = 10 | trace ( "Warning: `haskell-nix.haskellLib.extra.collectChecks`" 11 | + " is deprecated and will be removed. Please use" 12 | + " `haskell-nix.haskellLib.collectChecks'`.") 13 | haskell-nix.haskellLib.collectChecks'; 14 | 15 | recRecurseIntoAttrs = x: 16 | if (isAttrs x && !isDerivation x && x.recurseForDerivations or true) 17 | then recurseIntoAttrs (mapAttrs (n: v: if n == "buildPackages" then v else recRecurseIntoAttrs v) x) 18 | else x; 19 | }; 20 | }; 21 | 22 | stackNixRegenerate = pkgs.callPackage ./nix-tools-regenerate.nix { 23 | nix-tools = haskell-nix.nix-tools.${compiler-nix-name}; 24 | }; 25 | 26 | haskellBuildUtils = pkgs.callPackage ./utils/default.nix { 27 | inherit compiler-nix-name index-state; 28 | }; 29 | 30 | rewriteStatic = _: p: if (pkgs.stdenv.hostPlatform.isDarwin) then 31 | pkgs.runCommandCC p.name { 32 | nativeBuildInputs = [ pkgs.haskellBuildUtils pkgs.buildPackages.binutils pkgs.buildPackages.nix ]; 33 | } '' 34 | cp -R ${p} $out 35 | chmod -R +w $out 36 | rewrite-libs $out/bin $out/bin/* 37 | '' else if (pkgs.stdenv.hostPlatform.isMusl) then 38 | pkgs.runCommandCC p.name { } '' 39 | cp -R ${p} $out 40 | chmod -R +w $out 41 | $STRIP $out/bin/* 42 | '' else p; 43 | 44 | # Given a derivation, stamp its Haskell executable with provided version info (git revision), 45 | # using `set-git-rev` from the haskellBuildUtils package. 46 | # The target executable must have use "Data.FileEmbed.dummySpace". 47 | # Return a new derivation that depends on the original one. 48 | # This is an alternative to using postInstall for stamping, 49 | # allowing more caching opportunities and a much lower closure size. 50 | setGitRev = gitrev: drv: 51 | let 52 | # The new drivation will copy over existing attributes for compatibility, 53 | # except `exePath` that need to point to the new $out path. 54 | newdrv = buildPackages.runCommand drv.name { 55 | passthru = drv.passthru // (optionalAttrs (drv.passthru ? exeName) { 56 | exePath = newdrv + "/bin/${drv.passthru.exeName}"; 57 | }); 58 | } '' 59 | mkdir -p $out 60 | # We link rather than copy from original, to save some space/time: 61 | ln -s ${drv}/* $out/ 62 | rm $out/bin 63 | mkdir $out/bin 64 | ln -s ${drv}/bin/* $out/bin/ 65 | rm $out/bin/*${stdenv.hostPlatform.extensions.executable} 66 | cp --no-preserve=timestamps --recursive ${drv}/bin/*${stdenv.hostPlatform.extensions.executable} $out/bin/ 67 | chmod -R +w $out/bin/*${stdenv.hostPlatform.extensions.executable} 68 | ${pkgsBuildBuild.haskellBuildUtils}/bin/set-git-rev "${gitrev}" $out/bin/*${stdenv.hostPlatform.extensions.executable} 69 | ''; 70 | in drv // newdrv; 71 | 72 | # Stamp executables from multiple derivations, identified by path in the attribute set 73 | # (third arg), with version info (git revision). Eg.: 74 | # `setGitRevForPaths gitrev [ 75 | # "cardano-db-sync.components.exes.cardano-db-sync" 76 | # "cardano-smash-server.components.exes.cardano-smash-server" 77 | # "cardano-db-tool.components.exes.cardano-db-tool"] hsPkgs 78 | setGitRevForPaths = gitrev: exePaths: 79 | updateManyAttrsByPath (map (path: { 80 | path = splitString "." path; 81 | update = setGitRev gitrev; 82 | }) exePaths); 83 | } 84 | -------------------------------------------------------------------------------- /overlays/haskell-nix-extra/nix-tools-regenerate.nix: -------------------------------------------------------------------------------- 1 | # A script for generating the nix haskell package set based on stackage, 2 | # using the common convention for repo layout. 3 | 4 | { lib, stdenv, runtimeShell, path, writeScript, nix-tools, coreutils, findutils, glibcLocales }: 5 | 6 | let 7 | deps = [ nix-tools coreutils findutils ]; 8 | 9 | in 10 | writeScript "nix-tools-regenerate" '' 11 | #!${runtimeShell} 12 | # 13 | # Haskell package set regeneration script. 14 | # 15 | # stack-to-nix will transform the stack.yaml file into something 16 | # nix can understand. 17 | # 18 | 19 | set -euo pipefail 20 | # See https://github.com/NixOS/nixpkgs/pull/47676 for why we add /usr/bin to 21 | # the PATH on darwin. The security-tool in nixpkgs is broken on macOS Mojave. 22 | export PATH=${(lib.makeBinPath deps) + lib.optionalString stdenv.isDarwin ":/usr/bin"} 23 | export NIX_PATH=nixpkgs=${path} 24 | # Needed or stack-to-nix will die on unicode inputs 25 | LOCALE_ARCHIVE=${lib.optionalString (stdenv.hostPlatform.libc == "glibc") "${glibcLocales}/lib/locale/locale-archive"}; 26 | LANG="en_US.UTF-8"; 27 | LC_ALL="en_US.UTF-8"; 28 | 29 | tmp_dest=".stack-to-nix.tmp" 30 | mkdir -p "$tmp_dest" 31 | 32 | function cleanup { 33 | rm -rf "$tmp_dest" 34 | } 35 | trap cleanup EXIT 36 | 37 | stack-to-nix --output "$tmp_dest/.stack.nix" "$@" 38 | ( 39 | cd $tmp_dest/.stack.nix 40 | mv pkgs.nix default.nix 41 | ) 42 | 43 | generated_files="$(cd "$tmp_dest"; find .stack.nix)" 44 | 45 | cp -rlf $tmp_dest/.stack.nix nix/ 46 | 47 | echo "Generated files in nix directory:" 48 | echo "$generated_files" 49 | '' 50 | -------------------------------------------------------------------------------- /overlays/haskell-nix-extra/utils/.gitignore: -------------------------------------------------------------------------------- 1 | dist-newstyle 2 | .stack-work 3 | -------------------------------------------------------------------------------- /overlays/haskell-nix-extra/utils/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /overlays/haskell-nix-extra/utils/default.nix: -------------------------------------------------------------------------------- 1 | { lib, haskell-nix, symlinkJoin 2 | , compiler-nix-name, index-state 3 | , evalSystem ? null }: 4 | 5 | let 6 | project = mkProject {}; 7 | 8 | evalSystemArg = if evalSystem == null 9 | then {} 10 | else { inherit evalSystem; }; 11 | mkProject = args: haskell-nix.cabalProject ({ 12 | src = haskell-nix.haskellLib.cleanSourceWith { 13 | name = "iohk-nix-utils"; 14 | src = ./.; 15 | }; 16 | inherit compiler-nix-name index-state; 17 | } // evalSystemArg // args); 18 | in 19 | symlinkJoin { 20 | name = "iohk-nix-utils"; 21 | paths = lib.attrValues project.iohk-nix-utils.components.exes; 22 | passthru = { 23 | inherit project mkProject; 24 | shell = project.shellFor {}; 25 | roots = project.roots; 26 | package = builtins.trace "WARNING: iohk-nix `haskellBuildUtils.package` has been renamed to `haskellBuildUtils`." null; 27 | stackRebuild = builtins.trace "WARNING: iohk-nix stackRebuild script has been removed." null; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /overlays/haskell-nix-extra/utils/iohk-nix-utils.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: 2.2 2 | name: iohk-nix-utils 3 | version: 0.1.0.0 4 | license: Apache-2.0 5 | author: IOHK Devops 6 | maintainer: devops@iohk.io 7 | copyright: 2019 IOHK 8 | category: Development 9 | 10 | library 11 | build-depends: base 12 | , async 13 | , bytestring 14 | , extra 15 | , foldl 16 | , optparse-applicative 17 | , safe 18 | , system-filepath 19 | , text 20 | , transformers 21 | , turtle 22 | ghc-options: -Wall 23 | default-language: Haskell2010 24 | exposed-modules: Build 25 | , BuildArgs 26 | , CommonBuild 27 | hs-source-dirs: lib 28 | executable set-git-rev 29 | main-is: set-git-rev.hs 30 | build-depends: base 31 | , bytestring 32 | , deepseq 33 | , file-embed 34 | default-language: Haskell2010 35 | -- https://github.com/NixOS/nixpkgs/issues/46814 36 | if os(darwin) 37 | ghc-options: -liconv 38 | 39 | executable rewrite-libs 40 | main-is: rewrite-libs.hs 41 | build-depends: base 42 | , turtle 43 | , megaparsec 44 | , text 45 | , directory 46 | default-language: Haskell2010 47 | -------------------------------------------------------------------------------- /overlays/haskell-nix-extra/utils/lib/Build.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase #-} 2 | {-# LANGUAGE NamedFieldPuns #-} 3 | {-# LANGUAGE OverloadedStrings #-} 4 | {-# LANGUAGE RecordWildCards #-} 5 | {-# LANGUAGE ScopedTypeVariables #-} 6 | {-# LANGUAGE TypeApplications #-} 7 | 8 | module Build where 9 | 10 | import Data.Text 11 | ( Text ) 12 | 13 | import CommonBuild 14 | ( BuildkiteEnv 15 | , CoverallsConfig 16 | , DryRun 17 | , ExitCode (ExitSuccess) 18 | , cacheGetStep 19 | , cachePutStep 20 | , cleanBuildDirectory 21 | , cleanupCacheStep 22 | , doMaybe 23 | , echo 24 | , getBuildkiteEnv 25 | , getCacheConfig 26 | , isBorsBuild 27 | , purgeCacheStep 28 | , run 29 | , setupBuildDirectory 30 | , timeout 31 | , uploadCoverageStep 32 | , void 33 | , weederStep 34 | , when 35 | , whenRun 36 | , (.&&.) 37 | ) 38 | 39 | import BuildArgs 40 | ( BuildArgs (BuildArgs, command, options) 41 | , Command (Build, CleanupCache, PurgeCache) 42 | , RebuildOpts (RebuildOpts, optBuildDirectory, optCacheDirectory, optDryRun) 43 | , parseArgs 44 | ) 45 | 46 | import Data.Maybe 47 | ( fromMaybe ) 48 | import System.Exit 49 | ( exitWith ) 50 | 51 | 52 | newtype Timeout = Timeout { unTimeout :: Int } 53 | deriving (Eq, Show) 54 | 55 | -- | Run the CI build step. 56 | -- 57 | -- The specific command and its options can be passed as command line 58 | -- arguments. See module 'BuildArgs'. 59 | doBuild 60 | :: LibraryName 61 | -> Optimizations 62 | -> ShouldUploadCoverage 63 | -> [TestRun] 64 | -> CoverallsConfig 65 | -> Timeout 66 | -> IO () 67 | doBuild (LibraryName whichLibrary) 68 | optimizations 69 | (ShouldUploadCoverage shouldUploadCoverage) 70 | testRuns 71 | coverallsConfig 72 | testsTimeout = do 73 | BuildArgs {options, command} <- 74 | parseArgs $ "Build " ++ whichLibrary ++ " with stack in Buildkite" 75 | let RebuildOpts { optBuildDirectory, optCacheDirectory, optDryRun } = options 76 | optBuildkiteEnv <- getBuildkiteEnv 77 | cacheConfig <- getCacheConfig optBuildkiteEnv optCacheDirectory 78 | case command of 79 | Build -> do 80 | doMaybe (setupBuildDirectory optDryRun) optBuildDirectory 81 | whenRun optDryRun $ do 82 | cacheGetStep cacheConfig 83 | cleanBuildDirectory (fromMaybe "." optBuildDirectory) 84 | buildResult <- buildStep optDryRun optimizations optBuildkiteEnv testRuns testsTimeout 85 | when (shouldUploadCoverage optBuildkiteEnv) $ 86 | uploadCoverageStep coverallsConfig optDryRun 87 | whenRun optDryRun $ cachePutStep cacheConfig 88 | void $ weederStep optDryRun 89 | exitWith buildResult 90 | CleanupCache -> 91 | cleanupCacheStep optDryRun cacheConfig optBuildDirectory 92 | PurgeCache -> 93 | purgeCacheStep optDryRun cacheConfig optBuildDirectory 94 | 95 | newtype LibraryName = LibraryName String deriving Show 96 | 97 | data Optimizations = Standard | Fast deriving (Show, Eq) 98 | 99 | -- | Function to determine whether coverage information should be uploaded. 100 | -- This might depend in the Buildkite environment. 101 | newtype ShouldUploadCoverage = ShouldUploadCoverage (Maybe BuildkiteEnv -> Bool) 102 | 103 | uploadCoverageIfBors :: ShouldUploadCoverage 104 | uploadCoverageIfBors = ShouldUploadCoverage $ maybe False isBorsBuild 105 | 106 | newtype TestRun = TestRun 107 | { stackTestArgs :: StackExtraTestArgs 108 | } 109 | 110 | -- | Extra arguments for @stack test@ 111 | newtype StackExtraTestArgs = StackExtraTestArgs (Maybe BuildkiteEnv -> [Text]) 112 | 113 | buildStep 114 | :: DryRun 115 | -> Optimizations 116 | -> Maybe BuildkiteEnv 117 | -> [TestRun] 118 | -- ^ Used to specify different arguments for different test runs. 119 | -> Timeout 120 | -- ^ Test timeout. 121 | -> IO ExitCode 122 | buildStep dryRun optimizations optBuildkiteEnv testRuns (Timeout testTimeout)= 123 | echo "--- Build LTS Snapshot" 124 | *> build Standard ["--only-snapshot"] .&&. 125 | echo "--- Build dependencies" 126 | *> build Standard ["--only-dependencies"] .&&. 127 | echo "+++ Build" 128 | *> build optimizations ["--test", "--no-run-tests"] .&&. 129 | echo "+++ Test" 130 | *> foldr (.&&.) (pure ExitSuccess) (timeout testTimeout . test <$> testRuns) 131 | where 132 | build optimizations' args = 133 | run dryRun "stack" $ concat 134 | [ color "always" 135 | , [ "build" ] 136 | , [ "--pedantic" ] 137 | , [ "--bench" ] 138 | , [ "--no-run-benchmarks" ] 139 | , [ "--coverage" ] 140 | , shouldUseFast optimizations' 141 | , args 142 | ] 143 | 144 | test (TestRun (StackExtraTestArgs mkTestArgs)) 145 | = run dryRun "stack" 146 | $ concat 147 | [ color "always" 148 | , [ "test" ] 149 | , [ "--pedantic" ] 150 | , [ "--coverage" ] 151 | , shouldUseFast optimizations 152 | , mkTestArgs optBuildkiteEnv 153 | ] 154 | 155 | color arg = ["--color", arg] 156 | shouldUseFast arg = case arg of Standard -> []; Fast -> ["--fast"] 157 | -------------------------------------------------------------------------------- /overlays/haskell-nix-extra/utils/lib/BuildArgs.hs: -------------------------------------------------------------------------------- 1 | -- | Build arguments for the CI build program. 2 | 3 | module BuildArgs 4 | ( BuildArgs (BuildArgs, options, command) 5 | , RebuildOpts (RebuildOpts, optBuildDirectory, optCacheDirectory, optDryRun) 6 | , Command (Build, CleanupCache, PurgeCache) 7 | -- * Command line parsing 8 | , parseArgs 9 | ) 10 | where 11 | 12 | import Prelude hiding 13 | ( FilePath ) 14 | 15 | import qualified Filesystem.Path.CurrentOS as FP 16 | import Options.Applicative 17 | ( Parser 18 | , execParser 19 | , flag 20 | , fullDesc 21 | , help 22 | , helper 23 | , idm 24 | , info 25 | , long 26 | , metavar 27 | , option 28 | , optional 29 | , progDesc 30 | , str 31 | , subparser 32 | , (<**>) 33 | , (<|>) 34 | ) 35 | import qualified Options.Applicative as Opts 36 | 37 | import CommonBuild 38 | ( DryRun (DryRun, Run), FilePath ) 39 | 40 | 41 | data BuildArgs = BuildArgs 42 | { options :: RebuildOpts 43 | , command :: Command 44 | } deriving (Show) 45 | 46 | data RebuildOpts = RebuildOpts 47 | { optBuildDirectory :: Maybe FilePath 48 | , optCacheDirectory :: Maybe FilePath 49 | , optDryRun :: DryRun 50 | } deriving (Show) 51 | 52 | data Command = Build | CleanupCache | PurgeCache deriving (Show) 53 | 54 | -------------------------------------------------------------------------------- 55 | -- Command line parsing 56 | 57 | parseArgs :: String -> IO BuildArgs 58 | parseArgs programDescription = execParser opts 59 | where 60 | opts = info 61 | (cmdOpts <**> helper) 62 | (fullDesc <> progDesc programDescription) 63 | cmdOpts = BuildArgs 64 | <$> rebuildOpts 65 | <*> (cmd <|> pure Build) 66 | cmd = subparser 67 | ( Opts.command "build" (info (pure Build) idm) 68 | <> Opts.command "cleanup-cache" (info (pure CleanupCache) idm) 69 | <> Opts.command "purge-cache" (info (pure PurgeCache) idm) 70 | ) 71 | 72 | rebuildOpts :: Parser RebuildOpts 73 | rebuildOpts = RebuildOpts 74 | <$> optional buildDir 75 | <*> optional cacheName 76 | <*> dryRun 77 | where 78 | buildDir = option 79 | (FP.decodeString <$> str) 80 | ( long "build-dir" 81 | <> metavar "DIR" 82 | <> help "Copy sources to directory before building" 83 | ) 84 | cacheName = option 85 | (FP.decodeString <$> str) 86 | ( long "cache-dir" 87 | <> metavar "DIR" 88 | <> help "Location of project's cache" 89 | ) 90 | dryRun = flag Run DryRun 91 | ( long "dry-run" 92 | <> help "Print what build commands would be run, without executing them" 93 | ) 94 | -------------------------------------------------------------------------------- /overlays/haskell-nix-extra/utils/rewrite-libs.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | {-# LANGUAGE LambdaCase #-} 3 | {-# LANGUAGE CPP #-} 4 | 5 | -- | Given a binary file on MacOS, rewrite some of the dynamic 6 | -- libraries to relative paths. 7 | -- 8 | -- 1. Crawl through the tree of libraries 9 | -- 2. filter only for libraries not core to MacOS 10 | -- 3. copy the library to global relative folder 11 | -- 4. set the new library path for all references 12 | -- 5. test that --help executes on the binary 13 | -- 14 | -- This program is originally from the Daedalus installer generator. 15 | 16 | module Main where 17 | 18 | import System.Directory (copyFile, getPermissions, setOwnerWritable, setPermissions) 19 | import Text.Megaparsec (Parsec, eof, manyTill, parse, someTill) 20 | import Text.Megaparsec.Char (eol, spaceChar) 21 | import Turtle (procStrict, procs) 22 | import qualified Data.Text as T 23 | import Data.Text (Text) 24 | import Data.Void (Void) 25 | import Control.Applicative (many) 26 | import Data.Maybe (catMaybes) 27 | import System.Exit (die, exitFailure, exitSuccess) 28 | import System.Environment (getArgs) 29 | 30 | #if MIN_VERSION_megaparsec(7,0,0) 31 | import Text.Megaparsec (anySingle) 32 | #else 33 | import Text.Megaparsec.Char (anyChar) 34 | anySingle = anyChar 35 | #endif 36 | 37 | -- Rewrite libs paths and bundle them 38 | main :: IO () 39 | main = do 40 | (outDir, progs) <- parseArgs 41 | _res <- chain outDir (map T.pack progs) 42 | pure () 43 | 44 | parseArgs :: IO (FilePath, [FilePath]) 45 | parseArgs = getArgs >>= \case 46 | (outDir:prog:progs) -> pure (outDir, (prog:progs)) 47 | _ -> die "usage: rewrite-libs OUTDIR PROG [PROGS...]" >> exitFailure 48 | 49 | systemLibs :: [Text] 50 | systemLibs = ["libSystem.B.dylib"] 51 | 52 | -- dir: final path of the files 53 | -- args: libraries to process 54 | -- returns processed libraries 55 | chain :: FilePath -> [Text] -> IO [Text] 56 | chain dir args@(x:xs) = do 57 | (_, output) <- procStrict "otool" ["-L", x] mempty 58 | case (parse parseOTool (T.unpack x) output) of 59 | Left err -> do 60 | print err 61 | return [] 62 | Right files -> do 63 | -- parse again all libraries pointing to nix store that we haven't processed yet 64 | let libs = filter (T.isPrefixOf "/nix/store/") files 65 | filtered <- traverse (patchLib x dir) libs 66 | chained <- chain dir (xs ++ (filter (\f -> not $ elem f args) $ catMaybes filtered)) 67 | return $ x : chained 68 | chain _ [] = return [] 69 | 70 | 71 | patchLib :: Text -> FilePath -> Text -> IO (Maybe Text) 72 | patchLib source dir lib 73 | | (filter (\pattern -> T.isSuffixOf pattern lib) systemLibs) /= mempty = do 74 | -- if it's a system lib, just point to correct folder and be done 75 | print $ "Patching " <> lib <> " as system in " <> source 76 | procs "install_name_tool" ["-change", lib, "/usr/lib/" <> (filename lib), (T.pack dir) <> "/" <> (filename source)] mempty 77 | return Nothing 78 | | otherwise = do 79 | -- otherwise, copy it to dist and change where it points 80 | print $ "Bundling " <> lib <> " in " <> source 81 | -- substitute store path if they are missing 82 | procs "nix-store" ["-r", lib] mempty 83 | procs "install_name_tool" ["-change", lib, "@executable_path/" <> (filename lib), (T.pack dir) <> "/" <> (filename source)] mempty 84 | let dest = dir <> "/" <> (T.unpack $ filename lib) 85 | copyFile (T.unpack lib) dest 86 | permissions <- getPermissions dest 87 | setPermissions dest $ setOwnerWritable True permissions 88 | return $ Just lib 89 | 90 | filename :: Text -> Text 91 | filename path = last $ T.splitOn "/" path 92 | 93 | -- otool parser 94 | 95 | type Parser = Parsec Void Text 96 | 97 | parseLibLine :: Parser Text 98 | parseLibLine = do 99 | _ <- many spaceChar 100 | path <- someTill anySingle spaceChar 101 | _ <- someTill anySingle eol 102 | return (T.pack path) 103 | 104 | 105 | parseOTool :: Parser [Text] 106 | parseOTool = do 107 | _ <- manyTill anySingle eol 108 | manyTill parseLibLine eof 109 | -------------------------------------------------------------------------------- /overlays/haskell-nix-extra/utils/set-git-rev.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase #-} 2 | {-# LANGUAGE OverloadedStrings #-} 3 | 4 | -- | Stamps a Haskell executable with a git revision. 5 | -- The target executable must have use "Data.FileEmbed.dummySpace". 6 | -- 7 | -- This progam is originally from cardano-sl. 8 | 9 | module Main where 10 | 11 | import Control.DeepSeq (force) 12 | import Control.Exception (ErrorCall (..), handle, evaluate) 13 | import Data.ByteString (ByteString) 14 | import qualified Data.ByteString.Char8 as B8 15 | import Data.FileEmbed (injectWith) 16 | import Data.List (isInfixOf) 17 | import System.Exit (die, exitFailure, exitSuccess) 18 | import System.Environment (getArgs) 19 | 20 | main :: IO () 21 | main = do 22 | (hash, progs) <- parseArgs 23 | mapM_ (setGitRev hash) progs 24 | 25 | setGitRev :: ByteString -> FilePath -> IO () 26 | setGitRev hash prog = do 27 | putStr $ "Setting gitrev of " <> prog <> " ... " 28 | bs <- B8.readFile prog 29 | injectWith' "gitrev" hash bs >>= \case 30 | Right bs' -> do 31 | B8.writeFile prog bs' 32 | B8.putStrLn "OK" 33 | exitSuccess 34 | Left "" -> do 35 | B8.putStrLn $ "Failed setting gitrev to \"" <> hash <> "\"" 36 | exitFailure 37 | Left msg | "Size is: \"\"" `isInfixOf` msg -> do 38 | -- Ignore programs without a gitrev injected 39 | B8.putStrLn "File does not have dummySpace." 40 | exitSuccess 41 | Left msg -> do 42 | putStrLn msg 43 | exitFailure 44 | 45 | -- | Work around annoying use of error function in file-embed. 46 | injectWith' :: ByteString -> ByteString -> ByteString -> IO (Either String ByteString) 47 | injectWith' postfix toInj orig = handle (pure . toLeft) (toRight <$> evaluateNF inj) 48 | where 49 | inj = injectWith postfix toInj orig 50 | toRight (Just a) = Right a 51 | toRight Nothing = Left "" 52 | toLeft (ErrorCall msg) = Left msg 53 | evaluateNF = evaluate . force 54 | 55 | parseArgs :: IO (ByteString, [FilePath]) 56 | parseArgs = getArgs >>= \case 57 | (rev:prog:progs) -> pure (B8.pack rev, (prog:progs)) 58 | _ -> die "usage: set-git-rev REV PROG [PROGS...]" >> exitFailure 59 | -------------------------------------------------------------------------------- /overlays/haskell-nix-extra/utils/stack.yaml: -------------------------------------------------------------------------------- 1 | resolver: lts-13.24 2 | compiler: ghc-8.6.5 3 | 4 | packages: 5 | - . 6 | 7 | # extra-deps: 8 | -------------------------------------------------------------------------------- /overlays/rust/cardano-cli.nix: -------------------------------------------------------------------------------- 1 | { rustPlatform 2 | , fetchFromGitHub 3 | , sqlite 4 | , protobuf 5 | , pkgconfig 6 | , openssl 7 | , ... }: 8 | 9 | rustPlatform.buildRustPackage rec { 10 | version = "0.0"; 11 | name = "cardano-cli-${version}"; 12 | src = fetchFromGitHub { 13 | owner = "input-output-hk"; 14 | repo = "cardano-cli"; 15 | rev = "ed064d5a3b96c23b52bb20ca49da9cb8764a2e0f"; 16 | sha256 = "07y5ssar6aq93snrvmapk05zmym4w23ydvjn2njp8saxk23ivqsg"; 17 | fetchSubmodules = true; 18 | }; 19 | 20 | cargoSha256 = "1jra0635inm95xp7vg8l7s7ybijcy28956cd6jl8qw2p8bw0z1p3"; 21 | buildInputs = [ protobuf ]; 22 | PROTOC = "${protobuf}/bin/protoc"; 23 | # workaround https://github.com/NixOS/nixpkgs/issues/61618 24 | preConfigure = '' 25 | export HOME=`mktemp -d` 26 | ''; 27 | } 28 | -------------------------------------------------------------------------------- /overlays/rust/cardano-http-bridge-emurgo.nix: -------------------------------------------------------------------------------- 1 | { rustPlatform 2 | , fetchFromGitHub 3 | , sqlite 4 | , protobuf 5 | , pkgconfig 6 | , openssl 7 | , stdenv 8 | , darwin 9 | , ... }: 10 | 11 | let 12 | Security = darwin.apple_sdk.frameworks.Security; 13 | in rustPlatform.buildRustPackage rec { 14 | version = "0.0"; 15 | name = "cardano-http-bridge-${version}"; 16 | src = fetchFromGitHub { 17 | owner = "Emurgo"; 18 | repo = "cardano-http-bridge"; 19 | rev = "cd7fa514e8c17879663c41a046cb6bd51e6b18d0"; 20 | sha256 = "1s7p1jy63myahkm90y2kgxik8kv311f6prwdsl8p3arjh5vg85x3"; 21 | fetchSubmodules = true; 22 | }; 23 | 24 | cargoSha256 = "0sr9mzw9d5j86f7j7y2hdaxdrl3jm4dyzmbhpxjb8x6nf1bi10an"; 25 | buildInputs = [ protobuf ] ++ stdenv.lib.optional stdenv.isDarwin Security; 26 | PROTOC = "${protobuf}/bin/protoc"; 27 | # workaround https://github.com/NixOS/nixpkgs/issues/61618 28 | preConfigure = '' 29 | export HOME=`mktemp -d` 30 | ''; 31 | } 32 | -------------------------------------------------------------------------------- /overlays/rust/cardano-http-bridge.nix: -------------------------------------------------------------------------------- 1 | { rustPlatform 2 | , fetchFromGitHub 3 | , sqlite 4 | , protobuf 5 | , pkgconfig 6 | , openssl 7 | , stdenv 8 | , darwin 9 | , ... }: 10 | 11 | let 12 | Security = darwin.apple_sdk.frameworks.Security; 13 | in rustPlatform.buildRustPackage rec { 14 | version = "0.0"; 15 | name = "cardano-http-bridge-${version}"; 16 | src = fetchFromGitHub { 17 | owner = "input-output-hk"; 18 | repo = "cardano-http-bridge"; 19 | rev = "31cd4d48b3b65ef8d2d10c493a1191535b785923"; 20 | sha256 = "0xfbqaj9ksfx704pb65pccalhfx2p2z2lg4rsg12n58g3ih449k3"; 21 | fetchSubmodules = true; 22 | }; 23 | 24 | cargoSha256 = "07l3gbqzgv29zxpv7rmq1wkkyi3yw3w7j10bf0ws8fv92k9j922x"; 25 | buildInputs = [ protobuf ] ++ stdenv.lib.optional stdenv.isDarwin Security; 26 | PROTOC = "${protobuf}/bin/protoc"; 27 | # workaround https://github.com/NixOS/nixpkgs/issues/61618 28 | preConfigure = '' 29 | export HOME=`mktemp -d` 30 | ''; 31 | } 32 | -------------------------------------------------------------------------------- /overlays/rust/default.nix: -------------------------------------------------------------------------------- 1 | self: super: let 2 | # bump mozilla-nixpkgs rev and run: 3 | # curl https://static.rust-lang.org/dist/channel-rust-stable.toml -o overlays/rust/channel-rust-stable.toml 4 | # to bump the rust stable version to latest 5 | stableChannelToml = ./channel-rust-stable.toml; 6 | stableChannel = super.lib.rustLib.fromManifestFile stableChannelToml { 7 | inherit (super) stdenv fetchurl patchelf; 8 | }; 9 | 10 | in { 11 | rust.packages.stable.rustc = stableChannel.rust; 12 | rust.packages.stable.cargo = stableChannel.cargo; 13 | rustPlatform = super.recurseIntoAttrs (super.rust.makeRustPlatform { 14 | rustc = stableChannel.rust; 15 | cargo = stableChannel.cargo; 16 | }); 17 | makeJormungandr = (super.pkgs.callPackage ./jormungandr.nix {}).makeJormungandr; 18 | makeJcli = (super.pkgs.callPackage ./jormungandr.nix {}).makeJcli; 19 | makeJormungandr-debug = (super.pkgs.callPackage ./jormungandr.nix { buildType = "debug"; }).makeJormungandr; 20 | makeJcli-debug = (super.pkgs.callPackage ./jormungandr.nix { buildType = "debug"; }).makeJcli; 21 | cardano-http-bridge = super.pkgs.callPackage ./cardano-http-bridge.nix {}; 22 | cardano-http-bridge-emurgo = super.pkgs.callPackage ./cardano-http-bridge-emurgo.nix {}; 23 | cardano-cli = super.pkgs.callPackage ./cardano-cli.nix {}; 24 | } 25 | -------------------------------------------------------------------------------- /overlays/rust/jormungandr.nix: -------------------------------------------------------------------------------- 1 | { rustPlatform 2 | , lib 3 | , stdenv 4 | , fetchFromGitHub 5 | , sqlite 6 | , protobuf 7 | , pkgconfig 8 | , openssl 9 | , systemd 10 | , darwin 11 | , rustup 12 | , rustc 13 | , cargo 14 | , rustfmt 15 | , callPackage 16 | , buildPackages 17 | , buildType ? "release" 18 | , ... }@args: 19 | let 20 | fetchSrc = { name, rev, sha256 }: 21 | fetchFromGitHub { 22 | owner = "input-output-hk"; 23 | repo = "jormungandr"; 24 | inherit name rev sha256; 25 | fetchSubmodules = true; 26 | }; 27 | 28 | Security = darwin.apple_sdk.frameworks.Security; 29 | 30 | ccForBuild="${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc"; 31 | cxxForBuild="${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}c++"; 32 | ccForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; 33 | cxxForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"; 34 | releaseDir = "target/${stdenv.hostPlatform.config}/${buildType}"; 35 | 36 | buildPhaseFn = cargoBuildFlags: with builtins; args.buildPhase or '' 37 | runHook preBuild 38 | ( 39 | set -x 40 | env \ 41 | "CC_${stdenv.buildPlatform.config}"="${ccForBuild}" \ 42 | "CXX_${stdenv.buildPlatform.config}"="${cxxForBuild}" \ 43 | "CC_${stdenv.hostPlatform.config}"="${ccForHost}" \ 44 | "CXX_${stdenv.hostPlatform.config}"="${cxxForHost}" \ 45 | cargo build \ 46 | ${lib.optionalString (buildType == "release") "--release"} --target ${stdenv.hostPlatform.config} \ 47 | --frozen ${concatStringsSep " " cargoBuildFlags} 48 | ) 49 | # rename the output dir to a architecture independent one 50 | mapfile -t targets < <(find "$NIX_BUILD_TOP" -type d | grep '${releaseDir}$') 51 | for target in "''${targets[@]}"; do 52 | rm -rf "$target/../../${buildType}" 53 | ln -srf "$target" "$target/../../" 54 | done 55 | runHook postBuild 56 | ''; 57 | 58 | commitHash = commit: '' 59 | GITPATH=$(echo $PATH | tr ':' "\n" | grep git) 60 | cat << EOF > git 61 | #!${stdenv.shell} 62 | case "\$*" in 63 | "rev-parse --short HEAD") echo -n "${commit}" | cut -c -7 | tr -d "\n";; 64 | "rev-parse --abbrev-ref HEAD") echo -n "nix-build" ;; 65 | "diff --quiet --exit-code HEAD") true ;; 66 | *) ''${GITPATH}/git "\$@" ;; 67 | esac; 68 | EOF 69 | chmod +x git 70 | export PATH="$(echo $PATH | tr ':' "\n" | grep -v git | tr "\n" ":")$(pwd)" 71 | ''; 72 | 73 | makeJormungandr = { version, rev ? "v${version}", sha256, cargoSha256, name ? "jormungandr-${version}" }: 74 | rustPlatform.buildRustPackage rec { 75 | inherit name version buildType; 76 | src = fetchSrc { 77 | name = "${name}-source"; 78 | inherit rev sha256; 79 | }; 80 | inherit cargoSha256; 81 | nativeBuildInputs = [ pkgconfig ]; 82 | buildInputs = [ sqlite protobuf openssl ] 83 | ++ lib.optional stdenv.isDarwin Security 84 | ++ lib.optional stdenv.isLinux systemd; 85 | preBuild = '' 86 | ${commitHash rev} 87 | echo -e "\n[profile.dev]" >> Cargo.toml 88 | echo "opt-level = 3" >> Cargo.toml 89 | cd jormungandr 90 | ''; 91 | buildPhase = buildPhaseFn cargoBuildFlags; 92 | preInstall = "cd .."; 93 | cargoBuildFlags = ["--features \"gelf"] ++ lib.optional stdenv.isLinux "systemd" ++ ["\""]; 94 | PROTOC = "${protobuf}/bin/protoc"; 95 | # workaround https://github.com/NixOS/nixpkgs/issues/61618 96 | preConfigure = '' 97 | export HOME=`mktemp -d` 98 | ''; 99 | passthru = { inherit src; }; 100 | }; 101 | 102 | makeJcli = { version, rev ? "v${version}", sha256, cargoSha256, name ? "jormungandr-cli-${version}" }: 103 | rustPlatform.buildRustPackage rec { 104 | inherit name version buildType; 105 | src = fetchSrc { 106 | name = "${name}-source"; 107 | inherit rev sha256; 108 | }; 109 | 110 | inherit cargoSha256; 111 | nativeBuildInputs = [ pkgconfig ]; 112 | buildInputs = [ sqlite protobuf openssl ] 113 | ++ lib.optional stdenv.isDarwin Security 114 | ++ lib.optional stdenv.isLinux systemd; 115 | preBuild = '' 116 | ${commitHash rev} 117 | echo -e "\n[profile.dev]" >> Cargo.toml 118 | echo "opt-level = 0" >> Cargo.toml 119 | cd jcli 120 | ''; 121 | buildPhase = buildPhaseFn cargoBuildFlags; 122 | preInstall = "cd .."; 123 | postInstall = '' 124 | mkdir $out/scripts 125 | cp scripts/* $out/scripts/ 126 | ''; 127 | cargoBuildFlags = []; 128 | PROTOC = "${protobuf}/bin/protoc"; 129 | # workaround https://github.com/NixOS/nixpkgs/issues/61618 130 | preConfigure = '' 131 | export HOME=`mktemp -d` 132 | ''; 133 | passthru = { inherit src; }; 134 | }; 135 | 136 | in { 137 | inherit makeJormungandr makeJcli; 138 | } 139 | -------------------------------------------------------------------------------- /overlays/rust/mozilla.nix: -------------------------------------------------------------------------------- 1 | { fetchFromGitHub }: 2 | let 3 | rustOverlay = fetchFromGitHub { 4 | owner = "mozilla"; 5 | repo = "nixpkgs-mozilla"; 6 | rev = "5300241b41243cb8962fad284f0004afad187dad"; 7 | sha256 = "1h3g3817anicwa9705npssvkwhi876zijyyvv4c86qiklrkn5j9w"; 8 | }; 9 | in 10 | import (rustOverlay + "/rust-overlay.nix") 11 | -------------------------------------------------------------------------------- /overlays/rust/patches/0001-update-Cargo.lock.patch: -------------------------------------------------------------------------------- 1 | From cc02cc30c89f01fd807a4cb997a85744e228e829 Mon Sep 17 00:00:00 2001 2 | From: Vincent Hanquez 3 | Date: Fri, 21 Jun 2019 16:08:37 +0100 4 | Subject: [PATCH] update Cargo.lock 5 | 6 | --- 7 | Cargo.lock | 22 +++++++++++----------- 8 | 1 file changed, 11 insertions(+), 11 deletions(-) 9 | 10 | diff --git a/Cargo.lock b/Cargo.lock 11 | index 746d5fdf..5159e77f 100644 12 | --- a/Cargo.lock 13 | +++ b/Cargo.lock 14 | @@ -1200,7 +1200,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" 15 | 16 | [[package]] 17 | name = "jcli" 18 | -version = "0.2.1" 19 | +version = "0.2.2" 20 | dependencies = [ 21 | "actix-net 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", 22 | "actix-web 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)", 23 | @@ -1228,7 +1228,7 @@ dependencies = [ 24 | "hex 0.1.0", 25 | "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", 26 | "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 27 | - "jormungandr-utils 0.2.0", 28 | + "jormungandr-utils 0.2.2", 29 | "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 30 | "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", 31 | "mktemp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 32 | @@ -1259,7 +1259,7 @@ dependencies = [ 33 | 34 | [[package]] 35 | name = "jormungandr" 36 | -version = "0.2.1" 37 | +version = "0.2.2" 38 | dependencies = [ 39 | "actix-net 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", 40 | "actix-web 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)", 41 | @@ -1288,8 +1288,8 @@ dependencies = [ 42 | "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", 43 | "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 44 | "hyper 0.12.29 (registry+https://github.com/rust-lang/crates.io-index)", 45 | - "jormungandr-lib 0.1.0", 46 | - "jormungandr-utils 0.2.0", 47 | + "jormungandr-lib 0.2.2", 48 | + "jormungandr-utils 0.2.2", 49 | "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 50 | "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", 51 | "mktemp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 52 | @@ -1321,7 +1321,7 @@ dependencies = [ 53 | 54 | [[package]] 55 | name = "jormungandr-integration-tests" 56 | -version = "0.2.1" 57 | +version = "0.2.2" 58 | dependencies = [ 59 | "assert_cmd 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", 60 | "assert_fs 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", 61 | @@ -1329,9 +1329,9 @@ dependencies = [ 62 | "chain-crypto 0.1.0", 63 | "custom_error 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 64 | "galvanic-test 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 65 | - "jcli 0.2.1", 66 | - "jormungandr 0.2.1", 67 | - "jormungandr-lib 0.1.0", 68 | + "jcli 0.2.2", 69 | + "jormungandr 0.2.2", 70 | + "jormungandr-lib 0.2.2", 71 | "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 72 | "mktemp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 73 | "quickcheck 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", 74 | @@ -1346,7 +1346,7 @@ dependencies = [ 75 | 76 | [[package]] 77 | name = "jormungandr-lib" 78 | -version = "0.1.0" 79 | +version = "0.2.2" 80 | dependencies = [ 81 | "bech32 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 82 | "bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", 83 | @@ -1365,7 +1365,7 @@ dependencies = [ 84 | 85 | [[package]] 86 | name = "jormungandr-utils" 87 | -version = "0.2.0" 88 | +version = "0.2.2" 89 | dependencies = [ 90 | "bech32 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 91 | "chain-addr 0.1.0", 92 | -- 93 | 2.19.2 94 | 95 | -------------------------------------------------------------------------------- /overlays/utils/default.nix: -------------------------------------------------------------------------------- 1 | final: prev: let 2 | inherit (final) system git nixFlakes cabal writeShellScriptBin; 3 | in { 4 | nixWrapped = writeShellScriptBin "nix" '' 5 | find_up() { 6 | while [[ $PWD != / ]] ; do 7 | if [[ -e "$1" ]]; then 8 | echo "$PWD" 9 | return 10 | fi 11 | if [[ -e "nix/$1" ]]; then 12 | echo "$PWD/nix" 13 | return 14 | fi 15 | cd .. 16 | done 17 | } 18 | if [[ "$@" == *"flake"*" "*"show"* ]] || [[ "$@" == *"flake"*" "*"check"* ]]; then 19 | >&2 echo 'Temporary override `supported-systems.nix` original content to be able to use `nix flake show|check` on dev machines (workaround for https://github.com/NixOS/nix/issues/4265)' 20 | nixdir=$(find_up "supported-systems.nix") 21 | SYSTEMS="$nixdir/supported-systems.nix" 22 | BACKUP="$(mktemp)" 23 | mv "$SYSTEMS" "$BACKUP" 24 | echo '[ "${system}" ]' > "$SYSTEMS" 25 | function atexit() { 26 | mv "$BACKUP" "$SYSTEMS" 27 | } 28 | trap atexit EXIT 29 | fi 30 | GC_DONT_GC=1 ${nixFlakes}/bin/nix --experimental-features "nix-command flakes" "$@" 31 | ''; 32 | cabalWrapped = writeShellScriptBin "cabal" '' 33 | set -euo pipefail 34 | 35 | find_up() { 36 | while [[ $PWD != / ]] ; do 37 | if [[ -e "$1" ]]; then 38 | echo "$PWD" 39 | return 40 | fi 41 | cd .. 42 | done 43 | } 44 | 45 | toplevel=$(find_up "cabal.project") 46 | 47 | if [[ -n "$toplevel" ]]; then 48 | cabal_project="$toplevel/cabal.project" 49 | nix_shell_cabal_project=$toplevel/.nix-shell-cabal.project 50 | extra_cabal_opts=("--project-file=$nix_shell_cabal_project") 51 | awk ' 52 | # Add comment with explanation of file 53 | BEGIN { 54 | print "-- Generated from '"$cabal_project"' by the wrapper script" 55 | print "-- ${placeholder "out"}" 56 | print "-- Add this file to your .gitignore\n" 57 | } 58 | 59 | # Matches all section starts 60 | /^[^ ]/ { 61 | # Remember the section name (they can span multiple lines) 62 | section = $0 63 | } 64 | # Matches every line 65 | // { 66 | # Only print the line if it is not in the section we want to omit 67 | if (section != "source-repository-package") 68 | print $0 69 | } 70 | ' "$cabal_project" > "$nix_shell_cabal_project" 71 | else 72 | extra_cabal_opts=() 73 | fi 74 | 75 | cabal=${final.cabal or final.cabal-install}/bin/cabal 76 | >&2 echo "$cabal ''${extra_cabal_opts[@]} $@" 77 | exec "$cabal" "''${extra_cabal_opts[@]}" "$@" 78 | ''; 79 | 80 | fourmoluCheck = ../../tests/fourmolu.nix; 81 | hlintCheck = ../../tests/hlint.nix; 82 | shellCheck = ../../tests/shellcheck.nix; 83 | stylishHaskellCheck = ../../tests/stylish-haskell.nix; 84 | 85 | checkStackProject = final.callPackage ../../ci/check-stack-project.nix { }; 86 | sha256map-regenerate = final.callPackage ../../ci/sha256map-regenerate { }; 87 | inherit (final.callPackages ../../ci/cabal-project-regenerate {}) cabalProjectRegenerate checkCabalProject; 88 | 89 | } 90 | -------------------------------------------------------------------------------- /pkgs/cabal-wrapper.nix: -------------------------------------------------------------------------------- 1 | { runCommand 2 | , runtimeShell 3 | , cabal-install 4 | }: 5 | runCommand "cabal" { inherit (cabal-install) meta; } '' 6 | mkdir -p $out/bin 7 | cat << EOF > $out/bin/cabal 8 | #!${runtimeShell} 9 | set -euo pipefail 10 | 11 | find_up() { 12 | while [[ \$PWD != / ]] ; do 13 | if [[ -e "\$1" ]]; then 14 | echo "\$PWD" 15 | return 16 | fi 17 | cd .. 18 | done 19 | } 20 | 21 | toplevel=\$(find_up "cabal.project") 22 | 23 | if [[ -n "\$toplevel" ]]; then 24 | cabal_project="\$toplevel/cabal.project" 25 | nix_cabal_project=\$toplevel/.nix-cabal.project 26 | extra_cabal_opts=("--project-file=\$nix_cabal_project") 27 | awk ' 28 | # Add comment with explanation of file 29 | BEGIN { 30 | print "-- Generated from '"\$cabal_project"' by the wrapper script" 31 | print "-- ${placeholder "out"}/cabal" 32 | print "-- Add this file to your .gitignore\n" 33 | } 34 | 35 | # Matches all section starts 36 | /^[^ ]/ { 37 | # Remember the section name (they can span multiple lines) 38 | section = \$0 39 | } 40 | # Matches every line 41 | // { 42 | # Only print the line if it is not in the section we want to omit 43 | if (section != "source-repository-package") 44 | print \$0 45 | } 46 | ' "\$cabal_project" > "\$nix_cabal_project" 47 | else 48 | extra_cabal_opts=() 49 | fi 50 | 51 | cabal=${placeholder "out"}/bin/.cabal 52 | >&2 echo "\$cabal \''${extra_cabal_opts[@]} \$@" 53 | exec "\$cabal" "\''${extra_cabal_opts[@]}" "\$@" 54 | EOF 55 | cp -rn ${cabal-install}/* $out/ 56 | cp ${cabal-install}/bin/cabal $out/bin/.cabal 57 | chmod +x $out/bin/* 58 | '' 59 | -------------------------------------------------------------------------------- /pkgs/stack-cabal-sync-shell.nix: -------------------------------------------------------------------------------- 1 | { stdenv, cardano-repo-tool }: 2 | 3 | stdenv.mkDerivation { 4 | name = "stack-cabal-sync-shell"; 5 | buildInputs = [ cardano-repo-tool ]; 6 | shellHook = '' 7 | for EXE in cardano-repo-tool; do 8 | source <($EXE --bash-completion-script `type -p $EXE`) 9 | done 10 | ''; 11 | phases = ["nobuildPhase"]; 12 | nobuildPhase = "mkdir -p $out"; 13 | } 14 | -------------------------------------------------------------------------------- /release.nix: -------------------------------------------------------------------------------- 1 | let commonLib = (import ./. {}); in 2 | { system ? builtins.currentSystem 3 | , config ? {} 4 | , pkgs ? commonLib.getPkgs { inherit system config; } 5 | 6 | # this is passed in by hydra to provide us with the revision 7 | , iohk-nix ? { outPath = ./.; rev = "abcdef"; } 8 | 9 | , scrubJobs ? true 10 | , supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ] 11 | , nixpkgsArgs ? { 12 | config = config // { allowUnfree = false; inHydra = true; }; 13 | } 14 | }: 15 | 16 | with (import (commonLib.nixpkgs + "/pkgs/top-level/release-lib.nix") { 17 | inherit supportedSystems scrubJobs nixpkgsArgs; 18 | packageSet = import ./.; 19 | }); 20 | 21 | with pkgs.lib; 22 | 23 | let 24 | inherit (commonLib) jormungandrLib cardanoLib; 25 | 26 | jormungandrPackages = foldl' (sum: name: 27 | recursiveUpdate { 28 | jormungandrLib.environments.${name} = { 29 | packages = { 30 | jcli = supportedSystems; 31 | jcli-debug = supportedSystems; 32 | jormungandr = supportedSystems; 33 | jormungandr-debug = supportedSystems; 34 | }; 35 | }; 36 | } sum 37 | ) {} (attrNames jormungandrLib.environments); 38 | 39 | usedJormungandrVersions = flatten (mapAttrsToList (name: env: 40 | with env.packages; [ jcli jcli-debug jormungandr jormungandr-debug ] 41 | ) jormungandrLib.environments); 42 | 43 | jormungandrConfigs = jormungandrLib.forEnvironments jormungandrLib.mkConfigHydra; 44 | 45 | mappedPkgs = mapTestOn ({ 46 | rust-packages.pkgs.cardano-http-bridge = supportedSystems; 47 | haskell-nix-extra-packages.stackNixRegenerate = supportedSystems; 48 | haskell-nix-extra-packages.haskellBuildUtils = supportedSystems; 49 | 50 | # Development tools 51 | } // jormungandrPackages); 52 | 53 | in 54 | fix (self: mappedPkgs // { 55 | inherit (commonLib) check-hydra; 56 | inherit jormungandrConfigs; 57 | jormungandr-deployment = jormungandrLib.mkConfigHtml { inherit (jormungandrLib.environments) itn_rewards_v1 beta nightly legacy; }; 58 | cardano-deployment = cardanoLib.mkConfigHtml { inherit (cardanoLib.environments) mainnet preprod preview; }; 59 | 60 | forceNewEval = pkgs.writeText "forceNewEval" iohk-nix.rev; 61 | required = pkgs.lib.hydraJob (pkgs.releaseTools.aggregate { 62 | name = "required"; 63 | constituents = (with self; [ 64 | self.forceNewEval 65 | rust-packages.pkgs.cardano-http-bridge.x86_64-linux 66 | haskell-nix-extra-packages.stackNixRegenerate.x86_64-linux 67 | haskell-nix-extra-packages.haskellBuildUtils.x86_64-linux 68 | ]) ++ usedJormungandrVersions; 69 | }); 70 | }) 71 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | let 2 | commonLib = import ./. {}; 3 | pkgs = commonLib.pkgs; 4 | shell = pkgs.stdenv.mkDerivation { 5 | name = "shell"; 6 | buildInputs = [ pkgs.niv ]; 7 | shellHook = '' 8 | echo "IOHK NIX" \ 9 | | ${pkgs.figlet}/bin/figlet -f banner -c \ 10 | | ${pkgs.lolcat}/bin/lolcat 11 | 12 | echo "Run niv update to update to latest" 13 | echo "Run niv update to update all packages" 14 | echo "NOTE: you may exceed github requests" 15 | echo "This can be resolved with:" 16 | echo " export GITHUB_TOKEN=" 17 | ''; 18 | }; 19 | in shell 20 | -------------------------------------------------------------------------------- /supervisord/default.nix: -------------------------------------------------------------------------------- 1 | { pkgs, lib }: 2 | 3 | with lib; 4 | let 5 | writeSupervisorConfig = generators.toINI {}; 6 | 7 | in { 8 | inherit writeSupervisorConfig; 9 | } 10 | -------------------------------------------------------------------------------- /tests/fix-stylish-haskell.nix: -------------------------------------------------------------------------------- 1 | { writeScriptBin, git, fd, stylish-haskell }: 2 | 3 | writeScriptBin "fix-stylish-haskell" '' 4 | ${git}/bin/git diff > pre-stylish.diff 5 | ${fd}/bin/fd --extension hs "$@" \ 6 | --exec ${stylish-haskell}/bin/stylish-haskell -i {} 7 | ${git}/bin/git diff > post-stylish.diff 8 | diff pre-stylish.diff post-stylish.diff > /dev/null 9 | if [ $? != 0 ] 10 | then 11 | echo "Changes by stylish have been made. Please commit them." 12 | else 13 | echo "No stylish changes were made." 14 | fi 15 | rm pre-stylish.diff post-stylish.diff 16 | exit 17 | '' 18 | -------------------------------------------------------------------------------- /tests/fourmolu.nix: -------------------------------------------------------------------------------- 1 | { runCommand, fourmolu, src, lib }: 2 | 3 | let 4 | # Remove everything except Haskell sources, fourmolu configuration, and cabal files. 5 | src' = lib.cleanSourceWith { 6 | inherit src; 7 | 8 | filter = with lib; name: type: 9 | let baseName = baseNameOf (toString name); in ( 10 | (type == "regular" && hasSuffix ".hs" baseName) || 11 | (type == "regular" && hasSuffix ".yaml" baseName) || 12 | (type == "regular" && hasSuffix ".cabal" baseName) || 13 | (type == "directory") 14 | ); 15 | }; 16 | in 17 | 18 | runCommand "fourmolu-check" { buildInputs = [ fourmolu ]; } '' 19 | set +e 20 | cd ${src'} 21 | fourmolu --mode check . 22 | EXIT_CODE=$? 23 | 24 | echo $EXIT_CODE > $out 25 | 26 | exit $EXIT_CODE 27 | '' 28 | -------------------------------------------------------------------------------- /tests/hlint.nix: -------------------------------------------------------------------------------- 1 | { runCommand, hlint, src, lib, }: 2 | 3 | let 4 | # just haskell sources and the hlint config file 5 | src' = lib.cleanSourceWith { 6 | inherit src; 7 | filter = with lib; 8 | name: type: let baseName = baseNameOf (toString name); in ( 9 | (type == "regular" && hasSuffix ".hs" baseName) || 10 | (type == "regular" && hasSuffix ".yaml" baseName) || 11 | (type == "directory") 12 | ); 13 | }; 14 | in 15 | runCommand "hlint-check" { buildInputs = [ hlint ]; } '' 16 | set +e 17 | cd ${src'} 18 | hlint . --ignore-glob='dist-newstyle/*' 19 | EXIT_CODE=$? 20 | if [[ $EXIT_CODE != 0 ]] 21 | then 22 | echo '=====================================================================' 23 | echo 'Note: to ignore a particular hint (e.g. "Reduce duplication"), write' 24 | echo 'this in the source file:' 25 | echo '{-# ANN module ("HLint: ignore Reduce duplication" :: Text) #-}' 26 | echo 'You can also apply it just to a particular function, which is better:' 27 | echo '{-# ANN funcName ("HLint: ignore Reduce duplication" :: Text) #-}' 28 | exit $EXIT_CODE 29 | else 30 | echo $EXIT_CODE > $out 31 | fi 32 | '' 33 | -------------------------------------------------------------------------------- /tests/shellcheck.nix: -------------------------------------------------------------------------------- 1 | { runCommand, shellcheck, src, lib }: 2 | 3 | let 4 | # just the shell scripts 5 | src' = lib.cleanSourceWith { 6 | inherit src; 7 | filter = with lib; 8 | name: type: let baseName = baseNameOf (toString name); in ( 9 | (type == "regular" && hasSuffix ".sh" baseName) || 10 | (type == "directory") 11 | ); 12 | }; 13 | in 14 | runCommand "shellcheck" { buildInputs = [ shellcheck ]; } '' 15 | EXIT_STATUS=0 16 | cd ${src'} 17 | while IFS= read -r -d ''' i 18 | do 19 | if shellcheck -x -e 1008 -e 2148 "$i" 20 | then 21 | echo "$i [ PASSED ]" 22 | else 23 | echo "$i [ FAILED ]" 24 | EXIT_STATUS=$(($EXIT_STATUS+1)) 25 | fi 26 | done < <(find -name '*.sh' -print0) 27 | echo $EXIT_STATUS > $out 28 | echo Total Failed Files: $EXIT_STATUS 29 | exit "$EXIT_STATUS" 30 | '' 31 | -------------------------------------------------------------------------------- /tests/stylish-haskell.nix: -------------------------------------------------------------------------------- 1 | { runCommand, stylish-haskell, src, lib, diffutils, glibcLocales }: 2 | 3 | let 4 | # just haskell sources and the stylish-haskell config file 5 | src' = lib.cleanSourceWith { 6 | inherit src; 7 | filter = with lib; 8 | name: type: let baseName = baseNameOf (toString name); in ( 9 | (type == "regular" && hasSuffix ".hs" baseName) || 10 | (type == "regular" && hasSuffix ".yaml" baseName) || 11 | (type == "directory" && (baseName != "docs" && baseName != "dist" && baseName != ".stack-work")) 12 | ); 13 | }; 14 | in 15 | runCommand "stylish-check" { 16 | succeedOnFailure = true; 17 | buildInputs = [ stylish-haskell diffutils glibcLocales ]; 18 | } '' 19 | set +e 20 | cp -a ${src'} orig 21 | cp -a ${src'} stylish 22 | chmod -R +w stylish 23 | cd stylish 24 | find . -type f -name "*hs" -not -name 'HLint.hs' -exec stylish-haskell -i {} \; 25 | cd .. 26 | diff --brief --recursive orig stylish > /dev/null 27 | EXIT_CODE=$? 28 | if [[ $EXIT_CODE != 0 ]] 29 | then 30 | mkdir -p $out/nix-support 31 | diff -ur orig stylish > $out/stylish.diff 32 | echo "file none $out/stylish.diff" > $out/nix-support/hydra-build-products 33 | echo "*** Stylish-haskell found changes that need addressed first" 34 | echo "*** Please run `$(nix-build ./nix -A iohkNix.fixStylishHaskell)/bin/fix-stylish-haskell --exclude '*/dist/*' --exclude '*/docs/*'` and commit changes" 35 | echo "*** or apply the diff generated by hydra if you don't have nix." 36 | exit $EXIT_CODE 37 | else 38 | echo $EXIT_CODE > $out 39 | fi 40 | '' 41 | --------------------------------------------------------------------------------