Skip to content

Commit 5307784

Browse files
committed
bump version
1 parent 98260c0 commit 5307784

File tree

4 files changed

+144
-8
lines changed

4 files changed

+144
-8
lines changed

nix/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sources.nixpkgs {
44
overlays = [
55
(_: pkgs: {
6+
flake-compat = import sources.flake-compat;
67
go = pkgs.go_1_22;
78
go-ethereum = pkgs.callPackage ./go-ethereum.nix {
89
inherit (pkgs.darwin) libobjc;

nix/flake.nix

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
4+
flake-utils.url = "github:numtide/flake-utils";
5+
nix-bundle-exe = {
6+
url = "github:3noch/nix-bundle-exe";
7+
flake = false;
8+
};
9+
gomod2nix = {
10+
url = "github:nix-community/gomod2nix";
11+
inputs.nixpkgs.follows = "nixpkgs";
12+
inputs.flake-utils.follows = "flake-utils";
13+
};
14+
};
15+
16+
outputs = { self, nixpkgs, nix-bundle-exe, gomod2nix, flake-utils }:
17+
let
18+
rev = self.shortRev or "dirty";
19+
mkApp = drv: {
20+
type = "app";
21+
program = "${drv}/bin/${drv.meta.mainProgram}";
22+
};
23+
in
24+
(flake-utils.lib.eachDefaultSystem
25+
(system:
26+
let
27+
pkgs = import nixpkgs {
28+
inherit system;
29+
overlays = [
30+
(import ./nix/build_overlay.nix)
31+
gomod2nix.overlays.default
32+
self.overlay
33+
];
34+
config = { };
35+
};
36+
in
37+
rec {
38+
packages = pkgs.cronos-matrix // {
39+
inherit (pkgs) rocksdb;
40+
};
41+
apps = {
42+
cronosd = mkApp packages.cronosd;
43+
cronosd-testnet = mkApp packages.cronosd-testnet;
44+
};
45+
defaultPackage = packages.cronosd;
46+
defaultApp = apps.cronosd;
47+
devShells = {
48+
default = pkgs.mkShell {
49+
buildInputs = [
50+
defaultPackage.go
51+
pkgs.gomod2nix
52+
];
53+
};
54+
rocksdb = pkgs.mkShell {
55+
buildInputs = [
56+
defaultPackage.go
57+
pkgs.gomod2nix
58+
pkgs.rocksdb
59+
];
60+
};
61+
};
62+
legacyPackages = pkgs;
63+
}
64+
)
65+
) // {
66+
overlay = final: super: {
67+
go = super.go_1_22;
68+
bundle-exe = final.pkgsBuildBuild.callPackage nix-bundle-exe { };
69+
# make-tarball don't follow symbolic links to avoid duplicate file, the bundle should have no external references.
70+
# reset the ownership and permissions to make the extract result more normal.
71+
make-tarball = drv: final.runCommand "tarball-${drv.name}"
72+
{
73+
nativeBuildInputs = with final.buildPackages; [ gnutar gzip ];
74+
} ''
75+
tar cfv - -C "${drv}" \
76+
--owner=0 --group=0 --mode=u+rw,uga+r --hard-dereference . \
77+
| gzip -9 > $out
78+
'';
79+
bundle-win-exe = drv: final.callPackage ./nix/bundle-win-exe.nix { cronosd = drv; };
80+
} // (with final;
81+
let
82+
matrix = lib.cartesianProductOfSets {
83+
network = [ "mainnet" "testnet" ];
84+
pkgtype = [
85+
"nix" # normal nix package
86+
"bundle" # relocatable bundled package
87+
"tarball" # tarball of the bundle, for distribution and checksum
88+
];
89+
};
90+
binaries = builtins.listToAttrs (builtins.map
91+
({ network, pkgtype }: {
92+
name = builtins.concatStringsSep "-" (
93+
[ "cronosd" ] ++
94+
lib.optional (network != "mainnet") network ++
95+
lib.optional (pkgtype != "nix") pkgtype
96+
);
97+
value =
98+
let
99+
cronosd = callPackage ./. {
100+
inherit rev network;
101+
};
102+
bundle =
103+
if stdenv.hostPlatform.isWindows then
104+
bundle-win-exe cronosd
105+
else
106+
bundle-exe cronosd;
107+
in
108+
if pkgtype == "bundle" then
109+
bundle
110+
else if pkgtype == "tarball" then
111+
make-tarball bundle
112+
else
113+
cronosd;
114+
})
115+
matrix
116+
);
117+
in
118+
{
119+
cronos-matrix = binaries;
120+
}
121+
);
122+
};
123+
}

nix/sources.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,17 @@
5858
"type": "tarball",
5959
"url": "https://github.com/nix-community/poetry2nix/archive/4eb2ac54029af42a001c9901194e9ce19cbd8a40.tar.gz",
6060
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
61+
},
62+
"flake-compat": {
63+
"branch": "master",
64+
"description": null,
65+
"homepage": null,
66+
"owner": "edolstra",
67+
"repo": "flake-compat",
68+
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
69+
"sha256": "1qc703yg0babixi6wshn5wm2kgl5y1drcswgszh4xxzbrwkk9sv7",
70+
"type": "tarball",
71+
"url": "https://github.com/edolstra/flake-compat/archive/b4a34015c698c7793d592d66adbab377907a2be8.tar.gz",
72+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
6173
}
6274
}

tests/integration_tests/configs/upgrade-test-package.nix

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
let
22
pkgs = import ../../../nix { };
3-
fetchEthermint = rev: builtins.fetchTarball "https://github.com/evmos/ethermint/archive/${rev}.tar.gz";
4-
released = pkgs.buildGo120Module rec {
5-
name = "ethermintd";
6-
src = fetchEthermint "d29cdad6e667f6089dfecbedd36bb8d3a2a7d025";
7-
subPackages = [ "cmd/ethermintd" ];
8-
vendorHash = "sha256-cQAol54b6hNzsA4Q3MP9mTqFWM1MvR5uMPrYpaoj3SY=";
9-
doCheck = false;
10-
};
3+
fetchFlake = repo: rev: (pkgs.flake-compat {
4+
src = {
5+
outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz";
6+
inherit rev;
7+
shortRev = builtins.substring 0 7 rev;
8+
};
9+
}).defaultNix;
10+
released = (fetchFlake "crypto-org-chain/ethermint" "27d29ccdc275e5771f1febf4354c57566f9d18e5").default;
1111
current = pkgs.callPackage ../../../. { };
1212
in
1313
pkgs.linkFarm "upgrade-test-package" [

0 commit comments

Comments
 (0)