Merge pull request 'zerotier: move nix_shell to external package' (#24) from zerotier into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/24
This commit is contained in:
10
pkgs/clan-cli/clan_cli/nix.py
Normal file
10
pkgs/clan-cli/clan_cli/nix.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import os
|
||||
|
||||
CLAN_NIXPKGS = os.environ.get("CLAN_NIXPKGS")
|
||||
|
||||
|
||||
def nix_shell(packages: list[str], cmd: list[str]) -> list[str]:
|
||||
# in unittest we will have all binaries provided
|
||||
if CLAN_NIXPKGS is None:
|
||||
return cmd
|
||||
return ["nix", "shell", "-f", CLAN_NIXPKGS] + packages + ["-c"] + cmd
|
||||
@@ -1,5 +1,4 @@
|
||||
import json
|
||||
import os
|
||||
import socket
|
||||
import subprocess
|
||||
import time
|
||||
@@ -9,6 +8,8 @@ from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
from typing import Any, Iterator, Optional
|
||||
|
||||
from ..nix import nix_shell
|
||||
|
||||
|
||||
def try_bind_port(port: int) -> bool:
|
||||
tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
@@ -36,16 +37,6 @@ def find_free_port(port_range: range) -> int:
|
||||
raise Exception("cannot find a free port")
|
||||
|
||||
|
||||
CLAN_NIXPKGS = os.environ.get("CLAN_NIXPKGS")
|
||||
|
||||
|
||||
def nix_shell(packages: list[str], cmd: list[str]) -> list[str]:
|
||||
# in unittest we will have all binaries provided
|
||||
if CLAN_NIXPKGS is None:
|
||||
return cmd
|
||||
return ["nix", "shell", "-f", CLAN_NIXPKGS] + packages + ["-c"] + cmd
|
||||
|
||||
|
||||
class ZerotierController:
|
||||
def __init__(self, port: int, home: Path) -> None:
|
||||
self.port = port
|
||||
|
||||
Reference in New Issue
Block a user