Skip to content

Commit 2907ff2

Browse files
committed
Add a Nix flake with a devshell, and package builds
Resolves blockfrost/blockfrost-ops#2023
1 parent 976793e commit 2907ff2

File tree

12 files changed

+727
-4
lines changed

12 files changed

+727
-4
lines changed

.envrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
use flake
2+
3+
source_env_if_exists .envrc.local

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
target
22
README.html
3+
4+
# Nix
5+
result
6+
result-*
7+
8+
# direnv
9+
.direnv/
10+
.envrc.local

flake.lock

Lines changed: 210 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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+
}

modules/genesis_bootstrapper/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async fn fetch_bytes(client: &reqwest::Client, url: &str) -> Result<Vec<u8>> {
1515
if let Ok(path) = env::var("ACROPOLIS_OFFLINE_MIRROR") {
1616
if let Ok(file) = File::open(&path) {
1717
if let Ok(map) = from_reader::<_, HashMap<String, String>>(file) {
18-
if let Some(path) = map.get(url) {
18+
if let Some(path) = map.get(url.trim()) {
1919
if let Ok(bytes) = fs::read(&Path::new(path).to_path_buf()) {
2020
return Ok(bytes);
2121
}

modules/parameters_state/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn fetch_text(url: &str) -> Result<String, Box<dyn std::error::Error>> {
1515
if !path.is_empty() {
1616
if let Ok(file) = File::open(path) {
1717
if let Ok(map) = from_reader::<_, HashMap<String, String>>(file) {
18-
if let Some(path_str) = map.get(url) {
18+
if let Some(path_str) = map.get(url.trim()) {
1919
if let Ok(s) = fs::read_to_string(&Path::new(path_str).to_path_buf()) {
2020
return Ok(s);
2121
}

0 commit comments

Comments
 (0)