36 lines
1022 B
Python
36 lines
1022 B
Python
"""Provides components to build nix components and process the result."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
import re
|
|
from tempfile import mkdtemp
|
|
|
|
from flupdt.common import bash_wrapper
|
|
|
|
drv_re = re.compile(r".*(/nix/store/.*\.drv).*")
|
|
|
|
OUTPUT_DIR = mkdtemp(prefix="flupdt-outputs-")
|
|
|
|
|
|
def build_output(path: str, output: str) -> str | None:
|
|
"""Builds a given output in a flake.
|
|
|
|
:param path: path to flake
|
|
:param output: flake output to be built
|
|
:returns the .drv path on success or None on failure
|
|
"""
|
|
logging.info(f"build {output}")
|
|
logging.debug(f"outputting to {OUTPUT_DIR}/{output}.nixoutput")
|
|
out = bash_wrapper(f"nix build {path}#{output} -o {OUTPUT_DIR}/{output}.nixoutput")
|
|
logging.debug("output")
|
|
logging.debug(out[0])
|
|
logging.debug("error")
|
|
logging.debug(out[1])
|
|
logging.debug("statuscode")
|
|
logging.debug(out[2])
|
|
if out[2] != 0:
|
|
logging.warning(f"output {output} did not build correctly")
|
|
return None
|
|
return ""
|