diff --git a/default.nix b/default.nix index e97181a5c44..efb1e073545 100644 --- a/default.nix +++ b/default.nix @@ -3,24 +3,30 @@ , system ? builtins.currentSystem , haskellNix ? import - (builtins.fetchTarball - "https://github.com/input-output-hk/haskell.nix/archive/0.0.64.tar.gz") - { } + (builtins.fetchTarball { + url = "https://github.com/input-output-hk/haskell.nix/archive/0.0.64.tar.gz"; + sha256 = "0mply6n3gym8r7z4l7512phw667qzwfqkfl1zmiyrdjpdg7xqn1d"; + }) + { pkgs = import nixpkgsSrc { inherit system; }; } , iohkNix ? import - (builtins.fetchTarball - "https://github.com/input-output-hk/iohk-nix/archive/d31417fe8c8fbfb697b3ad4c498e17eb046874b9.tar.gz") + (builtins.fetchTarball { + url = "https://github.com/input-output-hk/iohk-nix/archive/d31417fe8c8fbfb697b3ad4c498e17eb046874b9.tar.gz"; + sha256 = "0w562wdmdhp83dw9rabiijj5hk1f4l8p8f3bwlr7virakgbg8lf8"; + }) { } # NOTE: use the 'repo' branch of CHaP which contains the index -, CHaP ? (builtins.fetchTarball - "https://github.com/input-output-hk/cardano-haskell-packages/archive/695c91a740abfeef0860056227c605abf6375edd.tar.gz") +, CHaP ? (builtins.fetchTarball { + url = "https://github.com/input-output-hk/cardano-haskell-packages/archive/695c91a740abfeef0860056227c605abf6375edd.tar.gz"; + sha256 = "05dffxjxap6ncfs7x4lpp85cm7pvls0b10idpyshm4lqlrz5v92p"; + }) - # nixpkgs-unstable as also used by cardano-node, cardano-ledger et al -, nixpkgsSrc ? haskellNix.sources.nixpkgs-unstable +, nixpkgsSrc ? iohkNix.nixpkgs }: let pkgs = import nixpkgsSrc (haskellNix.nixpkgsArgs // { + inherit system; overlays = # Haskell.nix (https://github.com/input-output-hk/haskell.nix) haskellNix.overlays diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000000..08038163422 --- /dev/null +++ b/flake.lock @@ -0,0 +1,447 @@ +{ + "nodes": { + "blank": { + "locked": { + "lastModified": 1625557891, + "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", + "owner": "divnix", + "repo": "blank", + "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "blank", + "type": "github" + } + }, + "devshell": { + "inputs": { + "flake-utils": [ + "tullia", + "std", + "flake-utils" + ], + "nixpkgs": [ + "tullia", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1663445644, + "narHash": "sha256-+xVlcK60x7VY1vRJbNUEAHi17ZuoQxAIH4S4iUFUGBA=", + "owner": "numtide", + "repo": "devshell", + "rev": "e3dc3e21594fe07bdb24bdf1c8657acaa4cb8f66", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "dmerge": { + "inputs": { + "nixlib": [ + "tullia", + "std", + "nixpkgs" + ], + "yants": [ + "tullia", + "std", + "yants" + ] + }, + "locked": { + "lastModified": 1659548052, + "narHash": "sha256-fzI2gp1skGA8mQo/FBFrUAtY0GQkAIAaV/V127TJPyY=", + "owner": "divnix", + "repo": "data-merge", + "rev": "d160d18ce7b1a45b88344aa3f13ed1163954b497", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "data-merge", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gomod2nix": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + }, + "locked": { + "lastModified": 1655245309, + "narHash": "sha256-d/YPoQ/vFn1+GTmSdvbSBSTOai61FONxB4+Lt6w/IVI=", + "owner": "tweag", + "repo": "gomod2nix", + "rev": "40d32f82fc60d66402eb0972e6e368aeab3faf58", + "type": "github" + }, + "original": { + "owner": "tweag", + "repo": "gomod2nix", + "type": "github" + } + }, + "mdbook-kroki-preprocessor": { + "flake": false, + "locked": { + "lastModified": 1661755005, + "narHash": "sha256-1TJuUzfyMycWlOQH67LR63/ll2GDZz25I3JfScy/Jnw=", + "owner": "JoelCourtney", + "repo": "mdbook-kroki-preprocessor", + "rev": "93adb5716d035829efed27f65f2f0833a7d3e76f", + "type": "github" + }, + "original": { + "owner": "JoelCourtney", + "repo": "mdbook-kroki-preprocessor", + "type": "github" + } + }, + "n2c": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": [ + "tullia", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1665039323, + "narHash": "sha256-SAh3ZjFGsaCI8FRzXQyp56qcGdAqgKEfJWPCQ0Sr7tQ=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "b008fe329ffb59b67bf9e7b08ede6ee792f2741a", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "nix2container", + "type": "github" + } + }, + "nix-nomad": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": [ + "tullia", + "nix2container", + "flake-utils" + ], + "gomod2nix": "gomod2nix", + "nixpkgs": [ + "tullia", + "nixpkgs" + ], + "nixpkgs-lib": [ + "tullia", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1658277770, + "narHash": "sha256-T/PgG3wUn8Z2rnzfxf2VqlR1CBjInPE0l1yVzXxPnt0=", + "owner": "tristanpemble", + "repo": "nix-nomad", + "rev": "054adcbdd0a836ae1c20951b67ed549131fd2d70", + "type": "github" + }, + "original": { + "owner": "tristanpemble", + "repo": "nix-nomad", + "type": "github" + } + }, + "nix2container": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1658567952, + "narHash": "sha256-XZ4ETYAMU7XcpEeAFP3NOl9yDXNuZAen/aIJ84G+VgA=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "60bb43d405991c1378baf15a40b5811a53e32ffa", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "nix2container", + "type": "github" + } + }, + "nixago": { + "inputs": { + "flake-utils": [ + "tullia", + "std", + "flake-utils" + ], + "nixago-exts": [ + "tullia", + "std", + "blank" + ], + "nixpkgs": [ + "tullia", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1661824785, + "narHash": "sha256-/PnwdWoO/JugJZHtDUioQp3uRiWeXHUdgvoyNbXesz8=", + "owner": "nix-community", + "repo": "nixago", + "rev": "8c1f9e5f1578d4b2ea989f618588d62a335083c3", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixago", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1653581809, + "narHash": "sha256-Uvka0V5MTGbeOfWte25+tfRL3moECDh1VwokWSZUdoY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "83658b28fe638a170a19b8933aa008b30640fbd1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1654807842, + "narHash": "sha256-ADymZpr6LuTEBXcy6RtFHcUZdjKTBRTMYwu19WOx17E=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fc909087cc3386955f21b4665731dbdaceefb1d8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1653920503, + "narHash": "sha256-BBeCZwZImtjP3oYy4WogkQYy5OxNyfNciVSc1AfZgLQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a634c8f6c1fbf9b9730e01764999666f3436f10a", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-22.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1665087388, + "narHash": "sha256-FZFPuW9NWHJteATOf79rZfwfRn5fE0wi9kRzvGfDHPA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "95fda953f6db2e9496d2682c4fc7b82f959878f7", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": [ + "tullia", + "nixpkgs" + ], + "std": [ + "tullia", + "std" + ], + "tullia": "tullia" + } + }, + "std": { + "inputs": { + "blank": "blank", + "devshell": "devshell", + "dmerge": "dmerge", + "flake-utils": "flake-utils_2", + "makes": [ + "tullia", + "std", + "blank" + ], + "mdbook-kroki-preprocessor": "mdbook-kroki-preprocessor", + "microvm": [ + "tullia", + "std", + "blank" + ], + "n2c": "n2c", + "nixago": "nixago", + "nixpkgs": "nixpkgs_4", + "yants": "yants" + }, + "locked": { + "lastModified": 1665513321, + "narHash": "sha256-D6Pacw9yf/HMs84KYuCxHXnNDL7v43gtcka5URagFqE=", + "owner": "divnix", + "repo": "std", + "rev": "94a90eedb9cfc115b12ae8f6622d9904788559e4", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "std", + "type": "github" + } + }, + "tullia": { + "inputs": { + "nix-nomad": "nix-nomad", + "nix2container": "nix2container", + "nixpkgs": "nixpkgs_3", + "std": "std" + }, + "locked": { + "lastModified": 1668711738, + "narHash": "sha256-CBjky16o9pqsGE1bWu6nRlRajgSXMEk+yaFQLibqXcE=", + "owner": "input-output-hk", + "repo": "tullia", + "rev": "ead1f515c251f0e060060ef0e2356a51d3dfe4b0", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "tullia", + "type": "github" + } + }, + "utils": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "yants": { + "inputs": { + "nixpkgs": [ + "tullia", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660507851, + "narHash": "sha256-BKjq7JnVuUR/xDtcv6Vm9GYGKAblisXrAgybor9hT/s=", + "owner": "divnix", + "repo": "yants", + "rev": "0b895ca02a8fa72bad50b454cb3e7d8a66407c96", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "yants", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000000..d3d2e21f624 --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + inputs = { + nixpkgs.follows = "tullia/nixpkgs"; + std.follows = "tullia/std"; + tullia.url = github:input-output-hk/tullia; + }; + + outputs = { + self, + std, + tullia, + ... + } @ inputs: + std.growOn { + inherit inputs; + cellsFrom = ./nix; + 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; + }; +} diff --git a/nix/automation/hydraJobs.nix b/nix/automation/hydraJobs.nix new file mode 100644 index 00000000000..58dbdb209b0 --- /dev/null +++ b/nix/automation/hydraJobs.nix @@ -0,0 +1,9 @@ +{ + cell, + inputs, +}: + +import "${inputs.self}/release.nix" { + hydra = inputs.self; + inherit (inputs.nixpkgs) system; +} diff --git a/nix/automation/pipelines.nix b/nix/automation/pipelines.nix new file mode 100644 index 00000000000..af9f2de5386 --- /dev/null +++ b/nix/automation/pipelines.nix @@ -0,0 +1,29 @@ +{ + inputs, + cell, +}: { + ci = {config, lib, ...}: { + preset = { + 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 != {}; + repository = "input-output-hk/hydra"; + revision = config.preset.github.lib.readRevision inputs.cells.cloud.library.actionCiInputName null; + }; + }; + + command.text = config.preset.github.status.lib.reportBulk { + bulk.text = "nix eval .#hydraJobs --apply __attrNames --json | nix-systems -i"; + each.text = ''nix build -L .#hydraJobs."$1".required''; + skippedDescription = lib.escapeShellArg "No nix builder available for this system"; + }; + + memory = 1024 * 8; + nomad.resources.cpu = 10000; + }; +} diff --git a/nix/cloud/actions.nix b/nix/cloud/actions.nix new file mode 100644 index 00000000000..de6025edcb3 --- /dev/null +++ b/nix/cloud/actions.nix @@ -0,0 +1,23 @@ +{ + cell, + inputs, +}: { + "hydra/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/hydra" + } + + #lib.merge + #ios: [ + #lib.io.github_push & github, + { #lib.io.github_pr, github, #target_default: false }, + ] + ''; + }; +} diff --git a/nix/cloud/library.nix b/nix/cloud/library.nix new file mode 100644 index 00000000000..11850235ea1 --- /dev/null +++ b/nix/cloud/library.nix @@ -0,0 +1,6 @@ +{ + inputs, + cell, +}: { + actionCiInputName = "GitHub event"; +} diff --git a/release.nix b/release.nix index aa055692449..887aad211e7 100644 --- a/release.nix +++ b/release.nix @@ -3,10 +3,11 @@ { # this is passed in by hydra to provide us with the revision hydra ? { outPath = ./.; rev = "abcdef"; } +, system ? builtins.currentSystem , ... }: let - project = import ./default.nix { }; + project = import ./default.nix { inherit system; }; nativePkgs = project.hsPkgs; # Allow reinstallation of terminfo as it's not installed with cross compilers. patchedForCrossProject = project.hsPkgs.appendModule @@ -15,7 +16,7 @@ let in rec { # Build shell derivation to cache it - shell = import ./shell.nix { }; + shell = import ./shell.nix { inherit system; }; # Build some executables hydra-node = nativePkgs.hydra-node.components.exes.hydra-node; diff --git a/shell.nix b/shell.nix index eb7c323b2d5..34bbc91f787 100644 --- a/shell.nix +++ b/shell.nix @@ -5,9 +5,10 @@ { # Used in CI to have a smaller closure withoutDevTools ? false +, system ? builtins.currentSystem }: let - project = import ./default.nix { }; + project = import ./default.nix { inherit system; }; inherit (project) compiler pkgs hsPkgs cardano-node; libs = [