uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
|
|
@ -0,0 +1,139 @@
|
|||
From 269cc4c9558549f340ec186d9246654564b2f633 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
|
||||
Date: Tue, 18 Aug 2020 10:22:36 +0100
|
||||
Subject: [PATCH] add nixos support
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
|
||||
---
|
||||
cloudinit/distros/__init__.py | 1 +
|
||||
cloudinit/distros/nixos.py | 103 ++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 104 insertions(+)
|
||||
create mode 100644 cloudinit/distros/nixos.py
|
||||
|
||||
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
|
||||
index 2537608f..c533b585 100755
|
||||
--- a/cloudinit/distros/__init__.py
|
||||
+++ b/cloudinit/distros/__init__.py
|
||||
@@ -47,6 +47,7 @@ OSFAMILIES = {
|
||||
'gentoo': ['gentoo'],
|
||||
'redhat': ['amazon', 'centos', 'fedora', 'rhel'],
|
||||
'suse': ['opensuse', 'sles'],
|
||||
+ 'nixos': ['nixos'],
|
||||
}
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
diff --git a/cloudinit/distros/nixos.py b/cloudinit/distros/nixos.py
|
||||
new file mode 100644
|
||||
index 00000000..d53d2a61
|
||||
--- /dev/null
|
||||
+++ b/cloudinit/distros/nixos.py
|
||||
@@ -0,0 +1,103 @@
|
||||
+# vi: ts=4 expandtab
|
||||
+#
|
||||
+# Copyright (C) 2012 Canonical Ltd.
|
||||
+# Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
|
||||
+# Copyright (C) 2012 Yahoo! Inc.
|
||||
+#
|
||||
+# Author: Scott Moser <scott.moser@canonical.com>
|
||||
+# Author: Juerg Haefliger <juerg.haefliger@hp.com>
|
||||
+# Author: Joshua Harlow <harlowja@yahoo-inc.com>
|
||||
+#
|
||||
+# This program is free software: you can redistribute it and/or modify
|
||||
+# it under the terms of the GNU General Public License version 3, as
|
||||
+# published by the Free Software Foundation.
|
||||
+#
|
||||
+# This program is distributed in the hope that it will be useful,
|
||||
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+# GNU General Public License for more details.
|
||||
+#
|
||||
+# You should have received a copy of the GNU General Public License
|
||||
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
+
|
||||
+import os
|
||||
+
|
||||
+from cloudinit import distros
|
||||
+from cloudinit import helpers
|
||||
+from cloudinit import log as logging
|
||||
+from cloudinit import util
|
||||
+from cloudinit import atomic_helper
|
||||
+
|
||||
+from cloudinit.distros.parsers.hostname import HostnameConf
|
||||
+
|
||||
+LOG = logging.getLogger(__name__)
|
||||
+
|
||||
+class Distro(distros.Distro):
|
||||
+
|
||||
+ def __init__(self, name, cfg, paths):
|
||||
+ distros.Distro.__init__(self, name, cfg, paths)
|
||||
+ # This will be used to restrict certain
|
||||
+ # calls from repeatly happening (when they
|
||||
+ # should only happen say once per instance...)
|
||||
+ self._runner = helpers.Runners(paths)
|
||||
+ self.usr_lib_exec = os.path.join(os.path.dirname(__file__),
|
||||
+ "../../../../../libexec")
|
||||
+ self.osfamily = 'nixos'
|
||||
+
|
||||
+ def _select_hostname(self, hostname, fqdn):
|
||||
+ # Prefer the short hostname over the long
|
||||
+ # fully qualified domain name
|
||||
+ if not hostname:
|
||||
+ return fqdn
|
||||
+ return hostname
|
||||
+
|
||||
+ def _write_hostname(self, your_hostname, out_fn):
|
||||
+ conf = None
|
||||
+ try:
|
||||
+ # Try to update the previous one
|
||||
+ # so lets see if we can read it first.
|
||||
+ conf = self._read_hostname_conf(out_fn)
|
||||
+ except IOError:
|
||||
+ pass
|
||||
+ if not conf:
|
||||
+ conf = HostnameConf('')
|
||||
+ conf.set_hostname(your_hostname)
|
||||
+ atomic_helper.write_file(out_fn, str(conf).encode("utf-8"))
|
||||
+
|
||||
+ def _read_system_hostname(self):
|
||||
+ sys_hostname = self._read_hostname(self.hostname_conf_fn)
|
||||
+ return (self.hostname_conf_fn, sys_hostname)
|
||||
+
|
||||
+ def _read_hostname_conf(self, filename):
|
||||
+ conf = HostnameConf(util.load_file(filename))
|
||||
+ conf.parse()
|
||||
+ return conf
|
||||
+
|
||||
+ def _read_hostname(self, filename, default=None):
|
||||
+ hostname = None
|
||||
+ try:
|
||||
+ conf = self._read_hostname_conf(filename)
|
||||
+ hostname = conf.hostname
|
||||
+ except IOError:
|
||||
+ pass
|
||||
+ if not hostname:
|
||||
+ return default
|
||||
+ return hostname
|
||||
+
|
||||
+ def _write_network(self, settings):
|
||||
+ raise NotImplementedError()
|
||||
+
|
||||
+ def apply_locale(self, locale, out_fn=None):
|
||||
+ raise NotImplementedError()
|
||||
+
|
||||
+ def install_packages(self, pkglist):
|
||||
+ raise NotImplementedError()
|
||||
+
|
||||
+ def package_command(self, command, args=None, pkgs=None):
|
||||
+ raise NotImplementedError()
|
||||
+
|
||||
+ def set_timezone(self, tz):
|
||||
+ raise NotImplementedError()
|
||||
+
|
||||
+ def update_package_sources(self):
|
||||
+ raise NotImplementedError()
|
||||
--
|
||||
2.28.0
|
||||
|
||||
131
pkgs/tools/virtualization/cloud-init/default.nix
Normal file
131
pkgs/tools/virtualization/cloud-init/default.nix
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
{ lib
|
||||
, nixosTests
|
||||
, buildPythonApplication
|
||||
, cloud-utils
|
||||
, dmidecode
|
||||
, fetchFromGitHub
|
||||
, iproute2
|
||||
, openssh
|
||||
, python3
|
||||
, shadow
|
||||
, systemd
|
||||
}:
|
||||
|
||||
python3.pkgs.buildPythonApplication rec {
|
||||
pname = "cloud-init";
|
||||
version = "21.4";
|
||||
namePrefix = "";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "canonical";
|
||||
repo = "cloud-init";
|
||||
rev = version;
|
||||
sha256 = "09413qz9y2csvhjb4krjnkfj97vlykx79j912p27jjcrg82f1nib";
|
||||
};
|
||||
|
||||
patches = [ ./0001-add-nixos-support.patch ];
|
||||
|
||||
prePatch = ''
|
||||
substituteInPlace setup.py \
|
||||
--replace /lib/systemd $out/lib/systemd
|
||||
|
||||
substituteInPlace cloudinit/net/networkd.py \
|
||||
--replace "['/usr/sbin', '/bin']" "['/usr/sbin', '/bin', '${iproute2}/bin', '${systemd}/bin']"
|
||||
|
||||
substituteInPlace tests/unittests/test_net_activators.py \
|
||||
--replace "['/usr/sbin', '/bin']" \
|
||||
"['/usr/sbin', '/bin', '${iproute2}/bin', '${systemd}/bin']"
|
||||
'';
|
||||
|
||||
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 = with python3.pkgs; [
|
||||
configobj
|
||||
jinja2
|
||||
jsonpatch
|
||||
jsonschema
|
||||
netifaces
|
||||
oauthlib
|
||||
pyserial
|
||||
pyyaml
|
||||
requests
|
||||
];
|
||||
|
||||
checkInputs = with python3.pkgs; [
|
||||
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"
|
||||
# Disable failing VMware and PuppetAio tests
|
||||
"test_get_data_iso9660_with_network_config"
|
||||
"test_get_data_vmware_guestinfo_with_network_config"
|
||||
"test_get_host_info"
|
||||
"test_no_data_access_method"
|
||||
"test_install_with_collection"
|
||||
"test_install_with_custom_url"
|
||||
"test_install_with_default_arguments"
|
||||
"test_install_with_no_cleanup"
|
||||
"test_install_with_version"
|
||||
];
|
||||
|
||||
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"
|
||||
];
|
||||
|
||||
passthru.tests.cloud-init = nixosTests.cloud-init;
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://cloudinit.readthedocs.org";
|
||||
description = "Provides configuration and customization of cloud instance";
|
||||
license = with licenses; [ asl20 gpl3Plus ];
|
||||
maintainers = with maintainers; [ madjar phile314 ];
|
||||
platforms = platforms.all;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue