diff options
Diffstat (limited to 'modules/private/buildbot/common/build_helpers.py')
-rw-r--r-- | modules/private/buildbot/common/build_helpers.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/modules/private/buildbot/common/build_helpers.py b/modules/private/buildbot/common/build_helpers.py index ed7ada3..acea905 100644 --- a/modules/private/buildbot/common/build_helpers.py +++ b/modules/private/buildbot/common/build_helpers.py | |||
@@ -1,10 +1,11 @@ | |||
1 | from buildbot.plugins import util, steps, schedulers | 1 | from buildbot.plugins import util, steps, schedulers |
2 | from buildbot_buildslist import BuildsList | 2 | from buildbot_buildslist import BuildsList |
3 | from shutil import which | ||
3 | 4 | ||
4 | __all__ = [ | 5 | __all__ = [ |
5 | "force_scheduler", "deploy_scheduler", "hook_scheduler", | 6 | "force_scheduler", "deploy_scheduler", "hook_scheduler", |
6 | "clean_branch", "package_and_upload", "SlackStatusPush", | 7 | "clean_branch", "package_and_upload", "SlackStatusPush", |
7 | "XMPPStatusPush" | 8 | "XMPPStatusPush", "NixShellCommand" |
8 | ] | 9 | ] |
9 | 10 | ||
10 | # Small helpers" | 11 | # Small helpers" |
@@ -30,6 +31,26 @@ def package_and_upload(package, package_dest, package_url): | |||
30 | command=["rm", "-f", package]), | 31 | command=["rm", "-f", package]), |
31 | ] | 32 | ] |
32 | 33 | ||
34 | # Steps | ||
35 | class NixShellCommand(steps.ShellCommand): | ||
36 | def __init__(self, command=None, pure=True, nixfile=None, **kwargs): | ||
37 | assert(isinstance(command, str)) | ||
38 | oldpath = kwargs.get("env", {}).get("PATH", None) | ||
39 | if which("nix-shell", path=oldpath) is None: | ||
40 | kwargs["env"] = kwargs.get("env", {}) | ||
41 | if isinstance(oldpath, str): | ||
42 | kwargs["env"]["PATH"] = "/run/current-system/sw/bin:" + oldpath | ||
43 | elif isinstance(oldpath, list): | ||
44 | kwargs["env"]["PATH"] = ["/run/current-system/sw/bin"] + oldpath | ||
45 | nixcommand = ["nix-shell"] | ||
46 | if pure: | ||
47 | nixcommand.append("--pure") | ||
48 | nixcommand.append("--run") | ||
49 | nixcommand.append(command) | ||
50 | if nixfile is not None: | ||
51 | nixcommand.append(nixfile) | ||
52 | super().__init__(command=nixcommand, **kwargs) | ||
53 | |||
33 | # Schedulers | 54 | # Schedulers |
34 | def force_scheduler(name, builders): | 55 | def force_scheduler(name, builders): |
35 | return schedulers.ForceScheduler(name=name, | 56 | return schedulers.ForceScheduler(name=name, |