Skip to content

Commit

Permalink
Merge pull request #1317 from input-output-hk/lc/flake-update
Browse files Browse the repository at this point in the history
Refactor flake, shells and hydraProject
  • Loading branch information
locallycompact authored Feb 28, 2024
2 parents 3006762 + d3e1aaf commit a269c50
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 228 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/formatting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- name: 📐 Check code formatting
run: |
nix develop .#fmt --command treefmt --fail-on-change
nix build .#checks.x86_64-linux.treefmt
- name: 📐 Check hlint
run: |
Expand Down
6 changes: 1 addition & 5 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Custom repository for cardano haskell packages, see CONTRIBUTING.md
repository cardano-haskell-packages
url: https://input-output-hk.github.io/cardano-haskell-packages
url: https://intersectmbo.github.io/cardano-haskell-packages
secure: True
root-keys:
3e0cce471cf09815f930210f7827266fd09045445d65923e6d0238a6cd15126f
Expand Down Expand Up @@ -44,7 +44,3 @@ benchmarks: True

-- Always show detailed output for tests
test-show-details: direct

-- Fix compilation of strict-containers (see also nix/hydra/project.nix)
package strict-containers
ghc-options: "-Wno-noncanonical-monad-instances"
48 changes: 24 additions & 24 deletions flake.lock

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

