Skip to content

Commit

Permalink
add std flake and tullia (#323)
Browse files Browse the repository at this point in the history
add std flake and tullia

Co-authored-by: Michael Peyton Jones <michael.peyton-jones@iohk.io>
  • Loading branch information
dermetfan and michaelpj committed Oct 27, 2022
1 parent a5461b1 commit 4c11344
Show file tree
Hide file tree
Showing 8 changed files with 564 additions and 2 deletions.
423 changes: 423 additions & 0 deletions flake.lock

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
inputs = {
nixpkgs.follows = "std/nixpkgs";
std.url = github:divnix/std;
tullia = {
url = github:input-output-hk/tullia;
inputs.std.follows = "std";
};
};

outputs = {
self,
std,
tullia,
...
} @ inputs:
std.growOn {
inherit inputs;
cellsFrom = nix/cells;
cellBlocks = [
(std.functions "library")
(std.functions "hydraJobs")
(tullia.tasks "pipelines")
(std.functions "actions")
];
}
(
tullia.fromStd {
actions = std.harvest self ["cloud" "actions"];
tasks = std.harvest self ["automation" "pipelines"];
}
)
{
hydraJobs = std.harvest self ["automation" "hydraJobs"];
};

nixConfig = {
extra-substituters = ["https://cache.iog.io"];
extra-trusted-public-keys = ["hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="];
allow-import-from-derivation = true;
};
}
9 changes: 9 additions & 0 deletions nix/cells/automation/hydraJobs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
cell,
inputs,
}:

import "${inputs.self}/release.nix" {
cardano-base = inputs.self;
supportedSystems = [inputs.nixpkgs.system];
}
52 changes: 52 additions & 0 deletions nix/cells/automation/pipelines.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
inputs,
cell,
}: let
inherit (inputs.tullia) flakeOutputTasks taskSequence;
inherit (inputs.nixpkgs) system lib;

common = {config, ...}: {
preset = {
# needed on top-level task to set runtime options
nix.enable = true;

github-ci = {
# Tullia tasks can run locally or on Cicero.
# When no facts are present we know that we are running locally and vice versa.
# When running locally, the current directory is already bind-mounted into the container,
# so we don't need to fetch the source from GitHub and we don't want to report a GitHub status.
enable = config.actionRun.facts != {};
repo = "input-output-hk/cardano-base";
sha = config.preset.github-ci.lib.getRevision inputs.cells.cloud.library.actionCiInputName null;
};
};
};

ciTasks =
__mapAttrs
(_: flakeOutputTask: {...}: {
imports = [common flakeOutputTask];

memory = 1024 * 8;
nomad.resources.cpu = 10000;
})
(flakeOutputTasks ["hydraJobs" system] { outputs.hydraJobs.${system} = cell.hydraJobs; });

ciTasksSeq = taskSequence "ci/" ciTasks (
# make sure the aggregate is built last
let
required = "hydraJobs.${system}.required";
all = __attrNames ciTasks;
in
assert __elem required all;
lib.remove required all ++ [required]
);
in
ciTasks # for running separately
// ciTasksSeq # for running in an arbitrary sequence
// {
"ci" = {lib, ...}: {
imports = [common];
after = __attrNames ciTasksSeq;
};
}
23 changes: 23 additions & 0 deletions nix/cells/cloud/actions.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
cell,
inputs,
}: {
"cardano-base/ci" = {
task = "ci";
io = ''
// This is a CUE expression that defines what events trigger a new run of this action.
// There is no documentation for this yet. Ask SRE if you have trouble changing this.
let github = {
#input: "${cell.library.actionCiInputName}"
#repo: "input-output-hk/cardano-base"
}
#lib.merge
#ios: [
#lib.io.github_push & github,
{ #lib.io.github_pr, github, #target_default: false },
]
'';
};
}
6 changes: 6 additions & 0 deletions nix/cells/cloud/library.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
inputs,
cell,
}: {
actionCiInputName = "GitHub event";
}
6 changes: 5 additions & 1 deletion nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ let
sources = import ./sources.nix { inherit pkgs; }
// sourcesOverride;
iohkNixMain = import sources.iohk-nix {};
haskellNix = (import sources."haskell.nix" { inherit system; sourcesOverride = { hackage = sources."hackage.nix"; }; }).nixpkgsArgs;
haskellNix = (import sources."haskell.nix" {
inherit system;
sourcesOverride.hackage = sources."hackage.nix";
pkgs = import nixpkgs { inherit system; };
}).nixpkgsArgs;
# use our own nixpkgs if it exists in our sources,
# otherwise use iohkNix default nixpkgs.
nixpkgs = if (sources ? nixpkgs)
Expand Down
5 changes: 4 additions & 1 deletion release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
, sourcesOverride ? {}

# Import pkgs, including IOHK common nix lib
, pkgs ? import ./nix { inherit sourcesOverride; }
, pkgs ? import ./nix {
inherit sourcesOverride;
system = __head supportedSystems;
}

}:

Expand Down

0 comments on commit 4c11344

Please sign in to comment.