aboutsummaryrefslogtreecommitdiff
path: root/scripts/p7s/__init__.py
blob: 8f6dea70d6104c5154125244e19134f460c2a79d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os, pathlib, shutil, subprocess, sys, textwrap


def nix_portable(command):
    def main():
        os.environ["NP_RUNTIME"] = "bwrap"
        sys.exit(subprocess.run([shutil.which("nix-portable"), "nix", "run", f"nixpkgs#{command}", "--"] + sys.argv[1:]).returncode)
    return main


BASHRC_D = pathlib.Path.home() / ".bashrc.d"


def multiline_string(s):
    return textwrap.dedent(s).lstrip()


def assert_single(l):
    assert len(l) == 1
    return l[0]