Skip to content

Commit 956b41d

Browse files
authored
fix: secondary outputs (e.g. .python, etc) not being cached (#26)
1 parent 959ef5a commit 956b41d

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
- id: enumerate_packages
4949
name: Get all packages
5050
run: |
51-
echo "FLAKE_OUTPUTS=$(python3 ./.github/workflows/get_all_packages.py)" >> $GITHUB_ENV
51+
echo "FLAKE_OUTPUTS=$(python3 ./.github/workflows/get_all_packages.py | tr '\n' ' ')" >> $GITHUB_ENV
5252
- name: Build All
5353
run: |
5454
set +e

.github/workflows/get_all_packages.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,33 @@
22
import json
33
import subprocess
44

5-
flake_meta_process = subprocess.Popen(
6-
["nix", "flake", "show", "--json"],
7-
stdout=subprocess.PIPE,
8-
stderr=subprocess.PIPE,
9-
encoding="utf8",
10-
)
11-
flake_meta_process.wait()
12-
if flake_meta_process.returncode:
13-
print(f"Failed to get flake metadata:", file=sys.stderr)
14-
print(flake_meta_process.stderr.read(), file=sys.stderr)
15-
exit(-1)
16-
flake_meta = json.load(flake_meta_process.stdout)
5+
def run(purpose, *args):
6+
process = subprocess.Popen(
7+
[*args],
8+
stdout=subprocess.PIPE,
9+
stderr=subprocess.PIPE,
10+
encoding="utf8",
11+
)
12+
process.wait()
13+
if process.returncode:
14+
print(f"Failed to {purpose}:", file=sys.stderr)
15+
print(process.stderr.read(), file=sys.stderr)
16+
exit(-1)
17+
return process.stdout
18+
19+
flake_meta = json.load(run("get flake metadata", "nix", "flake", "show", "--json"))
1720
packages = flake_meta["packages"]
1821
for platform, packages in packages.items():
1922
for package, package_info in packages.items():
20-
if len(package_info):
21-
print(f".#packages.{platform}.{package}", end=" ")
23+
if len(package_info) == 0:
24+
continue
25+
tgt = f".#packages.{platform}.{package}"
26+
outputs = []
27+
drv = json.load(run(f"get derivation info for {package}", "nix", "derivation", "show", tgt))
28+
keys = list(drv.keys())
29+
if len(keys) != 1:
30+
print(f"'nix derivation show' unexpectedly returned {len(keys)} paths, expected exactly 1: {tgt}", file=sys.stderr)
31+
exit(-1)
32+
output_list = drv[keys[0]]["outputs"]
33+
for output in output_list:
34+
print(f"{tgt}.{output}")

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
)
6161
(
6262
self.composePythonOverlay (pkgs': pkgs: pypkgs': pypkgs: let
63-
callPythonPackage = lib.callPackageWith (pkgs' // pkgs'.python3.pkgs);
63+
callPythonPackage = lib.callPackageWith (pkgs' // pypkgs');
6464
in {
6565
kfactory = pypkgs.kfactory.overrideAttrs (attrs': attrs: {
6666
version = "1.9.3";

nix/yosys.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
bash,
5858
version ? "0.54",
5959
sha256 ? "sha256-meKlZh6ZiiPHwQCvS7Y667lvE9XWgIaual8c6SDpeDw=",
60+
darwin, # To fix codesigning issue for pyosys
6061
# For environments
6162
yosys,
6263
buildEnv,
@@ -89,7 +90,7 @@ in let
8990
pkg-config
9091
bison
9192
flex
92-
];
93+
] ++ lib.optionals clangStdenv.isDarwin [darwin.autoSignDarwinBinariesHook];
9394

9495
propagatedBuildInputs = [
9596
tcl

0 commit comments

Comments
 (0)