79 changes: 61 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
inputs.nixpkgs.follows = "haskellNix/nixpkgs";
};
CHaP = {
url = "github:input-output-hk/cardano-haskell-packages?ref=repo";
url = "github:intersectmbo/cardano-haskell-packages?ref=repo";
flake = false;
};
# Use a patched 2.6.0.0 as we are also affected by
Expand All @@ -36,27 +36,66 @@
]
(system:
let
pkgs = import inputs.nixpkgs { inherit system; };
tools = {
hlint = hydraProject.pkgs.haskell-nix.tool hydraProject.compiler "hlint" "3.8";
compiler = "ghc964";

# nixpkgs enhanced with haskell.nix and crypto libs as used by iohk

pkgs = import nixpkgs {
inherit system;
overlays = [
# This overlay contains libsodium and libblst libraries
inputs.iohk-nix.overlays.crypto
# This overlay contains pkg-config mappings via haskell.nix to use the
# crypto libraries above
inputs.iohk-nix.overlays.haskell-nix-crypto
# Keep haskell.nix as the last overlay!
#
# Reason: haskell.nix modules/overlays neds to be last
# https://github.com/input-output-hk/haskell.nix/issues/1954
inputs.haskellNix.overlay
# Custom static libs used for darwin build
(import ./nix/static-libs.nix)
# Specific versions of tools we require
(final: prev: {
apply-refact = pkgs.haskell-nix.tool compiler "apply-refact" "0.14.0.0";
cabal-fmt = pkgs.haskell-nix.tool compiler "cabal-fmt" "0.1.9";
cabal-install = pkgs.haskell-nix.cabal-install.${compiler};
cabal-plan = pkgs.haskell-nix.tool compiler "cabal-plan" "0.7.3.0";
fourmolu = pkgs.haskell-nix.tool compiler "fourmolu" "0.14.0.0";
haskell-language-server = pkgs.haskell-nix.tool compiler "haskell-language-server" rec {
src = inputs.hls;
cabalProject = builtins.readFile (src + "/cabal.project");
};
hlint = pkgs.haskell-nix.tool compiler "hlint" "3.8";
cardano-cli = inputs.cardano-node.packages.${system}.cardano-cli;
cardano-node = inputs.cardano-node.packages.${system}.cardano-node;
mithril-client-cli = inputs.mithril.packages.${system}.mithril-client-cli;
})
];
};
hydraProject = import ./nix/hydra/project.nix {
inherit (inputs) haskellNix iohk-nix CHaP;
inherit system nixpkgs;

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

hsPkgs = import ./nix/hydra/project.nix {
inherit pkgs inputMap;
compiler-nix-name = compiler;
};

hydraPackages = import ./nix/hydra/packages.nix {
inherit hydraProject system pkgs inputs;
inherit system pkgs inputs hsPkgs;
gitRev = self.rev or "dirty";
};

hydraImages = import ./nix/hydra/docker.nix {
inherit hydraPackages system nixpkgs;
};

prefixAttrs = s: attrs:
with pkgs.lib.attrsets;
mapAttrs' (name: value: nameValuePair (s + name) value) attrs;
in
rec {
inherit hydraProject;
legacyPackages = pkgs;

packages =
{ default = hydraPackages.hydra-node; } //
Expand All @@ -66,22 +105,26 @@
};

checks = let lu = inputs.lint-utils.linters.${system}; in {
hlint = lu.hlint { src = self; hlint = tools.hlint; };
hlint = lu.hlint { src = self; hlint = pkgs.hlint; };
treefmt = lu.treefmt {
src = self;
buildInputs = [
pkgs.cabal-fmt
pkgs.nixpkgs-fmt
pkgs.fourmolu
];
treefmt = pkgs.treefmt;
};
};

devShells = (import ./nix/hydra/shell.nix {
inherit inputs hydraProject tools system;
}) // {
ci = (import ./nix/hydra/shell.nix {
inherit inputs hydraProject system tools;
withoutDevTools = true;
}).default;
devShells = import ./nix/hydra/shell.nix {
inherit inputs pkgs hsPkgs system compiler;
};

# Build selected derivations in CI for caching
hydraJobs = pkgs.lib.optionalAttrs (!pkgs.stdenv.isDarwin) {
packages = { inherit (packages) hydra-node hydra-tui hydraw spec; };
devShells = { inherit (devShells) default ci; };
devShells = { inherit (devShells) default; };
};
});

Expand Down
4 changes: 2 additions & 2 deletions nix/hydra/docker.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# metadata, as this is only added by the Github workflow.

{ hydraPackages # as defined in packages.nix
, system ? builtins.currentSystem
, nixpkgs ? <nixpkgs>
, system
, nixpkgs
}:
let
pkgs = import nixpkgs { inherit system; };
Expand Down
24 changes: 12 additions & 12 deletions nix/hydra/packages.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# A set of buildables we typically build for releases

{ hydraProject # as defined in default.nix
{ hsPkgs # as defined in default.nix
, system ? builtins.currentSystem
, pkgs
, inputs
Expand Down Expand Up @@ -55,9 +55,9 @@ let
'';
};

nativePkgs = hydraProject.hsPkgs;
nativePkgs = hsPkgs;
# Allow reinstallation of terminfo as it's not installed with cross compilers.
patchedForCrossProject = hydraProject.hsPkgs.appendModule
patchedForCrossProject = hsPkgs.appendModule
({ lib, ... }: { options.nonReinstallablePkgs = lib.mkOption { apply = lib.remove "terminfo"; }; });
musl64Pkgs = patchedForCrossProject.projectCross.musl64.hsPkgs;
in
Expand Down Expand Up @@ -184,15 +184,15 @@ rec {
haddocks = pkgs.runCommand "hydra-haddocks"
{
paths = [
hydraProject.hsPkgs.plutus-cbor.components.library.doc
hydraProject.hsPkgs.plutus-merkle-tree.components.library.doc
hydraProject.hsPkgs.hydra-prelude.components.library.doc
hydraProject.hsPkgs.hydra-cardano-api.components.library.doc
hydraProject.hsPkgs.hydra-plutus.components.library.doc
hydraProject.hsPkgs.hydra-node.components.library.doc
hydraProject.hsPkgs.hydra-node.components.tests.tests.doc
hydraProject.hsPkgs.hydra-cluster.components.library.doc
hydraProject.hsPkgs.hydra-tui.components.library.doc
hsPkgs.plutus-cbor.components.library.doc
hsPkgs.plutus-merkle-tree.components.library.doc
hsPkgs.hydra-prelude.components.library.doc
hsPkgs.hydra-cardano-api.components.library.doc
hsPkgs.hydra-plutus.components.library.doc
hsPkgs.hydra-node.components.library.doc
hsPkgs.hydra-node.components.tests.tests.doc
hsPkgs.hydra-cluster.components.library.doc
hsPkgs.hydra-tui.components.library.doc
];
}
''
Expand Down
Loading

0 comments on commit a269c50

Please sign in to comment.