Files
nixpkgs/pkgs/by-name/ni/nix-required-mounts/scripts/nix_required_mounts_closure.py
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

46 lines
1.0 KiB
Python

import json
import os
store_dir = os.environ["storeDir"]
with open(os.environ["shallowConfigPath"], "r") as f:
config = json.load(f)
cache = {}
def read_edges(path: str | dict) -> list[str | dict]:
if isinstance(path, dict):
return [path]
assert isinstance(path, str)
if not path.startswith(store_dir):
return [path]
if path in cache:
return cache[path]
name = f"references-{path.removeprefix(store_dir)}"
assert os.path.exists(name)
with open(name, "r") as f:
return [p.strip() for p in f.readlines() if p.startswith(store_dir)]
def host_path(mount: str | dict) -> str:
if isinstance(mount, dict):
return mount["host"]
assert isinstance(mount, str), mount
return mount
for pattern in config:
closure = []
for path in config[pattern]["paths"]:
closure.append(path)
closure.extend(read_edges(path))
config[pattern]["paths"] = list({host_path(m): m for m in closure}.values())
with open(os.environ["out"], "w") as f:
json.dump(config, f)