Skip to content

Commit

Permalink
nix: refatored how shell & tools are provided (#4969)
Browse files Browse the repository at this point in the history
* dependabot: remove misnamed script

We still have `.github/dependabot.yml`.

* nix: refactored how shell & tools are provided

* ouroboros-network-framework: removed unused extensions

* nix: stylish-haskell formatting

* nix: format nix files with nixpkgs-fmt

* formatted nix files with nixpkg-fmt

* nix: format cabal files with cabal-gild

* formated cabal files with cabal-gild

* GHA: removed check-git-dependencies

We no longer use `srp` for dependency management, thus the script is no
longer needed.

* nix: run `cabal check`

* nix: removed formatter field

* tx-submission: fixed a nothunk violation in a test

I made the `getTxSize` field of `Tx` strict.
Ref: https://ci.iog.io/build/5515353/nixlog/1

* nix: ouroboros-network

* Added explicit cabal.project
* Removed `-Werror` flags in nix, they are set in `cabal.project.local`
  files.
* Used `doCheckCross` instead of setting `doCheck` flag per package.

* nix: added profiling shell

```
nix develop .\#profiling
```

It will enter a nix shell with profiling environment for `ghc-9.8`.

* nix: build documentation, formats & shell only on `x86_64-linux`

* nix: removed nsh.sh script

* nix: removed shell.nix file

The only supported way to start one of the provides shells is by using
`nix develop`.

* nix: nix build .\#format.all

Added a convenient way to run all formatters.
  • Loading branch information
coot authored Oct 1, 2024
1 parent faf4c69 commit 2b0fa5b
Show file tree
Hide file tree
Showing 30 changed files with 1,876 additions and 1,830 deletions.
11 changes: 0 additions & 11 deletions .github/dependabut.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ on:
merge_group:

jobs:
check-git-dependencies:
name: Check git dependencies
runs-on: ubuntu-latest
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v4
- name: Check Dependencies
run: ./scripts/ci/check-git-dependencies.sh

check-changelogs:
name: Check changelogs
runs-on: ubuntu-latest
Expand All @@ -39,26 +27,3 @@ jobs:

- name: Check changelogs
run: ./scripts/ci/check-changelogs.sh

check-cabal-files:
name: Check cabal files
runs-on: ubuntu-latest
defaults:
run:
shell: bash

steps:
- name: Install dependencies
run: sudo apt install -y fd-find

- name: Install Haskell
uses: input-output-hk/actions/haskell@latest
id: setup-haskell
with:
cabal-version: "3.10.1.0"

- uses: actions/checkout@v4

- name: Check cabal files
run: ./scripts/ci/check-cabal-files.sh

69 changes: 36 additions & 33 deletions cardano-client/cardano-client.cabal
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
cabal-version: 3.0
name: cardano-client
version: 0.3.1.5
synopsis: An API for ouroboros-network
description: An API for ouroboros-network.
license: Apache-2.0
license-files:
LICENSE
NOTICE

name: cardano-client
version: 0.3.1.5
synopsis: An API for ouroboros-network
description: An API for ouroboros-network.
license: Apache-2.0
license-files: LICENSE
NOTICE
copyright: 2019-2023 Input Output Global Inc (IOG), 2023-2024 Intersect
author: IOHK Engineering Team
maintainer: [email protected]
category: Network
build-type: Simple
extra-doc-files: CHANGELOG.md
copyright: 2019-2023 Input Output Global Inc (IOG), 2023-2024 Intersect
author: IOHK Engineering Team
maintainer: [email protected]
category: Network
build-type: Simple
extra-doc-files: CHANGELOG.md

library
hs-source-dirs: src
exposed-modules: Cardano.Client.Subscription
default-language: Haskell2010
default-extensions: ImportQualifiedPost
build-depends: base >=4.14 && <4.21,
bytestring >=0.10 && <0.13,
containers,
ouroboros-network-api >= 0.5.2 && < 0.10,
ouroboros-network >= 0.9 && < 0.18,
ouroboros-network-framework >= 0.8 && < 0.14,
network-mux ^>= 0.4.5,
hs-source-dirs: src
exposed-modules: Cardano.Client.Subscription
default-language: Haskell2010
default-extensions: ImportQualifiedPost
build-depends:
base >=4.14 && <4.21,
bytestring >=0.10 && <0.13,
containers,
network-mux ^>=0.4.5,
ouroboros-network >=0.9 && <0.18,
ouroboros-network-api >=0.5.2 && <0.10,
ouroboros-network-framework >=0.8 && <0.14,

ghc-options: -Wall
-Wno-unticked-promoted-constructors
-Wcompat
-Wincomplete-uni-patterns
-Wincomplete-record-updates
-Wpartial-fields
-Widentities
-Wredundant-constraints
-Wunused-packages
ghc-options:
-Wall
-Wno-unticked-promoted-constructors
-Wcompat
-Wincomplete-uni-patterns
-Wincomplete-record-updates
-Wpartial-fields
-Widentities
-Wredundant-constraints
-Wunused-packages
107 changes: 54 additions & 53 deletions cardano-ping/cardano-ping.cabal
Original file line number Diff line number Diff line change
@@ -1,59 +1,60 @@
cabal-version: 3.0
name: cardano-ping
version: 0.4.0.2
synopsis: Utility for pinging cardano nodes
description: Utility for pinging cardano nodes.
license: Apache-2.0
license-files: LICENSE
NOTICE
copyright: 2019-2023 Input Output Global Inc (IOG), 2023-2024 Intersect
author: Karl Knutsson
maintainer: [email protected] [email protected]
category: Network
build-type: Simple
extra-doc-files: README.md
CHANGELOG.md
cabal-version: 3.0
name: cardano-ping
version: 0.4.0.2
synopsis: Utility for pinging cardano nodes
description: Utility for pinging cardano nodes.
license: Apache-2.0
license-files:
LICENSE
NOTICE

copyright: 2019-2023 Input Output Global Inc (IOG), 2023-2024 Intersect
author: Karl Knutsson
maintainer: [email protected] [email protected]
category: Network
build-type: Simple
extra-doc-files:
CHANGELOG.md
README.md

flag asserts
description: Enable assertions
manual: False
default: False
description: Enable assertions
manual: False
default: False

library
hs-source-dirs: src
exposed-modules: Cardano.Network.Ping
build-depends: base >=4.14 && <4.21,
aeson >=2.1.1.0 && <3,
cborg >=0.2.8 && <0.3,
bytestring >=0.10 && <0.13,
contra-tracer >=0.1 && <0.3,
iproute,
time,

si-timers ^>=1.5,
strict-stm,

network-mux ^>=0.4.5,
tdigest ^>=0.3,
text >=1.2.4 && <2.2,
transformers >=0.5 && <0.7,

-- The Windows version of network-3.1.2 is missing
-- functions, see
-- https://github.com/haskell/network/issues/484
network >= 3.1.2.2 && < 3.2,
hs-source-dirs: src
exposed-modules: Cardano.Network.Ping
build-depends:
-- The Windows version of network-3.1.2 is missing
-- functions, see
-- https://github.com/haskell/network/issues/484
aeson >=2.1.1.0 && <3,
base >=4.14 && <4.21,
bytestring >=0.10 && <0.13,
cborg >=0.2.8 && <0.3,
contra-tracer >=0.1 && <0.3,
iproute,
network >=3.1.2.2 && <3.2,
network-mux ^>=0.4.5,
si-timers ^>=1.5,
strict-stm,
tdigest ^>=0.3,
text >=1.2.4 && <2.2,
time,
transformers >=0.5 && <0.7,

if flag(asserts)
ghc-options: -fno-ignore-asserts

default-language: Haskell2010
default-extensions: ImportQualifiedPost
ghc-options: -Wall
-Wcompat
-Widentities
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wno-unticked-promoted-constructors
-Wpartial-fields
-Wredundant-constraints
-Wunused-packages
ghc-options: -fno-ignore-asserts
default-language: Haskell2010
default-extensions: ImportQualifiedPost
ghc-options:
-Wall
-Wcompat
-Widentities
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wno-unticked-promoted-constructors
-Wpartial-fields
-Wredundant-constraints
-Wunused-packages
86 changes: 51 additions & 35 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@

outputs = inputs:
let # all platforms on which we build
supportedSystems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
supportedSystems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
in
inputs.flake-utils.lib.eachSystem supportedSystems (
system:
Expand All @@ -45,53 +45,69 @@
overlays = [
# haskellNix.overlay can be configured by later overlays, so need to come before them.
inputs.haskellNix.overlay
(import ./nix/tools.nix inputs)
(import ./nix/ouroboros-network.nix inputs)
(import ./nix/network-docs.nix inputs)
];
};
inherit (pkgs) lib;

flake = pkgs.ouroboros-network.flake {};
network-docs = pkgs.callPackage ./nix/network-docs.nix { };
check-stylish = pkgs.callPackage ./nix/check-stylish.nix { };
buildSystem = pkgs.buildPlatform.system;
flake = pkgs.ouroboros-network.flake { };
format = pkgs.callPackage ./nix/formatting.nix pkgs;
inherit (pkgs) lib network-docs;

# shells accessible through `nix develop`,
# `nix develop .\#devShells.x86_64-linux.ghc810`, etc.
devShells = rec {
default = import ./nix/shell.nix {
hls = true;
profiling = false;
inherit inputs pkgs;
ouroboros-network = pkgs.ouroboros-network;
};
profiling = import ./nix/shell.nix {
hls = true;
profiling = true;
inherit inputs pkgs;
ouroboros-network = pkgs.ouroboros-network;
};
};

# jobs executed on hydra
hydraJobs =
pkgs.callPackages inputs.iohkNix.utils.ciJobsAggregates
{
ciJobs =
flake.hydraJobs
// {
# This ensure hydra send a status for the required job (even if no change other than commit hash)
# This ensure hydra send a status for the required job (even
# if no change other than commit hash)
revision = pkgs.writeText "revision" (inputs.self.rev or "dirty");
inherit network-docs check-stylish;
}
// lib.optionalAttrs (buildSystem == "x86_64-linux") {
devShell = devShells.default;
inherit format network-docs;
};
}
# add network-docs & check-stylish to support
# `nix build .\#hydraJobs.x86_64-linux.network-docs` and
# `nix build .\#hydraJobs.x86_64-linux.check-stylis`.
// { inherit network-docs check-stylish; };
# also provide hydraJobs through legacyPackages to allow building without system prefix, e.g.
};

