1 #! /usr/bin/env nix-shell
2 #! nix-shell -i python3 -p python3
9 from tempfile import TemporaryDirectory
13 proc = subprocess.run(
14 ["nix", "search", "-u", "--json", "^nixpkgs.linux_"], capture_output=True
16 data = json.loads(proc.stdout)
17 with TemporaryDirectory() as temp:
18 for pkg in data.keys():
19 symlink = os.path.join(temp, pkg)
20 res = subprocess.run(["nix", "build", f"{pkg}.configfile", "-o", symlink])
21 if res.returncode != 0:
22 print(f"failed to get configuration for {pkg}", file=sys.stderr)
24 name = f"{pkg.replace('.', '-')}-config"
25 with open(name, "w") as dst, open(symlink) as src:
26 shutil.copyfileobj(src, dst)
29 if __name__ == "__main__":