From b7c4e0c76c78ebffdf33a5f2bfb597a8fc231347 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 2 Jan 2020 10:38:24 +0000 Subject: [PATCH] add script to download linux kernel configs from nix --- contrib/get-nix-kconfig.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 contrib/get-nix-kconfig.py diff --git a/contrib/get-nix-kconfig.py b/contrib/get-nix-kconfig.py new file mode 100644 index 0000000..b69692c --- /dev/null +++ b/contrib/get-nix-kconfig.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +import json +import os +import shutil +import subprocess +import sys +from tempfile import TemporaryDirectory + + +def main() -> None: + proc = subprocess.run( + ["nix", "search", "-u", "--json", "^nixpkgs.linux_"], capture_output=True + ) + data = json.loads(proc.stdout) + with TemporaryDirectory() as temp: + for pkg in data.keys(): + symlink = os.path.join(temp, pkg) + res = subprocess.run(["nix", "build", f"{pkg}.configfile", "-o", symlink]) + if res.returncode != 0: + print(f"failed to get configuration for {pkg}", file=sys.stderr) + continue + name = f"{pkg.replace('.', '-')}-config" + with open(name, "w") as dst, open(symlink) as src: + shutil.copyfileobj(src, dst) + + +if __name__ == "__main__": + main() -- 2.31.1