Skip to content

Commit

Permalink
Reorganize a bit cardano hydraJobs. minor cleanups / formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbgi committed Aug 8, 2022
1 parent 6b182d0 commit 0e80dfa
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 107 deletions.
101 changes: 60 additions & 41 deletions nix/cardano/hydraJobs.nix
Expand Up @@ -8,64 +8,83 @@ let
inherit (nixpkgs.stdenv) hostPlatform;
inherit (cells.automation.jobs) mkHydraRequiredJob;
inherit (cell.packages) project nodeProject ogmiosProject;
mergedProject = lib.recursiveUpdate (lib.recursiveUpdate
(removeAttrs ogmiosProject ["checks" "benchmarks"]) nodeProject) project;
internal = {
roots = {
nodeProject = nodeProject.roots;
project = project.roots;
ogmiosProject = ogmiosProject.roots;
baseJobs = {
world = {
inherit (project) exes checks benchmarks;
profiled = lib.genAttrs [ "cardano-new-faucet" ] (n:
project.exes.${n}.passthru.profiled
);
internal = {
inherit (project) roots plan-nix;
};
};
node = {
inherit (nodeProject) exes checks benchmarks;
profiled = lib.genAttrs [ "cardano-node" "tx-generator" "locli" ] (n:
nodeProject.exes.${n}.passthru.profiled
);
internal = {
inherit (nodeProject) roots plan-nix;
};
};
plan-nix = {
nodeProject = nodeProject.plan-nix;
project = project.plan-nix;
ogmiosProject = ogmiosProject.plan-nix;
ogmios = {
inherit (ogmiosProject) exes;
internal = {
inherit (ogmiosProject) roots plan-nix;
};
};
};
jobs = {
linux = lib.optionalAttrs hostPlatform.isLinux {
x86 = lib.optionalAttrs hostPlatform.isx86_64 {
native = {
inherit (mergedProject) exes checks benchmarks;
profiled = lib.genAttrs [ "cardano-node" "tx-generator" "locli" "cardano-new-faucet" ] (n:
mergedProject.exes.${n}.passthru.profiled
);
asserted = lib.genAttrs [ "cardano-node" ] (n:
nodeProject.exes.${n}.passthru.asserted
);
inherit internal;
};
native = baseJobs;
musl =
let
muslProject = nodeProject.projectCross.musl64;
in
{
cardano-node-linux = muslProject.release;
internal.roots.nodeProject = muslProject.roots;
node =
let
muslProject = nodeProject.projectCross.musl64;
in
{
cardano-node-linux = muslProject.release;
internal = { inherit (muslProject) roots; };
};
};
windows =
let windowsProject = nodeProject.projectCross.mingwW64;
in
{
inherit (windowsProject) checks benchmarks;
cardano-node-win64 = windowsProject.release;
internal.roots.nodeProject = windowsProject.roots;
node =
let windowsProject = nodeProject.projectCross.mingwW64;
in
{
inherit (windowsProject) checks benchmarks;
cardano-node-win64 = windowsProject.release;
internal = { inherit (windowsProject) roots; };
};
};
};
arm = lib.optionalAttrs hostPlatform.isAarch64 {
inherit (mergedProject) exes;
inherit internal;
world = {
inherit (project) exes;
internal = {
inherit (project) roots plan-nix;
};
};
node = {
inherit (nodeProject) exes;
internal = {
inherit (nodeProject) roots plan-nix;
};
};
ogmios = {
inherit (ogmiosProject) exes;
internal = {
inherit (ogmiosProject) roots plan-nix;
};
};
};
};
macos = lib.optionalAttrs hostPlatform.isMacOS {
x86 = lib.optionalAttrs hostPlatform.isx86_64 {
inherit (mergedProject) exes checks benchmarks;
inherit internal;
};
arm = lib.optionalAttrs hostPlatform.isAarch64 {
inherit (mergedProject) exes checks benchmarks;
inherit internal;
};
x86 = lib.optionalAttrs hostPlatform.isx86_64 baseJobs;
arm = lib.optionalAttrs hostPlatform.isAarch64 baseJobs;
};
};
nonRequiredPaths = map lib.hasPrefix [ ];
Expand Down
110 changes: 57 additions & 53 deletions nix/cardano/packages/default.nix
@@ -1,7 +1,8 @@
{
inputs,
cell,
}: let
{ inputs
, cell
,
}:
let
inherit
(inputs)
self
Expand Down Expand Up @@ -47,64 +48,65 @@
});

nodeProject = (project.appendModule {
name = lib.mkForce "cardano-node";
name = "cardano-node";
gitrev = cardano-node.rev;
src = lib.mkForce (haskellLib.cleanSourceWith {
src = cardano-node.outPath;
name = "cardano-node-src";
filter = path: type:
let relPath = lib.removePrefix "${cardano-node.outPath}/" path; in
# excludes directories not part of cabal project:
(type != "directory" || (builtins.match ".*/.*" relPath != null) || (!(lib.elem relPath [
"nix"
"doc"
"docs"
]) && !(lib.hasPrefix "." relPath)))
# only keep cabal.project from files at root:
&& (type == "directory" || builtins.match ".*/.*" relPath != null || (relPath == "cabal.project"))
&& (lib.cleanSourceFilter path type)
&& (haskell-nix.haskellSourceFilter path type)
&& !(lib.hasSuffix ".gitignore" relPath)
# removes socket files
&& lib.elem type [ "regular" "directory" "symlink" ];
});
src = haskellLib.cleanSourceWith {
src = cardano-node.outPath;
name = "cardano-node-src";
filter = path: type:
let relPath = lib.removePrefix "${cardano-node.outPath}/" path; in
# excludes directories not part of cabal project:
(type != "directory" || (builtins.match ".*/.*" relPath != null) || (!(lib.elem relPath [
"nix"
"doc"
"docs"
]) && !(lib.hasPrefix "." relPath)))
# only keep cabal.project from files at root:
&& (type == "directory" || builtins.match ".*/.*" relPath != null || (relPath == "cabal.project"))
&& (lib.cleanSourceFilter path type)
&& (haskell-nix.haskellSourceFilter path type)
&& !(lib.hasSuffix ".gitignore" relPath)
# removes socket files
&& lib.elem type [ "regular" "directory" "symlink" ];
};
}).extend (final: prev: {
release = nixpkgs.callPackage ./binary-release.nix {
inherit (final.pkgs) stdenv;
exes =
lib.attrValues final.exes
++ [
final.hsPkgs.bech32.components.exes.bech32
];
inherit (final.exes.cardano-node.identifier) version;
inherit (cardano.library) copyEnvsTemplate;
inherit (cardano) environments;
};
});
release = nixpkgs.callPackage ./binary-release.nix {
inherit (final.pkgs) stdenv;
exes =
lib.attrValues final.exes
++ [
final.hsPkgs.bech32.components.exes.bech32
];
inherit (final.exes.cardano-node.identifier) version;
inherit (cardano.library) copyEnvsTemplate;
inherit (cardano) environments;
};
});

