Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

Commit 39367a4

Browse files
committed
Better and better structured forCache
1 parent 4eb96b9 commit 39367a4

1 file changed

Lines changed: 24 additions & 28 deletions

File tree

flake.nix

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -144,39 +144,35 @@
144144
}) buildSets
145145
);
146146

147-
# Dependencies that should be cached.
147+
# Dependencies that should be cached, the structure of the output
148+
# path is: <build variant>/<dependency>-<output>
148149
forCache =
149150
let
150151
filterDist = lib.filter (output: output != "dist");
151-
# Get all `torch` outputs except for `dist`. Not all outputs
152-
# are dependencies of `out`, but we'll need the `cxxdev` and
153-
# `dev` outputs for kernel builds.
154-
torchOutputs = builtins.listToAttrs (
155-
lib.flatten (
156-
# Map over build sets.
157-
map (
158-
buildSet:
159-
# Map over all outputs of `torch` in a buildset.
160-
map (output: {
161-
name = "${buildVersion buildSet}-${output}";
162-
value = buildSet.torch.${output};
163-
}) (filterDist buildSet.torch.outputs)
164-
) buildSets
165-
)
166-
);
167-
oldLinuxStdenvs = builtins.listToAttrs (
168-
map (buildSet: {
169-
name = "stdenv-${buildVersion buildSet}";
170-
value = buildSet.pkgs.stdenvGlibc_2_27;
171-
}) buildSets
172-
);
152+
# Get all outputs except for `dist` (which is the built wheel for Torch).
153+
allOutputs =
154+
drv:
155+
map (output: {
156+
name = "${drv.pname or drv.name}-${output}";
157+
path = drv.${output};
158+
}) (filterDist drv.outputs or [ "out" ]);
159+
buildSetOutputs =
160+
buildSet:
161+
with buildSet.pkgs;
162+
(
163+
allOutputs buildSet.torch
164+
++ allOutputs build2cmake
165+
++ allOutputs kernel-abi-check
166+
++ allOutputs python3Packages.kernels
167+
++ allOutputs stdenvGlibc_2_27
168+
);
169+
buildSetLinkFarm = buildSet: pkgs.linkFarm (buildVersion buildSet) (buildSetOutputs buildSet);
173170
in
174171
pkgs.linkFarm "packages-for-cache" (
175-
{
176-
inherit build2cmake kernel-abi-check;
177-
}
178-
// torchOutputs
179-
// lib.optionalAttrs nixpkgs.legacyPackages.${system}.stdenv.isLinux oldLinuxStdenvs
172+
map (buildSet: {
173+
name = buildVersion buildSet;
174+
path = buildSetLinkFarm buildSet;
175+
}) buildSets
180176
);
181177
};
182178
}

0 commit comments

Comments
 (0)