|
| 1 | +{ |
| 2 | + inputs = { |
| 3 | + nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05"; |
| 4 | + flake-parts.url = "github:hercules-ci/flake-parts"; |
| 5 | + treefmt-nix.url = "github:numtide/treefmt-nix"; |
| 6 | + treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; |
| 7 | + crane.url = "github:ipetkov/crane"; |
| 8 | + fenix.url = "github:nix-community/fenix"; |
| 9 | + fenix.inputs.nixpkgs.follows = "nixpkgs"; |
| 10 | + devshell.url = "github:numtide/devshell"; |
| 11 | + devshell.inputs.nixpkgs.follows = "nixpkgs"; |
| 12 | + cardano-playground.url = "github:input-output-hk/cardano-playground/56ebfef5595c43014029b039ade01b0ef06233e0"; |
| 13 | + cardano-playground.flake = false; # otherwise, +9k dependencies in flake.lock… |
| 14 | + sanchonet.url = "github:Hornan7/SanchoNet-Tutorials"; |
| 15 | + sanchonet.flake = false; |
| 16 | + advisory-db.url = "github:rustsec/advisory-db"; |
| 17 | + advisory-db.flake = false; |
| 18 | + }; |
| 19 | + |
| 20 | + outputs = inputs: let |
| 21 | + inherit (inputs.nixpkgs) lib; |
| 22 | + in |
| 23 | + inputs.flake-parts.lib.mkFlake {inherit inputs;} ({config, ...}: { |
| 24 | + imports = [ |
| 25 | + inputs.devshell.flakeModule |
| 26 | + inputs.treefmt-nix.flakeModule |
| 27 | + ]; |
| 28 | + |
| 29 | + systems = [ |
| 30 | + "x86_64-linux" |
| 31 | + "aarch64-linux" |
| 32 | + "aarch64-darwin" |
| 33 | + "x86_64-darwin" |
| 34 | + ]; |
| 35 | + perSystem = {system, ...}: let |
| 36 | + internal = inputs.self.internal.${system}; |
| 37 | + in { |
| 38 | + packages = |
| 39 | + { |
| 40 | + default = internal.acropolis-process-omnibus; |
| 41 | + inherit (internal) acropolis-process-omnibus acropolis-process-replayer; |
| 42 | + } |
| 43 | + // (lib.optionalAttrs (system == "x86_64-linux") { |
| 44 | + acropolis-process-omnibus-x86_64-windows = inputs.self.internal.x86_64-windows.acropolis-process-omnibus; |
| 45 | + acropolis-process-replayer-x86_64-windows = inputs.self.internal.x86_64-windows.acropolis-process-replayer; |
| 46 | + }); |
| 47 | + |
| 48 | + devshells.default = import ./nix/devshells.nix {inherit inputs;}; |
| 49 | + |
| 50 | + checks = internal.cargoChecks // internal.nixChecks; |
| 51 | + |
| 52 | + treefmt = |
| 53 | + /* |
| 54 | + { pkgs, ...} |
| 55 | + */ |
| 56 | + _: { |
| 57 | + projectRootFile = "flake.nix"; |
| 58 | + programs = { |
| 59 | + alejandra.enable = true; # Nix |
| 60 | + # TODO: enable them one by one (large commits, mostly whitespace): |
| 61 | + #prettier.enable = true; |
| 62 | + #rustfmt.enable = true; |
| 63 | + #rustfmt.package = internal.rustfmt; |
| 64 | + #yamlfmt.enable = pkgs.system != "x86_64-darwin"; # a treefmt-nix+yamlfmt bug on Intel Macs |
| 65 | + #taplo.enable = true; # TOML |
| 66 | + #shfmt.enable = true; |
| 67 | + }; |
| 68 | + # settings.formatter.rustfmt.options = [ |
| 69 | + # "--config-path" |
| 70 | + # (builtins.path { |
| 71 | + # name = "rustfmt.toml"; |
| 72 | + # path = ./rustfmt.toml; |
| 73 | + # }) |
| 74 | + # ]; |
| 75 | + }; |
| 76 | + }; |
| 77 | + |
| 78 | + flake = { |
| 79 | + internal = |
| 80 | + lib.genAttrs config.systems ( |
| 81 | + targetSystem: import ./nix/internal/unix.nix {inherit inputs targetSystem;} |
| 82 | + ) |
| 83 | + // lib.genAttrs ["x86_64-windows"] ( |
| 84 | + targetSystem: import ./nix/internal/windows.nix {inherit inputs targetSystem;} |
| 85 | + ); |
| 86 | + |
| 87 | + hydraJobs = let |
| 88 | + crossSystems = ["x86_64-windows"]; |
| 89 | + allJobs = { |
| 90 | + acropolis-process-omnibus = lib.genAttrs (config.systems ++ crossSystems) ( |
| 91 | + targetSystem: inputs.self.internal.${targetSystem}.acropolis-process-omnibus |
| 92 | + ); |
| 93 | + acropolis-process-replayer = lib.genAttrs (config.systems ++ crossSystems) ( |
| 94 | + targetSystem: inputs.self.internal.${targetSystem}.acropolis-process-replayer |
| 95 | + ); |
| 96 | + devshell = lib.genAttrs config.systems ( |
| 97 | + targetSystem: inputs.self.devShells.${targetSystem}.default |
| 98 | + ); |
| 99 | + inherit (inputs.self) checks; |
| 100 | + }; |
| 101 | + in |
| 102 | + allJobs |
| 103 | + // { |
| 104 | + required = inputs.nixpkgs.legacyPackages.x86_64-linux.releaseTools.aggregate { |
| 105 | + name = "github-required"; |
| 106 | + meta.description = "All jobs required to pass CI"; |
| 107 | + constituents = lib.collect lib.isDerivation allJobs; |
| 108 | + }; |
| 109 | + }; |
| 110 | + |
| 111 | + nixConfig = { |
| 112 | + extra-substituters = ["https://cache.iog.io"]; |
| 113 | + extra-trusted-public-keys = ["hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="]; |
| 114 | + allow-import-from-derivation = "true"; |
| 115 | + }; |
| 116 | + }; |
| 117 | + }); |
| 118 | +} |
0 commit comments