1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 nix-update-script, 6 packaging, 7 platformdirs, 8 pydantic, 9 pyyaml, 10 requests-unixsocket, 11 setuptools-scm, 12 pytest-check, 13 pytest-mock, 14 pytestCheckHook, 15 responses, 16 freezegun, 17 pytest-subprocess, 18 logassert, 19}: 20 21buildPythonPackage rec { 22 pname = "craft-providers"; 23 version = "2.2.0"; 24 25 pyproject = true; 26 27 src = fetchFromGitHub { 28 owner = "canonical"; 29 repo = "craft-providers"; 30 tag = version; 31 hash = "sha256-HCt6xdUu8+6CtkLeUrY2KYnULLwLLobDDm4O1DAiZrc="; 32 }; 33 34 patches = [ 35 # This lib will try to inject snaps *from the host system* into the build 36 # system. This patch short-circuits that logic and ensures that snaps are 37 # installed on the build system from the snap store - because there is no 38 # snapd on NixOS hosts that can be used for the injection. This patch will 39 # likely never be accepted upstream. 40 ./inject-snaps.patch 41 ]; 42 43 postPatch = '' 44 substituteInPlace craft_providers/lxd/installer.py \ 45 --replace-fail "/var/snap/lxd/common/lxd/unix.socket" "/var/lib/lxd/unix.socket" 46 47 substituteInPlace craft_providers/__init__.py \ 48 --replace-fail "dev" "${version}" 49 50 # The urllib3 incompat: https://github.com/msabramo/requests-unixsocket/pull/69 51 # This is already patched in nixpkgs. 52 substituteInPlace pyproject.toml \ 53 --replace-fail "setuptools==75.2.0" "setuptools" 54 ''; 55 56 pythonRelaxDeps = [ "requests" ]; 57 58 build-system = [ setuptools-scm ]; 59 60 dependencies = [ 61 packaging 62 platformdirs 63 pydantic 64 pyyaml 65 requests-unixsocket 66 ]; 67 68 pythonImportsCheck = [ "craft_providers" ]; 69 70 nativeCheckInputs = [ 71 freezegun 72 logassert 73 pytest-check 74 pytest-mock 75 pytest-subprocess 76 pytestCheckHook 77 responses 78 ]; 79 80 preCheck = '' 81 mkdir -p check-phase 82 export HOME="$(pwd)/check-phase" 83 ''; 84 85 pytestFlagsArray = [ "tests/unit" ]; 86 87 disabledTestPaths = [ 88 # Relies upon "logassert" python package which isn't in nixpkgs 89 "tests/unit/bases/test_ubuntu_buildd.py" 90 "tests/unit/bases/test_centos_7.py" 91 "tests/unit/bases/test_almalinux.py" 92 "tests/unit/actions/test_snap_installer.py" 93 # Relies upon "pytest-time" python package which isn't in nixpkgs 94 "tests/unit/multipass" 95 "tests/unit/lxd" 96 "tests/unit/test_base.py" 97 "tests/unit/util/test_retry.py" 98 ]; 99 100 passthru.updateScript = nix-update-script { }; 101 102 meta = { 103 description = "Interfaces for instantiating and controlling a variety of build environments"; 104 homepage = "https://github.com/canonical/craft-providers"; 105 changelog = "https://github.com/canonical/craft-providers/releases/tag/${src.tag}"; 106 license = lib.licenses.lgpl3Only; 107 maintainers = with lib.maintainers; [ jnsgruk ]; 108 platforms = lib.platforms.linux; 109 }; 110}