Skip to content

Commit

Permalink
Merge pull request #1324 from input-output-hk/lc/flake-parts
Browse files Browse the repository at this point in the history
Switch to flake-parts
  • Loading branch information
locallycompact authored Mar 6, 2024
2 parents c4e7df0 + 9269fc9 commit 7bfd3c5
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 193 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci-nix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ jobs:
if: ${{ matrix.package != 'hydra-tui' }}
run: |
cd ${{ matrix.package }}
nix build .#tests.${{ matrix.package }}
nix develop .#tests.${{ matrix.package }} --command tests
nix build .#${{ matrix.package }}-tests
nix develop .#${{ matrix.package }}-tests --command tests
- name: ❓ Test (TUI)
id: test_tui
Expand All @@ -62,8 +62,8 @@ jobs:
TERM: "xterm"
run: |
cd ${{ matrix.package }}
nix build .#tests.${{ matrix.package }}
nix develop .#tests.${{ matrix.package }} --build
nix build .#${{ matrix.package }}-tests
nix develop .#${{ matrix.package }}-tests --build
- name: 💾 Upload build & test artifacts
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -170,8 +170,8 @@ jobs:
run: |
mkdir -p benchmarks
cd ${{ matrix.package }}
nix build .#benchs.${{ matrix.package }}
nix develop .#benchs.${{ matrix.package }} --command ${{ matrix.bench }} ${{ matrix.options }}
nix build .#${{ matrix.package }}-bench
nix develop .#${{ matrix.package }}-bench --command ${{ matrix.bench }} ${{ matrix.options }}
- name: 💾 Upload build & test artifacts
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ right place before, you can use these `nix` builds from the repository root:
nix build .#spec && ln -s $(readlink result)/hydra-spec.pdf docs/static/hydra-spec.pdf
nix build .#haddocks -o docs/static/haddock

(cd hydra-node; nix develop .#benchs.hydra-node --command tx-cost --output-directory $(pwd)/../docs/benchmarks)
(cd hydra-cluster; nix develop .#benchs.hydra-cluster --command bench-e2e --scaling-factor 1 --output-directory $(pwd)/../docs/benchmarks)
(cd hydra-node; nix develop .#hydra-node-bench --command tx-cost --output-directory $(pwd)/../docs/benchmarks)
(cd hydra-cluster; nix develop .#hydra-cluster-bench --command bench-e2e --scaling-factor 1 --output-directory $(pwd)/../docs/benchmarks)
```

# Translating
Expand Down
75 changes: 39 additions & 36 deletions flake.lock

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

171 changes: 84 additions & 87 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
nixpkgs.follows = "haskellNix/nixpkgs";
haskellNix.url = "github:input-output-hk/haskell.nix";
iohk-nix.url = "github:input-output-hk/iohk-nix";
flake-utils.url = "github:numtide/flake-utils";
flake-parts.url = "github:hercules-ci/flake-parts";
lint-utils = {
url = "github:homotopic/lint-utils";
inputs.nixpkgs.follows = "haskellNix/nixpkgs";
Expand All @@ -25,110 +25,107 @@

outputs =
{ self
, flake-utils
, flake-parts
, nixpkgs
, cardano-node
, ...
} @ inputs:
flake-utils.lib.eachSystem [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
(system:
let
compiler = "ghc964";
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
perSystem = { config, system, ... }:
let
compiler = "ghc964";

# nixpkgs enhanced with haskell.nix and crypto libs as used by iohk
# 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)
inputs.nix-npm-buildpackage.overlays.default
# 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;
})
];
};
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)
inputs.nix-npm-buildpackage.overlays.default
# 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;
})
];
};

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

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

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

hydraImages = import ./nix/hydra/docker.nix {
inherit hydraPackages system nixpkgs;
};
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;
prefixAttrs = s: attrs:
with pkgs.lib.attrsets;
mapAttrs' (name: value: nameValuePair (s + name) value) attrs;

in
rec {
legacyPackages = pkgs;
in
rec {
legacyPackages = pkgs;

packages =
hydraPackages //
prefixAttrs "docker-" hydraImages // {
spec = import ./spec { inherit pkgs; };
};
packages =
hydraPackages //
prefixAttrs "docker-" hydraImages // {
spec = import ./spec { inherit pkgs; };
};

checks = let lu = inputs.lint-utils.linters.${system}; in {
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;
checks = let lu = inputs.lint-utils.linters.${system}; in {
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 pkgs hsPkgs system compiler;
};
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; };
};
});
};

nixConfig = {
extra-substituters = [
Expand Down
Loading

0 comments on commit 7bfd3c5

Please sign in to comment.