# Provide hydraJobs through legacyPackages to allow building without system prefix, e.g.
# `nix build .\#network-mux:lib:network-mux`
# `nix build .\#network-docs`
legacyPackages = { inherit hydraJobs network-docs check-stylish; };
legacyPackages = {
inherit hydraJobs network-docs;
format = format
// {
all = pkgs.releaseTools.aggregate {
name = "network-format";
meta.description = "Run all formatters";
constituents = lib.collect lib.isDerivation format;
};
};
};
in
lib.recursiveUpdate flake rec {
project = pkgs.ouroboros-network;
inherit hydraJobs;
inherit legacyPackages;
devShells = let
profillingShell = p: {
# `nix develop .#profiling`
profiling = (p.appendModule {modules = [{enableLibraryProfiling = true;}];}).shell;
};
in
profillingShell pkgs.ouroboros-network
# Additional shells for every GHC version supported by haskell.nix, eg. `nix develop .#ghc927`
// lib.mapAttrs (compiler-nix-name: _: let
p = pkgs.ouroboros-network.appendModule {inherit compiler-nix-name;};
in
p.shell // (profillingShell p))
pkgs.haskell-nix.compiler;
# formatter used by nix fmt
formatter = pkgs.alejandra;
inherit hydraJobs legacyPackages devShells;
}
);
}
Loading

0 comments on commit 2b0fa5b

Please sign in to comment.