inherit (project.args) compiler-nix-name;
inherit (project) index-state;

ogmiosProject = project.appendModule {
name = lib.mkForce "ogmios";
name = "ogmios";
gitrev = ogmios.rev;
src = lib.mkForce (haskellLib.cleanSourceWith {
src = haskellLib.cleanSourceWith {
name = "ogmios-src";
src = ogmios;
subDir = "server";
filter = path: type:
builtins.all (x: x) [
(baseNameOf path != "package.yaml")
];
});
};
modules = [
{
doHaddock = lib.mkForce false;
doCheck = lib.mkForce false;
}
];
};
in {
in
{
inherit project nodeProject ogmiosProject; # TODO REMOVE
inherit (nodeProject.exes) cardano-node cardano-cli cardano-submit-api cardano-tracer;
inherit (nodeProject.hsPkgs.bech32.components.exes) bech32;
Expand All @@ -114,21 +116,23 @@ in {
inherit (cardano-wallet.packages) cardano-address;
inherit (cardano-db-sync.packages) cardano-db-sync;
inherit (ogmiosProject.hsPkgs.ogmios.components.exes) ogmios;
cardano-graphql = (import (cardano-graphql + "/nix/pkgs.nix") {inherit (nixpkgs) system;}).packages.cardano-graphql;
graphql-engine = (import (cardano-graphql + "/nix/pkgs.nix") {inherit (nixpkgs) system;}).packages.graphql-engine;
cardano-explorer-app = let
# TODO fix the ugliness to make this work
package = nixpkgs.callPackage (cardano-explorer-app + "/nix/cardano-explorer-app.nix") {
nix-inclusive = nix-inclusive.lib.inclusive;
sources = null;
};
in
cardano-graphql = (import (cardano-graphql + "/nix/pkgs.nix") { inherit (nixpkgs) system; }).packages.cardano-graphql;
graphql-engine = (import (cardano-graphql + "/nix/pkgs.nix") { inherit (nixpkgs) system; }).packages.graphql-engine;
cardano-explorer-app =
let
# TODO fix the ugliness to make this work
package = nixpkgs.callPackage (cardano-explorer-app + "/nix/cardano-explorer-app.nix") {
nix-inclusive = nix-inclusive.lib.inclusive;
sources = null;
};
in
package;
#cardano-rosetta-server = (import (cardano-rosetta + "/nix/pkgs.nix") {inherit (nixpkgs) system;}).packages.cardano-rosetta-server;
cardano-config-html-public = let
publicEnvNames = ["mainnet" "testnet" "shelley_qa" "vasil-dev"];
environments = lib.filterAttrs (_: v: !v.private) cardano.environments;
in
cardano-config-html-public =
let
publicEnvNames = [ "mainnet" "testnet" "shelley_qa" "vasil-dev" ];
environments = lib.filterAttrs (_: v: !v.private) cardano.environments;
in
cardano.library.generateStaticHTMLConfigs environments;
cardano-config-html-internal = cardano.library.generateStaticHTMLConfigs cardano.environments;
inherit nix-inclusive; # TODO REMOVE
Expand Down
27 changes: 14 additions & 13 deletions nix/cardano/packages/haskell.nix
Expand Up @@ -27,21 +27,21 @@ in
};
};
config = {
name = "cardano-world";
src = haskellLib.cleanSourceWith {
name = lib.mkDefault "cardano-world";
src = lib.mkDefault (haskellLib.cleanSourceWith {
src = src.outPath;
name = "cardano-world-src";
filter = path: type:
let relPath = lib.removePrefix "${src.outPath}/" path; in
# only keep cabal.project and directories under src:
(relPath == "cabal.project" || relPath == "src" || (type == "directory" && (builtins.match "src/.*" relPath != null))
|| (builtins.match "src/.*/.*" relPath != null))
|| (builtins.match "src/.*/.*" relPath != null))
&& (lib.cleanSourceFilter path type)
&& (haskell-nix.haskellSourceFilter path type)
&& !(lib.hasSuffix ".gitignore" relPath)
# removes socket files
&& lib.elem type [ "regular" "directory" "symlink" ];
};
});
compiler-nix-name = "ghc8107";
cabalProjectLocal = ''
allow-newer: terminfo:base
Expand All @@ -68,15 +68,16 @@ in
modules =
let
inherit (config) src;
packagesExes = let
project = haskell-nix.cabalProject' {
inherit (config) name src compiler-nix-name cabalProjectLocal;
};
packages = haskellLib.selectProjectPackages project.hsPkgs;
in
lib.genAttrs
(lib.attrNames packages)
(name: lib.attrNames packages.${name}.components.exes);
packagesExes =
let
project = haskell-nix.cabalProject' {
inherit (config) name src compiler-nix-name cabalProjectLocal;
};
packages = haskellLib.selectProjectPackages project.hsPkgs;
in
lib.genAttrs
(lib.attrNames packages)
(name: lib.attrNames packages.${name}.components.exes);
packageNames = builtins.attrNames packagesExes;
in
[
Expand Down

0 comments on commit 0e80dfa

Please sign in to comment.