summary refs log tree commit diff
path: root/pkgs/tools/virtualization/cloud-init/default.nix
blob: 439cf47e55c151bbd145b197a57cb5511ea8e9ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{ lib
, fetchFromGitHub
, buildPythonApplication
, jinja2
, oauthlib
, configobj
, pyyaml
, requests
, jsonschema
, jsonpatch
, httpretty
, dmidecode
, pytestCheckHook
, shadow
, cloud-utils
, openssh
}:

buildPythonApplication rec {
  pname = "cloud-init";
  version = "21.2";
  namePrefix = "";

  src = fetchFromGitHub {
    owner = "canonical";
    repo = "cloud-init";
    rev = version;
    sha256 = "0vhjkgs49ixfa3kkj5s3v3gcxvypm3cdvfk6adrk2bx3wv2cbhvz";
  };

  patches = [ ./0001-add-nixos-support.patch ];
  prePatch = ''
    substituteInPlace setup.py --replace /lib/systemd $out/lib/systemd
  '';

  postInstall = ''
    install -D -m755 ./tools/write-ssh-key-fingerprints $out/libexec/write-ssh-key-fingerprints
    for i in $out/libexec/*; do
      wrapProgram $i --prefix PATH : "${lib.makeBinPath [ openssh ]}"
    done
  '';

  propagatedBuildInputs = [
    jinja2
    oauthlib
    configobj
    pyyaml
    requests
    jsonschema
    jsonpatch
  ];

  checkInputs = [
    pytestCheckHook
    httpretty
    dmidecode
    # needed for tests; at runtime we rather want the setuid wrapper
    shadow
  ];

  makeWrapperArgs = [
    "--prefix PATH : ${lib.makeBinPath [ dmidecode cloud-utils.guest ]}/bin"
  ];

  disabledTests = [
    # tries to create /var
    "test_dhclient_run_with_tmpdir"
    # clears path and fails because mkdir is not found
    "test_path_env_gets_set_from_main"
    # tries to read from /etc/ca-certificates.conf while inside the sandbox
    "test_handler_ca_certs"
    # Doesn't work in the sandbox
    "TestEphemeralDhcpNoNetworkSetup"
    "TestHasURLConnectivity"
    "TestReadFileOrUrl"
    "TestConsumeUserDataHttp"
    # Chef Omnibus
    "TestInstallChefOmnibus"
    # https://github.com/canonical/cloud-init/pull/893
    "TestGetPackageMirrorInfo"
  ];

  disabledTestPaths = [
    # Oracle tests are not passing
    "cloudinit/sources/tests/test_oracle.py"
    # Disable the integration tests. pycloudlib would be required
    "tests/unittests/test_datasource/test_aliyun.py"
    "tests/unittests/test_datasource/test_azure.py"
    "tests/unittests/test_datasource/test_ec2.py"
    "tests/unittests/test_datasource/test_exoscale.py"
    "tests/unittests/test_datasource/test_gce.py"
    "tests/unittests/test_datasource/test_openstack.py"
    "tests/unittests/test_datasource/test_scaleway.py"
    "tests/unittests/test_ec2_util.py"
  ];

  preCheck = ''
    # TestTempUtils.test_mkdtemp_default_non_root does not like TMPDIR=/build
    export TMPDIR=/tmp
  '';

  pythonImportsCheck = [ "cloudinit" ];

  meta = with lib; {
    homepage = "https://cloudinit.readthedocs.org";
    description = "Provides configuration and customization of cloud instance";
    maintainers = with maintainers; [ madjar phile314 ];
    platforms = platforms.all;
  };
}