diff --git a/flake.nix b/flake.nix index 36fc0bfe97..5fea04c927 100644 --- a/flake.nix +++ b/flake.nix @@ -31,12 +31,7 @@ let pkgs = import nixpkgs { inherit system; - overlays = [ - (import ./nix/build_overlay.nix) - poetry2nix.overlays.default - gomod2nix.overlays.default - self.overlay - ]; + overlays = self.overlays.default; config = { }; }; in @@ -73,62 +68,17 @@ } ) ) // { - overlay = final: super: { - go = super.go_1_22; - test-env = final.callPackage ./nix/testenv.nix { }; - bundle-exe = final.pkgsBuildBuild.callPackage nix-bundle-exe { }; - # 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: final.runCommand "tarball-${drv.name}" - { - nativeBuildInputs = with final.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: final.callPackage ./nix/bundle-win-exe.nix { cronosd = drv; }; - } // (with final; - let - matrix = lib.cartesianProductOfSets { - network = [ "mainnet" "testnet" ]; - pkgtype = [ - "nix" # normal nix package - "bundle" # relocatable bundled package - "tarball" # tarball of the bundle, for distribution and checksum - ]; + overlays.default = [ + (import ./nix/build_overlay.nix) + poetry2nix.overlays.default + gomod2nix.overlays.default + (final: super: { + go = super.go_1_22; + test-env = final.callPackage ./nix/testenv.nix { }; + cronos-matrix = final.callPackage ./nix/cronos-matrix.nix { + bundle-exe = final.pkgsBuildBuild.callPackage nix-bundle-exe { }; }; - binaries = 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 - ); - in - { - cronos-matrix = binaries; - } - ); + }) + ]; }; } diff --git a/nix/cronos-matrix.nix b/nix/cronos-matrix.nix new file mode 100644 index 0000000000..d8a585716e --- /dev/null +++ b/nix/cronos-matrix.nix @@ -0,0 +1,58 @@ +{ lib +, stdenv +, callPackage +, pkgsBuildBuild +, buildPackages +, runCommand +, rev ? "dirty" +, bundle-exe +}: +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 + ''; + bundle-win-exe = drv: callPackage ./bundle-win-exe.nix { cronosd = drv; }; + matrix = lib.cartesianProductOfSets { + network = [ "mainnet" "testnet" ]; + pkgtype = [ + "nix" # normal nix package + "bundle" # relocatable bundled package + "tarball" # tarball of the bundle, for distribution and checksum + ]; + }; + binaries = 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 + ); +in +binaries