From 82d23e8f1be7e636c1fde68da98de6a8c271018c Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Tue, 26 May 2026 19:09:25 +0200 Subject: [PATCH] release.nix: init This is a Hydra jobset definition to be used to warm up a cache with Lix versions built against several nixpkgs versions. This is only happening after a bunch of tests have passed. Change-Id: Id0b0e50c08581f3f377c7c793d2fd83a6007999d --- release.nix | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 release.nix diff --git a/release.nix b/release.nix new file mode 100644 index 000000000..29022a7e7 --- /dev/null +++ b/release.nix @@ -0,0 +1,87 @@ +{ + systems ? [ "x86_64-linux" ], + nixpkgs ? , + lixSrc ? builtins.fetchGit ./., +}: + +let + flakeLock = builtins.fromJSON (builtins.readFile (lixSrc + "/flake.lock")); + + fetchFlakeLockInputs = + names: + lib.listToAttrs ( + map ( + inputName: + let + nodeName = flakeLock.nodes.${flakeLock.root}.inputs.${inputName}; + in + lib.nameValuePair inputName (builtins.fetchTree flakeLock.nodes.${nodeName}.locked) + ) names + ); + + lib = import (nixpkgs + "/lib"); + filterSystems = lib.filter (n: builtins.elem n systems); + + inputs = + (import (lixSrc + "/nix-support/build/inputs.nix") ( + fetchFlakeLockInputs [ + "nix2container" + "nixpkgs-regression" + "nix_2_18" + ] + // { + inherit lib nixpkgs lixSrc; + } + )).overrideScope + ( + _: prev: { + linux32BitSystems = filterSystems prev.linux32BitSystems; + linux64BitSystems = filterSystems prev.linux64BitSystems; + darwinSystems = filterSystems prev.darwinSystems; + } + ); + + outputs = inputs.callPackage (lixSrc + "/nix-support/build/outputs.nix") { }; +in +lib.fix ( + self: + outputs.ciArtifacts + // { + inherit (outputs) tests; + + # Aggregate job that is finished in Hydra _after_ all constituent jobs (here: grouped by system) + # succeed. + # This is used to run CD scripts once all builds are finished on Hydra. + release = inputs.forAllSystems ( + system: + let + pkgs = inputs.nixpkgsFor.${system}.native; + in + pkgs.runCommand "release" + { + _hydraAggregate = true; + constituents = lib.filter (x: x != null) ( + lib.mapAttrsToListRecursiveCond + (_: val: !(lib.isDerivation val || builtins.any (system': val ? ${system'}) systems)) + ( + path: drv: + if drv ? ${system} then + lib.concatStringsSep "." (path ++ [ system ]) + else if drv.system or null == system then + lib.concatStringsSep "." path + else + null + ) + ( + removeAttrs self [ + "release" + ] + ) + ); + } + '' + touch $out + '' + ); + } +)