diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index dc8f1e64d6..5549333dd2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -102,5 +102,5 @@ jobs: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} if: steps.changed-files.outputs.any_changed == 'true' - - run: nix-shell -I nixpkgs=./nix -p nixpkgs-fmt --run "make lint-nix" + - run: nix-shell -I nixpkgs=./nix -p nixfmt-rfc-style --run "make lint-nix" if: steps.changed-files.outputs.any_changed == 'true' diff --git a/Makefile b/Makefile index 33cbf460b5..aa76077427 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,7 @@ lint-py: --format="::error file=%(path)s,line=%(row)d,col=%(col)d::%(path)s:%(row)d:%(col)d: %(code)s %(text)s" \ lint-nix: - find . -name "*.nix" ! -path './integration_tests/contracts/*' ! -path "./contracts/*" | xargs nixpkgs-fmt --check + find . -name "*.nix" ! -path './integration_tests/contracts/*' ! -path "./contracts/*" | xargs nixfmt -c .PHONY: lint lint-fix lint-py diff --git a/default.nix b/default.nix index e6e031cfa8..0693389f3d 100644 --- a/default.nix +++ b/default.nix @@ -1,19 +1,28 @@ -{ lib -, stdenv -, buildGoApplication -, nix-gitignore -, buildPackages -, coverage ? false # https://tip.golang.org/doc/go1.20#cover -, rocksdb -, network ? "mainnet" # mainnet|testnet -, rev ? "dirty" -, static ? stdenv.hostPlatform.isStatic -, nativeByteOrder ? true # nativeByteOrder mode will panic on big endian machines +{ + lib, + stdenv, + buildGoApplication, + nix-gitignore, + buildPackages, + coverage ? false, # https://tip.golang.org/doc/go1.20#cover + rocksdb, + network ? "mainnet", # mainnet|testnet + rev ? "dirty", + static ? stdenv.hostPlatform.isStatic, + nativeByteOrder ? true, # nativeByteOrder mode will panic on big endian machines }: let version = "v1.4.0"; pname = "cronosd"; - tags = [ "ledger" "netgo" network "rocksdb" "grocksdb_no_link" "pebbledb" "objstore" ] ++ lib.optionals nativeByteOrder [ "nativebyteorder" ]; + tags = [ + "ledger" + "netgo" + network + "rocksdb" + "grocksdb_no_link" + "pebbledb" + "objstore" + ] ++ lib.optionals nativeByteOrder [ "nativebyteorder" ]; ldflags = lib.concatStringsSep "\n" ([ "-X github.com/cosmos/cosmos-sdk/version.Name=cronos" "-X github.com/cosmos/cosmos-sdk/version.AppName=${pname}" @@ -24,29 +33,40 @@ let buildInputs = [ rocksdb ]; in buildGoApplication rec { - inherit pname version buildInputs tags ldflags; - src = (nix-gitignore.gitignoreSourcePure [ - "/*" # ignore all, then add whitelists - "!/x/" - "!/app/" - "!/cmd/" - "!/client/" - "!/versiondb/" - "!/memiavl/" - "!/store/" - "!go.mod" - "!go.sum" - "!gomod2nix.toml" - ] ./.); + inherit + pname + version + buildInputs + tags + ldflags + ; + src = ( + nix-gitignore.gitignoreSourcePure [ + "/*" # ignore all, then add whitelists + "!/x/" + "!/app/" + "!/cmd/" + "!/client/" + "!/versiondb/" + "!/memiavl/" + "!/store/" + "!go.mod" + "!go.sum" + "!gomod2nix.toml" + ] ./. + ); modules = ./gomod2nix.toml; pwd = src; # needed to support replace subPackages = [ "cmd/cronosd" ]; buildFlags = lib.optionalString coverage "-cover"; CGO_ENABLED = "1"; CGO_LDFLAGS = lib.optionalString (rocksdb != null) ( - if static then "-lrocksdb -pthread -lstdc++ -ldl -lzstd -lsnappy -llz4 -lbz2 -lz" - else if stdenv.hostPlatform.isWindows then "-lrocksdb-shared" - else "-lrocksdb -pthread -lstdc++ -ldl" + if static then + "-lrocksdb -pthread -lstdc++ -ldl -lzstd -lsnappy -llz4 -lbz2 -lz" + else if stdenv.hostPlatform.isWindows then + "-lrocksdb-shared" + else + "-lrocksdb -pthread -lstdc++ -ldl" ); postFixup = lib.optionalString (stdenv.isDarwin && rocksdb != null) '' diff --git a/flake.nix b/flake.nix index 3eef421c63..c58d275d91 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,15 @@ }; }; - outputs = { self, nixpkgs, nix-bundle-exe, gomod2nix, flake-utils, poetry2nix }: + outputs = + { + self, + nixpkgs, + nix-bundle-exe, + gomod2nix, + flake-utils, + poetry2nix, + }: let rev = self.shortRev or "dirty"; mkApp = drv: { @@ -26,52 +34,49 @@ program = "${drv}/bin/${drv.meta.mainProgram}"; }; in - (flake-utils.lib.eachDefaultSystem - (system: - let - pkgs = import nixpkgs { - inherit system; - overlays = self.overlays.default; - config = { }; + (flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { + inherit system; + overlays = self.overlays.default; + config = { }; + }; + in + rec { + packages = pkgs.cronos-matrix // { + inherit (pkgs) rocksdb testground-image; + }; + apps = { + cronosd = mkApp packages.cronosd; + cronosd-testnet = mkApp packages.cronosd-testnet; + stateless-testcase = { + type = "app"; + program = "${pkgs.benchmark-testcase}/bin/stateless-testcase"; }; - in - rec { - packages = pkgs.cronos-matrix // { - inherit (pkgs) rocksdb testground-image; + }; + defaultPackage = packages.cronosd; + defaultApp = apps.cronosd; + devShells = rec { + default = pkgs.mkShell { + buildInputs = [ + defaultPackage.go + pkgs.gomod2nix + pkgs.nixfmt-rfc-style + ]; }; - apps = { - cronosd = mkApp packages.cronosd; - cronosd-testnet = mkApp packages.cronosd-testnet; - stateless-testcase = { - type = "app"; - program = "${pkgs.benchmark-testcase}/bin/stateless-testcase"; - }; + rocksdb = pkgs.mkShell { + buildInputs = default.buildInputs ++ [ + pkgs.rocksdb + pkgs.rocksdb.tools + ]; }; - defaultPackage = packages.cronosd; - defaultApp = apps.cronosd; - devShells = rec { - default = pkgs.mkShell { - buildInputs = [ - defaultPackage.go - pkgs.gomod2nix - ]; - }; - rocksdb = pkgs.mkShell { - buildInputs = default.buildInputs ++ [ - pkgs.rocksdb - pkgs.rocksdb.tools - ]; - }; - full = pkgs.mkShell { - buildInputs = rocksdb.buildInputs ++ [ - pkgs.test-env - ]; - }; - }; - legacyPackages = pkgs; - } - ) - ) // { + full = pkgs.mkShell { buildInputs = rocksdb.buildInputs ++ [ pkgs.test-env ]; }; + }; + legacyPackages = pkgs; + } + )) + // { overlays.default = [ (import ./nix/build_overlay.nix) poetry2nix.overlays.default diff --git a/integration_tests/configs/broken-cronosd.nix b/integration_tests/configs/broken-cronosd.nix index 9242c004ad..508761270d 100644 --- a/integration_tests/configs/broken-cronosd.nix +++ b/integration_tests/configs/broken-cronosd.nix @@ -1,8 +1,9 @@ -{ pkgs ? import ../../nix { } }: -let cronosd = (pkgs.callPackage ../../. { }); +{ + pkgs ? import ../../nix { }, +}: +let + cronosd = (pkgs.callPackage ../../. { }); in cronosd.overrideAttrs (oldAttrs: { - patches = oldAttrs.patches or [ ] ++ [ - ./broken-cronosd.patch - ]; + patches = oldAttrs.patches or [ ] ++ [ ./broken-cronosd.patch ]; }) diff --git a/integration_tests/configs/upgrade-test-package.nix b/integration_tests/configs/upgrade-test-package.nix index 41b8d98d6f..e648394266 100644 --- a/integration_tests/configs/upgrade-test-package.nix +++ b/integration_tests/configs/upgrade-test-package.nix @@ -1,26 +1,47 @@ let pkgs = import ../../nix { }; - fetchFlake = repo: rev: (pkgs.flake-compat { - src = { - outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz"; - inherit rev; - shortRev = builtins.substring 0 7 rev; - }; - }).defaultNix; + fetchFlake = + repo: rev: + (pkgs.flake-compat { + src = { + outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz"; + inherit rev; + shortRev = builtins.substring 0 7 rev; + }; + }).defaultNix; # v1.0.15 - releasedGenesis = (fetchFlake "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default; + releasedGenesis = + (fetchFlake "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default; # release/v1.1.x - released1_1 = (fetchFlake "crypto-org-chain/cronos" "69a80154b6b24fca15f3562e2c4b312ee1092220").default; + released1_1 = + (fetchFlake "crypto-org-chain/cronos" "69a80154b6b24fca15f3562e2c4b312ee1092220").default; # release/v1.2.x - released1_2 = (fetchFlake "crypto-org-chain/cronos" "1aea999eef67a0a01b22422bad94b36e45b9759a").default; + released1_2 = + (fetchFlake "crypto-org-chain/cronos" "1aea999eef67a0a01b22422bad94b36e45b9759a").default; # release/v1.3.x - released1_3 = (fetchFlake "crypto-org-chain/cronos" "e1d819c862b30f0ce978baf2addb12516568639e").default; + released1_3 = + (fetchFlake "crypto-org-chain/cronos" "e1d819c862b30f0ce978baf2addb12516568639e").default; current = pkgs.callPackage ../../. { }; in pkgs.linkFarm "upgrade-test-package" [ - { name = "genesis"; path = releasedGenesis; } - { name = "v1.1.0"; path = released1_1; } - { name = "v1.2"; path = released1_2; } - { name = "v1.3"; path = released1_3; } - { name = "v1.4"; path = current; } + { + name = "genesis"; + path = releasedGenesis; + } + { + name = "v1.1.0"; + path = released1_1; + } + { + name = "v1.2"; + path = released1_2; + } + { + name = "v1.3"; + path = released1_3; + } + { + name = "v1.4"; + path = current; + } ] diff --git a/integration_tests/shell.nix b/integration_tests/shell.nix index fe275138a5..1d4c56d4f8 100644 --- a/integration_tests/shell.nix +++ b/integration_tests/shell.nix @@ -1,4 +1,7 @@ -{ system ? builtins.currentSystem, pkgs ? import ../nix { inherit system; } }: +{ + system ? builtins.currentSystem, + pkgs ? import ../nix { inherit system; }, +}: let renameExe = pkgs.callPackage ../nix/rename-exe.nix { }; in @@ -18,7 +21,7 @@ pkgs.mkShell { (renameExe pkgs.solc-static-versions.solc_0_6_8 "solc-0.6.8" "solc06") (renameExe pkgs.solc-static-versions.solc_0_8_21 "solc-0.8.21" "solc08") pkgs.test-env - pkgs.nixpkgs-fmt + pkgs.nixfmt-rfc-style pkgs.rocksdb pkgs.chain-maind pkgs.hermes diff --git a/nix/bundle-win-exe.nix b/nix/bundle-win-exe.nix index 44bcf323d7..5817b15823 100644 --- a/nix/bundle-win-exe.nix +++ b/nix/bundle-win-exe.nix @@ -1,35 +1,37 @@ -{ runCommand -, windows -, stdenv -, rocksdb -, bzip2 -, lz4 -, snappy -, zstd -, zlib -, cronosd +{ + runCommand, + windows, + stdenv, + rocksdb, + bzip2, + lz4, + snappy, + zstd, + zlib, + cronosd, }: runCommand "tarball-${cronosd.name}" -{ - # manually enumerate the runtime dependencies of cronosd on mingwW64 - deps = [ - "${rocksdb}/bin/librocksdb-shared.dll" - "${snappy}/bin/libsnappy.dll" - "${lz4.out}/lib/liblz4.dll" - "${bzip2.bin}/bin/libbz2-1.dll" - "${zlib}/bin/zlib1.dll" - "${zstd.bin}/bin/libzstd.dll" - "${windows.mingw_w64_pthreads}/bin/libwinpthread-1.dll" - "${windows.mcfgthreads}/bin/libmcfgthread-1.dll" - "${stdenv.cc.cc.lib}/x86_64-w64-mingw32/lib/libgcc_s_seh-1.dll" - "${stdenv.cc.cc.lib}/x86_64-w64-mingw32/lib/libstdc++-6.dll" - ]; -} '' - mkdir -p $out - for so in $deps - do - cp $so $out/ - done + { + # manually enumerate the runtime dependencies of cronosd on mingwW64 + deps = [ + "${rocksdb}/bin/librocksdb-shared.dll" + "${snappy}/bin/libsnappy.dll" + "${lz4.out}/lib/liblz4.dll" + "${bzip2.bin}/bin/libbz2-1.dll" + "${zlib}/bin/zlib1.dll" + "${zstd.bin}/bin/libzstd.dll" + "${windows.mingw_w64_pthreads}/bin/libwinpthread-1.dll" + "${windows.mcfgthreads}/bin/libmcfgthread-1.dll" + "${stdenv.cc.cc.lib}/x86_64-w64-mingw32/lib/libgcc_s_seh-1.dll" + "${stdenv.cc.cc.lib}/x86_64-w64-mingw32/lib/libstdc++-6.dll" + ]; + } + '' + mkdir -p $out + for so in $deps + do + cp $so $out/ + done - cp ${cronosd}/bin/${cronosd.meta.mainProgram} $out/ -'' + cp ${cronosd}/bin/${cronosd.meta.mainProgram} $out/ + '' diff --git a/nix/cosmovisor.nix b/nix/cosmovisor.nix index 16ca179e65..598cd908ad 100644 --- a/nix/cosmovisor.nix +++ b/nix/cosmovisor.nix @@ -1,6 +1,4 @@ -{ buildGoModule -, fetchFromGitHub -}: +{ buildGoModule, fetchFromGitHub }: let version = "1.5.0"; diff --git a/nix/cronos-matrix.nix b/nix/cronos-matrix.nix index e6016121bb..65f45e1261 100644 --- a/nix/cronos-matrix.nix +++ b/nix/cronos-matrix.nix @@ -1,25 +1,35 @@ -{ lib -, stdenv -, callPackage -, buildPackages -, runCommand -, bundle-exe -, rev ? "dirty" +{ + lib, + stdenv, + callPackage, + buildPackages, + runCommand, + bundle-exe, + rev ? "dirty", }: let # make-tarball don't follow symbolic links to avoid duplicate file, the bundle should have no external references. # reset the ownership and permissions to make the extract result more normal. - make-tarball = drv: runCommand "tarball-${drv.name}" - { - nativeBuildInputs = with buildPackages; [ gnutar gzip ]; - } '' - tar cfv - -C "${drv}" \ - --owner=0 --group=0 --mode=u+rw,uga+r --hard-dereference . \ - | gzip -9 > $out - ''; + make-tarball = + drv: + runCommand "tarball-${drv.name}" + { + nativeBuildInputs = with buildPackages; [ + gnutar + gzip + ]; + } + '' + tar cfv - -C "${drv}" \ + --owner=0 --group=0 --mode=u+rw,uga+r --hard-dereference . \ + | gzip -9 > $out + ''; bundle-win-exe = drv: callPackage ./bundle-win-exe.nix { cronosd = drv; }; matrix = lib.cartesianProductOfSets { - network = [ "mainnet" "testnet" ]; + network = [ + "mainnet" + "testnet" + ]; pkgtype = [ "nix" # normal nix package "bundle" # relocatable bundled package @@ -27,30 +37,26 @@ let ]; }; in -builtins.listToAttrs (builtins.map - ({ network, pkgtype }: { - name = builtins.concatStringsSep "-" ( - [ "cronosd" ] ++ - lib.optional (network != "mainnet") network ++ - lib.optional (pkgtype != "nix") pkgtype - ); - value = - let - cronosd = callPackage ../. { - inherit rev network; - }; - bundle = - if stdenv.hostPlatform.isWindows then - bundle-win-exe cronosd - else - bundle-exe cronosd; - in - if pkgtype == "bundle" then - bundle - else if pkgtype == "tarball" then - make-tarball bundle - else - cronosd; - }) - matrix +builtins.listToAttrs ( + builtins.map ( + { network, pkgtype }: + { + name = builtins.concatStringsSep "-" ( + [ "cronosd" ] + ++ lib.optional (network != "mainnet") network + ++ lib.optional (pkgtype != "nix") pkgtype + ); + value = + let + cronosd = callPackage ../. { inherit rev network; }; + bundle = if stdenv.hostPlatform.isWindows then bundle-win-exe cronosd else bundle-exe cronosd; + in + if pkgtype == "bundle" then + bundle + else if pkgtype == "tarball" then + make-tarball bundle + else + cronosd; + } + ) matrix ) diff --git a/nix/dapptools-overlay.nix b/nix/dapptools-overlay.nix index ace97cca95..1cb68e20a2 100644 --- a/nix/dapptools-overlay.nix +++ b/nix/dapptools-overlay.nix @@ -1,19 +1,16 @@ { dapptools-release, dapptools-master }: self: super: let - dapptools = { - x86_64-linux = - (import (dapptools-release + "/release.nix") { }).dapphub.linux.stable; - x86_64-darwin = - (import (dapptools-release + "/release.nix") { }).dapphub.darwin.stable; - }.${self.system} or (throw - "Unsupported system: ${self.system}"); + dapptools = + { + x86_64-linux = (import (dapptools-release + "/release.nix") { }).dapphub.linux.stable; + x86_64-darwin = (import (dapptools-release + "/release.nix") { }).dapphub.darwin.stable; + } + .${self.system} or (throw "Unsupported system: ${self.system}"); dapptools-patched = self.srcOnly { name = "dapptools-patched"; src = dapptools-master; - patches = [ - ./dapptools.patch - ]; + patches = [ ./dapptools.patch ]; }; in { diff --git a/nix/default.nix b/nix/default.nix index 1f9ffa4451..79ce5b8c8a 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -1,8 +1,15 @@ -{ sources ? import ./sources.nix, system ? builtins.currentSystem, ... }: +{ + sources ? import ./sources.nix, + system ? builtins.currentSystem, + ... +}: import sources.nixpkgs { overlays = [ (import ./build_overlay.nix) - (import ./dapptools-overlay.nix { dapptools-release = sources.dapptools; dapptools-master = sources.dapptools-master; }) + (import ./dapptools-overlay.nix { + dapptools-release = sources.dapptools; + dapptools-master = sources.dapptools-master; + }) (_: pkgs: { go = pkgs.go_1_22; go-ethereum = pkgs.callPackage ./go-ethereum.nix { @@ -15,15 +22,20 @@ import sources.nixpkgs { }) # update to a version that supports eip-1559 (import "${sources.poetry2nix}/overlay.nix") (import "${sources.gomod2nix}/overlay.nix") - (pkgs: _: + ( + pkgs: _: import ./scripts.nix { inherit pkgs; config = { cronos-config = ../scripts/cronos-devnet.yaml; geth-genesis = ../scripts/geth-genesis.json; - dotenv = builtins.path { name = "dotenv"; path = ../scripts/.env; }; + dotenv = builtins.path { + name = "dotenv"; + path = ../scripts/.env; + }; }; - }) + } + ) (_: pkgs: { gorc = pkgs.rustPlatform.buildRustPackage rec { name = "gorc"; @@ -31,21 +43,27 @@ import sources.nixpkgs { sourceRoot = "gravity-bridge-src/orchestrator"; cargoSha256 = "sha256-FQ43PFGbagIi+KZ6KUtjF7OClIkCqKd4pGzHaYr2Q+A="; cargoBuildFlags = "-p ${name} --features ethermint"; - buildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin - (with pkgs.darwin.apple_sdk.frameworks; [ CoreFoundation Security ]); + buildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin ( + with pkgs.darwin.apple_sdk.frameworks; + [ + CoreFoundation + Security + ] + ); doCheck = false; OPENSSL_NO_VENDOR = "1"; OPENSSL_DIR = pkgs.symlinkJoin { name = "openssl"; - paths = with pkgs.openssl; [ out dev ]; + paths = with pkgs.openssl; [ + out + dev + ]; }; }; hermes = pkgs.callPackage ./hermes.nix { src = sources.ibc-rs; }; }) (_: pkgs: { test-env = pkgs.callPackage ./testenv.nix { }; }) - (_: pkgs: { - cosmovisor = pkgs.callPackage ./cosmovisor.nix { }; - }) + (_: pkgs: { cosmovisor = pkgs.callPackage ./cosmovisor.nix { }; }) (_: pkgs: { rly = pkgs.buildGo121Module rec { name = "rly"; diff --git a/nix/gen-binding-shell.nix b/nix/gen-binding-shell.nix index 2ac5711a47..8409c332ff 100644 --- a/nix/gen-binding-shell.nix +++ b/nix/gen-binding-shell.nix @@ -1,4 +1,7 @@ -{ system ? builtins.currentSystem, pkgs ? import ./. { inherit system; } }: +{ + system ? builtins.currentSystem, + pkgs ? import ./. { inherit system; }, +}: let renameExe = pkgs.callPackage ./rename-exe.nix { }; in diff --git a/nix/go-ethereum.nix b/nix/go-ethereum.nix index b8651acaf1..8e5862b57b 100644 --- a/nix/go-ethereum.nix +++ b/nix/go-ethereum.nix @@ -1,4 +1,11 @@ -{ lib, stdenv, buildGoModule, fetchFromGitHub, libobjc, IOKit }: +{ + lib, + stdenv, + buildGoModule, + fetchFromGitHub, + libobjc, + IOKit, +}: let # A list of binaries to put into separate outputs @@ -27,7 +34,10 @@ buildGoModule rec { # Move binaries to separate outputs and symlink them back to $out postInstall = lib.concatStringsSep "\n" ( - builtins.map (bin: "mkdir -p \$${bin}/bin && mv $out/bin/${bin} \$${bin}/bin/ && ln -s \$${bin}/bin/${bin} $out/bin/") bins + builtins.map ( + bin: + "mkdir -p \$${bin}/bin && mv $out/bin/${bin} \$${bin}/bin/ && ln -s \$${bin}/bin/${bin} $out/bin/" + ) bins ); subPackages = [ @@ -47,13 +57,22 @@ buildGoModule rec { ]; # Fix for usb-related segmentation faults on darwin - propagatedBuildInputs = - lib.optionals stdenv.isDarwin [ libobjc IOKit ]; + propagatedBuildInputs = lib.optionals stdenv.isDarwin [ + libobjc + IOKit + ]; meta = with lib; { homepage = "https://geth.ethereum.org/"; description = "Official golang implementation of the Ethereum protocol"; - license = with licenses; [ lgpl3Plus gpl3Plus ]; - maintainers = with maintainers; [ adisbladis lionello RaghavSood ]; + license = with licenses; [ + lgpl3Plus + gpl3Plus + ]; + maintainers = with maintainers; [ + adisbladis + lionello + RaghavSood + ]; }; } diff --git a/nix/golangci-lint.nix b/nix/golangci-lint.nix index 9845f267dc..9f94ac696d 100644 --- a/nix/golangci-lint.nix +++ b/nix/golangci-lint.nix @@ -1,4 +1,9 @@ -{ buildGo123Module, fetchFromGitHub, lib, installShellFiles }: +{ + buildGo123Module, + fetchFromGitHub, + lib, + installShellFiles, +}: buildGo123Module rec { pname = "golangci-lint"; @@ -38,6 +43,9 @@ buildGo123Module rec { changelog = "https://github.com/golangci/golangci-lint/blob/v${version}/CHANGELOG.md"; mainProgram = "golangci-lint"; license = licenses.gpl3Plus; - maintainers = with maintainers; [ SuperSandro2000 mic92 ]; + maintainers = with maintainers; [ + SuperSandro2000 + mic92 + ]; }; } diff --git a/nix/hermes.nix b/nix/hermes.nix index 04a7352d7d..22895543b5 100644 --- a/nix/hermes.nix +++ b/nix/hermes.nix @@ -1,11 +1,12 @@ -{ src -, lib -, stdenv -, darwin -, rustPlatform -, symlinkJoin -, openssl -, pkg-config +{ + src, + lib, + stdenv, + darwin, + rustPlatform, + symlinkJoin, + openssl, + pkg-config, }: rustPlatform.buildRustPackage rec { @@ -30,6 +31,9 @@ rustPlatform.buildRustPackage rec { OPENSSL_NO_VENDOR = "1"; OPENSSL_DIR = symlinkJoin { name = "openssl"; - paths = with openssl; [ out dev ]; + paths = with openssl; [ + out + dev + ]; }; } diff --git a/nix/rocksdb.nix b/nix/rocksdb.nix index 0c33ca248e..32e1e0720e 100644 --- a/nix/rocksdb.nix +++ b/nix/rocksdb.nix @@ -1,21 +1,22 @@ -{ lib -, stdenv -, fetchFromGitHub -, fetchpatch -, cmake -, ninja -, bzip2 -, lz4 -, snappy -, zlib -, zstd -, windows +{ + lib, + stdenv, + fetchFromGitHub, + fetchpatch, + cmake, + ninja, + bzip2, + lz4, + snappy, + zlib, + zstd, + windows, # only enable jemalloc for non-windows platforms # see: https://github.com/NixOS/nixpkgs/issues/216479 -, enableJemalloc ? !stdenv.hostPlatform.isWindows && !stdenv.hostPlatform.isStatic -, jemalloc -, enableShared ? !stdenv.hostPlatform.isStatic -, sse42Support ? stdenv.hostPlatform.sse4_2Support + enableJemalloc ? !stdenv.hostPlatform.isWindows && !stdenv.hostPlatform.isStatic, + jemalloc, + enableShared ? !stdenv.hostPlatform.isStatic, + sse42Support ? stdenv.hostPlatform.sse4_2Support, }: stdenv.mkDerivation (finalAttrs: { @@ -29,11 +30,21 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-u5uuShM2SxHc9/zL4UU56IhCcR/ZQbzde0LgOYS44bM="; }; - nativeBuildInputs = [ cmake ninja ]; + nativeBuildInputs = [ + cmake + ninja + ]; - propagatedBuildInputs = [ bzip2 lz4 snappy zlib zstd ]; + propagatedBuildInputs = [ + bzip2 + lz4 + snappy + zlib + zstd + ]; - buildInputs = lib.optional enableJemalloc jemalloc + buildInputs = + lib.optional enableJemalloc jemalloc ++ lib.optional stdenv.hostPlatform.isMinGW windows.mingw_w64_pthreads; outputs = [ @@ -41,9 +52,7 @@ stdenv.mkDerivation (finalAttrs: { "tools" ]; - env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isClang [ - "-faligned-allocation" - ]); + env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isClang [ "-faligned-allocation" ]); cmakeFlags = [ "-DPORTABLE=1" @@ -68,46 +77,55 @@ stdenv.mkDerivation (finalAttrs: { # otherwise "cc1: error: -Wformat-security ignored without -Wformat [-Werror=format-security]" hardeningDisable = lib.optional stdenv.hostPlatform.isWindows "format"; - postPatch = lib.optionalString (lib.versionOlder finalAttrs.version "9") '' - # Fix gcc-13 build failures due to missing and - # includes, fixed upstream since 9.x - sed -e '1i #include ' -i options/offpeak_time_info.h - '' + lib.optionalString (lib.versionOlder finalAttrs.version "8") '' - # Fix gcc-13 build failures due to missing and - # includes, fixed upstream since 8.x - sed -e '1i #include ' -i db/compaction/compaction_iteration_stats.h - sed -e '1i #include ' -i table/block_based/data_block_hash_index.h - sed -e '1i #include ' -i util/string_util.h - sed -e '1i #include ' -i include/rocksdb/utilities/checkpoint.h - '' + lib.optionalString (lib.versionOlder finalAttrs.version "7") '' - # Fix gcc-13 build failures due to missing and - # includes, fixed upstream since 7.x - sed -e '1i #include ' -i third-party/folly/folly/synchronization/detail/ProxyLockable-inl.h - '' + '' - # fixed in https://github.com/facebook/rocksdb/pull/12309 - sed -e 's/ZSTD_INCLUDE_DIRS/zstd_INCLUDE_DIRS/' -i cmake/modules/Findzstd.cmake - sed -e 's/ZSTD_INCLUDE_DIRS/zstd_INCLUDE_DIRS/' -i CMakeLists.txt - ''; + postPatch = + lib.optionalString (lib.versionOlder finalAttrs.version "9") '' + # Fix gcc-13 build failures due to missing and + # includes, fixed upstream since 9.x + sed -e '1i #include ' -i options/offpeak_time_info.h + '' + + lib.optionalString (lib.versionOlder finalAttrs.version "8") '' + # Fix gcc-13 build failures due to missing and + # includes, fixed upstream since 8.x + sed -e '1i #include ' -i db/compaction/compaction_iteration_stats.h + sed -e '1i #include ' -i table/block_based/data_block_hash_index.h + sed -e '1i #include ' -i util/string_util.h + sed -e '1i #include ' -i include/rocksdb/utilities/checkpoint.h + '' + + lib.optionalString (lib.versionOlder finalAttrs.version "7") '' + # Fix gcc-13 build failures due to missing and + # includes, fixed upstream since 7.x + sed -e '1i #include ' -i third-party/folly/folly/synchronization/detail/ProxyLockable-inl.h + '' + + '' + # fixed in https://github.com/facebook/rocksdb/pull/12309 + sed -e 's/ZSTD_INCLUDE_DIRS/zstd_INCLUDE_DIRS/' -i cmake/modules/Findzstd.cmake + sed -e 's/ZSTD_INCLUDE_DIRS/zstd_INCLUDE_DIRS/' -i CMakeLists.txt + ''; - preInstall = '' - mkdir -p $tools/bin - cp tools/{ldb,sst_dump}${stdenv.hostPlatform.extensions.executable} $tools/bin/ - '' + lib.optionalString stdenv.isDarwin '' - ls -1 $tools/bin/* | xargs -I{} ${stdenv.cc.bintools.targetPrefix}install_name_tool -change "@rpath/librocksdb.${lib.versions.major finalAttrs.version}.dylib" $out/lib/librocksdb.dylib {} - '' + lib.optionalString (stdenv.isLinux && enableShared) '' - ls -1 $tools/bin/* | xargs -I{} patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib {} - ''; + preInstall = + '' + mkdir -p $tools/bin + cp tools/{ldb,sst_dump}${stdenv.hostPlatform.extensions.executable} $tools/bin/ + '' + + lib.optionalString stdenv.isDarwin '' + ls -1 $tools/bin/* | xargs -I{} ${stdenv.cc.bintools.targetPrefix}install_name_tool -change "@rpath/librocksdb.${lib.versions.major finalAttrs.version}.dylib" $out/lib/librocksdb.dylib {} + '' + + lib.optionalString (stdenv.isLinux && enableShared) '' + ls -1 $tools/bin/* | xargs -I{} patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib {} + ''; # Old version doesn't ship the .pc file, new version puts wrong paths in there. - postFixup = '' - if [ -f "$out"/lib/pkgconfig/rocksdb.pc ]; then - substituteInPlace "$out"/lib/pkgconfig/rocksdb.pc \ - --replace '="''${prefix}//' '="/' - fi - '' + lib.optionalString stdenv.isDarwin '' - ${stdenv.cc.targetPrefix}install_name_tool -change "@rpath/libsnappy.1.dylib" "${snappy}/lib/libsnappy.1.dylib" $out/lib/librocksdb.dylib - ${stdenv.cc.targetPrefix}install_name_tool -change "@rpath/librocksdb.${lib.versions.major finalAttrs.version}.dylib" "$out/lib/librocksdb.${lib.versions.major finalAttrs.version}.dylib" $out/lib/librocksdb.dylib - ''; + postFixup = + '' + if [ -f "$out"/lib/pkgconfig/rocksdb.pc ]; then + substituteInPlace "$out"/lib/pkgconfig/rocksdb.pc \ + --replace '="''${prefix}//' '="/' + fi + '' + + lib.optionalString stdenv.isDarwin '' + ${stdenv.cc.targetPrefix}install_name_tool -change "@rpath/libsnappy.1.dylib" "${snappy}/lib/libsnappy.1.dylib" $out/lib/librocksdb.dylib + ${stdenv.cc.targetPrefix}install_name_tool -change "@rpath/librocksdb.${lib.versions.major finalAttrs.version}.dylib" "$out/lib/librocksdb.${lib.versions.major finalAttrs.version}.dylib" $out/lib/librocksdb.dylib + ''; meta = with lib; { homepage = "https://rocksdb.org"; @@ -115,6 +133,9 @@ stdenv.mkDerivation (finalAttrs: { changelog = "https://github.com/facebook/rocksdb/raw/v${finalAttrs.version}/HISTORY.md"; license = licenses.asl20; platforms = platforms.all; - maintainers = with maintainers; [ adev magenbluten ]; + maintainers = with maintainers; [ + adev + magenbluten + ]; }; }) diff --git a/nix/scripts.nix b/nix/scripts.nix index 45aa631b3e..64a262acf8 100644 --- a/nix/scripts.nix +++ b/nix/scripts.nix @@ -1,7 +1,9 @@ -{ pkgs -, config -, cronos ? (import ../. { inherit pkgs; }) -}: rec { +{ + pkgs, + config, + cronos ? (import ../. { inherit pkgs; }), +}: +rec { start-cronos = pkgs.writeShellScriptBin "start-cronos" '' # rely on environment to provide cronosd export PATH=${pkgs.test-env}/bin:$PATH @@ -14,6 +16,9 @@ ''; start-scripts = pkgs.symlinkJoin { name = "start-scripts"; - paths = [ start-cronos start-geth ]; + paths = [ + start-cronos + start-geth + ]; }; } diff --git a/nix/sources.nix b/nix/sources.nix index 3f841046a8..c420541d76 100644 --- a/nix/sources.nix +++ b/nix/sources.nix @@ -6,113 +6,159 @@ let # The fetchers. fetch_ fetches specs of type . # - fetch_file = pkgs: name: spec: + fetch_file = + pkgs: name: spec: let name' = sanitizeName name + "-src"; in if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; name = name'; } + builtins_fetchurl { + inherit (spec) url sha256; + name = name'; + } else - pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; + pkgs.fetchurl { + inherit (spec) url sha256; + name = name'; + }; - fetch_tarball = pkgs: name: spec: + fetch_tarball = + pkgs: name: spec: let name' = sanitizeName name + "-src"; in if spec.builtin or true then - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } + builtins_fetchTarball { + name = name'; + inherit (spec) url sha256; + } else - pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; + pkgs.fetchzip { + name = name'; + inherit (spec) url sha256; + }; - fetch_git = name: spec: + fetch_git = + name: spec: let ref = - if spec ? ref then spec.ref else - if spec ? branch then "refs/heads/${spec.branch}" else - if spec ? tag then "refs/tags/${spec.tag}" else - abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; + if spec ? ref then + spec.ref + else if spec ? branch then + "refs/heads/${spec.branch}" + else if spec ? tag then + "refs/tags/${spec.tag}" + else + abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; in - builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; + builtins.fetchGit { + url = spec.repo; + inherit (spec) rev; + inherit ref; + }; fetch_local = spec: spec.path; - fetch_builtin-tarball = name: throw - ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=tarball -a builtin=true''; + fetch_builtin-tarball = + name: + throw '' + [${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=tarball -a builtin=true''; - fetch_builtin-url = name: throw - ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=file -a builtin=true''; + fetch_builtin-url = + name: + throw '' + [${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=file -a builtin=true''; # # Various helpers # # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 - sanitizeName = name: - ( - concatMapStrings (s: if builtins.isList s then "-" else s) - ( - builtins.split "[^[:alnum:]+._?=-]+" - ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) - ) - ); + sanitizeName = + name: + (concatMapStrings (s: if builtins.isList s then "-" else s) ( + builtins.split "[^[:alnum:]+._?=-]+" ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) + )); # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: system: + mkPkgs = + sources: system: let - sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; + sourcesNixpkgs = import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { + inherit system; + }; hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; hasThisAsNixpkgsPath = == ./.; in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then + if builtins.hasAttr "nixpkgs" sources then + sourcesNixpkgs + else if hasNixpkgsPath && !hasThisAsNixpkgsPath then import { } else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; + abort '' + Please specify either (through -I or NIX_PATH=nixpkgs=...) or + add a package called "nixpkgs" to your sources.json. + ''; # The actual fetching function. - fetch = pkgs: name: spec: + fetch = + pkgs: name: spec: - if ! builtins.hasAttr "type" spec then + if !builtins.hasAttr "type" spec then abort "ERROR: niv spec ${name} does not have a 'type' attribute" - else if spec.type == "file" then fetch_file pkgs name spec - else if spec.type == "tarball" then fetch_tarball pkgs name spec - else if spec.type == "git" then fetch_git name spec - else if spec.type == "local" then fetch_local spec - else if spec.type == "builtin-tarball" then fetch_builtin-tarball name - else if spec.type == "builtin-url" then fetch_builtin-url name + else if spec.type == "file" then + fetch_file pkgs name spec + else if spec.type == "tarball" then + fetch_tarball pkgs name spec + else if spec.type == "git" then + fetch_git name spec + else if spec.type == "local" then + fetch_local spec + else if spec.type == "builtin-tarball" then + fetch_builtin-tarball name + else if spec.type == "builtin-url" then + fetch_builtin-url name else abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; # If the environment variable NIV_OVERRIDE_${name} is set, then use # the path directly as opposed to the fetched source. - replace = name: drv: + replace = + name: drv: let saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; in - if ersatz == "" then drv else - # this turns the string into an actual Nix path (for both absolute and - # relative paths) - if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; + if ersatz == "" then + drv + else + # this turns the string into an actual Nix path (for both absolute and + # relative paths) + if builtins.substring 0 1 ersatz == "/" then + /. + ersatz + else + /. + builtins.getEnv "PWD" + "/${ersatz}"; # Ports of functions for older nix versions # a Nix version of mapAttrs if the built-in doesn't exist - mapAttrs = builtins.mapAttrs or ( - f: set: with builtins; - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) - ); + mapAttrs = + builtins.mapAttrs or ( + f: set: + with builtins; + listToAttrs ( + map (attr: { + name = attr; + value = f attr set.${attr}; + }) (attrNames set) + ) + ); # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 - range = first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1); + range = + first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1); # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); @@ -126,7 +172,12 @@ let optionalAttrs = cond: as: if cond then as else { }; # fetchTarball version that is compatible between all the versions of Nix - builtins_fetchTarball = { url, name ? null, sha256 }@attrs: + builtins_fetchTarball = + { + url, + name ? null, + sha256, + }@attrs: let inherit (builtins) lessThan nixVersion fetchTarball; in @@ -136,7 +187,12 @@ let fetchTarball attrs; # fetchurl version that is compatible between all the versions of Nix - builtins_fetchurl = { url, name ? null, sha256 }@attrs: + builtins_fetchurl = + { + url, + name ? null, + sha256, + }@attrs: let inherit (builtins) lessThan nixVersion fetchurl; in @@ -146,26 +202,25 @@ let fetchurl attrs; # Create the final "sources" from the config - mkSources = config: - mapAttrs - ( - name: spec: - if builtins.hasAttr "outPath" spec - then - abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = replace name (fetch config.pkgs name spec); } - ) - config.sources; + mkSources = + config: + mapAttrs ( + name: spec: + if builtins.hasAttr "outPath" spec then + abort "The values in sources.json should not have an 'outPath' attribute" + else + spec // { outPath = replace name (fetch config.pkgs name spec); } + ) config.sources; # The "config" used by the fetchers mkConfig = - { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null - , sources ? if isNull sourcesFile then { } else builtins.fromJSON (builtins.readFile sourcesFile) - , system ? builtins.currentSystem - , pkgs ? mkPkgs sources system - }: rec { + { + sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null, + sources ? if isNull sourcesFile then { } else builtins.fromJSON (builtins.readFile sourcesFile), + system ? builtins.currentSystem, + pkgs ? mkPkgs sources system, + }: + rec { # The sources, i.e. the attribute set of spec name to spec inherit sources; diff --git a/nix/testenv.nix b/nix/testenv.nix index b73aa9ad3c..66952a071d 100644 --- a/nix/testenv.nix +++ b/nix/testenv.nix @@ -1,8 +1,13 @@ -{ poetry2nix, lib, python311 }: +{ + poetry2nix, + lib, + python311, +}: poetry2nix.mkPoetryEnv { projectDir = ../integration_tests; python = python311; - overrides = poetry2nix.overrides.withDefaults (self: super: + overrides = poetry2nix.overrides.withDefaults ( + self: super: let buildSystems = { pystarport = [ "poetry-core" ]; @@ -16,11 +21,11 @@ poetry2nix.mkPoetryEnv { eth-bloom = [ "setuptools" ]; }; in - lib.mapAttrs - (attr: systems: super.${attr}.overridePythonAttrs - (old: { - nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ map (a: self.${a}) systems; - })) - buildSystems + lib.mapAttrs ( + attr: systems: + super.${attr}.overridePythonAttrs (old: { + nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ map (a: self.${a}) systems; + }) + ) buildSystems ); } diff --git a/nix/testground-image.nix b/nix/testground-image.nix index 629ae3ae8c..86c345a442 100644 --- a/nix/testground-image.nix +++ b/nix/testground-image.nix @@ -1,9 +1,12 @@ -{ dockerTools, runCommandLocal, cronos-matrix, benchmark-testcase }: +{ + dockerTools, + runCommandLocal, + cronos-matrix, + benchmark-testcase, +}: let patched-cronosd = cronos-matrix.cronosd.overrideAttrs (oldAttrs: { - patches = oldAttrs.patches or [ ] ++ [ - ./testground-cronosd.patch - ]; + patches = oldAttrs.patches or [ ] ++ [ ./testground-cronosd.patch ]; }); in let @@ -20,10 +23,17 @@ dockerTools.buildLayeredImage { tmpDir ]; config = { - Expose = [ 9090 26657 26656 1317 26658 26660 26659 30000 ]; - Cmd = [ "/bin/stateless-testcase" ]; - Env = [ - "PYTHONUNBUFFERED=1" + Expose = [ + 9090 + 26657 + 26656 + 1317 + 26658 + 26660 + 26659 + 30000 ]; + Cmd = [ "/bin/stateless-testcase" ]; + Env = [ "PYTHONUNBUFFERED=1" ]; }; } diff --git a/testground/benchmark/flake.nix b/testground/benchmark/flake.nix index 234cf58638..4b84c96322 100644 --- a/testground/benchmark/flake.nix +++ b/testground/benchmark/flake.nix @@ -9,38 +9,43 @@ }; }; - outputs = { self, nixpkgs, flake-utils, poetry2nix }: - flake-utils.lib.eachDefaultSystem - (system: - let - pkgs = import nixpkgs { - inherit system; - overlays = [ - poetry2nix.overlays.default - (import ./overlay.nix) - ]; - config = { }; + outputs = + { + self, + nixpkgs, + flake-utils, + poetry2nix, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ + poetry2nix.overlays.default + (import ./overlay.nix) + ]; + config = { }; + }; + in + rec { + packages.default = pkgs.benchmark-testcase; + apps = { + default = { + type = "app"; + program = "${pkgs.benchmark-testcase}/bin/stateless-testcase"; }; - in - rec { - packages.default = pkgs.benchmark-testcase; - apps = { - default = { - type = "app"; - program = "${pkgs.benchmark-testcase}/bin/stateless-testcase"; - }; - stateless-testcase = { - type = "app"; - program = "${pkgs.benchmark-testcase}/bin/stateless-testcase"; - }; - testnet = { - type = "app"; - program = "${pkgs.benchmark-testcase}/bin/testnet"; - }; + stateless-testcase = { + type = "app"; + program = "${pkgs.benchmark-testcase}/bin/stateless-testcase"; }; - devShells.default = pkgs.mkShell { - buildInputs = [ pkgs.benchmark-testcase-env ]; + testnet = { + type = "app"; + program = "${pkgs.benchmark-testcase}/bin/testnet"; }; - legacyPackages = pkgs; - }); + }; + devShells.default = pkgs.mkShell { buildInputs = [ pkgs.benchmark-testcase-env ]; }; + legacyPackages = pkgs; + } + ); } diff --git a/testground/benchmark/overlay.nix b/testground/benchmark/overlay.nix index 3360074e3b..7a9e787f0e 100644 --- a/testground/benchmark/overlay.nix +++ b/testground/benchmark/overlay.nix @@ -1,13 +1,18 @@ final: _: let - overrides = { lib, poetry2nix }: poetry2nix.overrides.withDefaults - (self: super: + overrides = + { lib, poetry2nix }: + poetry2nix.overrides.withDefaults ( + self: super: let buildSystems = { pystarport = [ "poetry-core" ]; durations = [ "setuptools" ]; multitail2 = [ "setuptools" ]; - docker = [ "hatchling" "hatch-vcs" ]; + docker = [ + "hatchling" + "hatch-vcs" + ]; pyunormalize = [ "setuptools" ]; pytest-github-actions-annotate-failures = [ "setuptools" ]; cprotobuf = [ "setuptools" ]; @@ -15,32 +20,48 @@ let flake8-isort = [ "hatchling" ]; }; in - lib.mapAttrs - (attr: systems: super.${attr}.overridePythonAttrs - (old: { - nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ map (a: self.${a}) systems; - })) - buildSystems + lib.mapAttrs ( + attr: systems: + super.${attr}.overridePythonAttrs (old: { + nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ map (a: self.${a}) systems; + }) + ) buildSystems ); - src = nix-gitignore: nix-gitignore.gitignoreSourcePure [ - "/*" # ignore all, then add whitelists - "!/benchmark/" - "!poetry.lock" - "!pyproject.toml" - ] ./.; + src = + nix-gitignore: + nix-gitignore.gitignoreSourcePure [ + "/*" # ignore all, then add whitelists + "!/benchmark/" + "!poetry.lock" + "!pyproject.toml" + ] ./.; - benchmark = { lib, poetry2nix, python311, nix-gitignore }: poetry2nix.mkPoetryApplication { - projectDir = src nix-gitignore; - python = python311; - overrides = overrides { inherit lib poetry2nix; }; - }; + benchmark = + { + lib, + poetry2nix, + python311, + nix-gitignore, + }: + poetry2nix.mkPoetryApplication { + projectDir = src nix-gitignore; + python = python311; + overrides = overrides { inherit lib poetry2nix; }; + }; - benchmark-env = { lib, poetry2nix, python311, nix-gitignore }: poetry2nix.mkPoetryEnv { - projectDir = src nix-gitignore; - python = python311; - overrides = overrides { inherit lib poetry2nix; }; - }; + benchmark-env = + { + lib, + poetry2nix, + python311, + nix-gitignore, + }: + poetry2nix.mkPoetryEnv { + projectDir = src nix-gitignore; + python = python311; + overrides = overrides { inherit lib poetry2nix; }; + }; in {