18dc8a95fb
this shouldn't create any rebuilds
the following script was used to generate this:
```fish
#!/usr/bin/env fish
# nix shell .#nixfmt nixpkgs#{nixf-diagnose,ripgrep,sd}
set base (git rev-parse HEAD)
set scope pkgs/by-name
set builder buildPythonApplication
set files (rg --files-with-matches -F "$builder rec {" $scope | sort -u)
for file in $files
echo $file
sd -F "$builder rec {" "$builder (finalAttrs: {" $file
# version
sd -F 'version}' 'finalAttrs.version}' $file
sd -F '${version' '${finalAttrs.version' $file
sd -F '= version' '= finalAttrs.version' $file
sd -F 'inherit version;' 'inherit (finalAttrs) version;' $file
sd -F ' + version;' ' + finalAttrs.version;' $file
sd 'replaceStrings (.*) version' 'replaceStrings $1 finalAttrs.version' $file
sd -F 'splitVersion version' 'splitVersion finalAttrs.version' $file
sd -F 'versionAtLeast version' 'versionAtLeast finalAttrs.version' $file
sd 'versions\.([a-z]+) version' 'versions.$1 finalAttrs.version' $file
# src
sd -F 'src}' 'finalAttrs.src}' $file
sd -F '${src' '${finalAttrs.src' $file
sd -F '= src' '= finalAttrs.src' $file
sd -F 'inherit src;' 'inherit (finalAttrs) src;' $file
sd -F 'inherit (src' 'inherit (finalAttrs.src' $file
# meta
sd -F '${meta' '${finalAttrs.meta' $file
sd -F '= meta' '= finalAttrs.meta' $file
sd -F 'inherit (meta' 'inherit (finalAttrs.meta' $file
# pname (restored afterwards)
sd -F 'pname}' 'finalAttrs.pname}' $file
sd -F '${pname' '${finalAttrs.pname' $file
sd -F '= pname' '= finalAttrs.pname' $file
# combinations
sd -F 'inherit version src;' 'inherit (finalAttrs) version src;' $file
sd -F 'inherit src version;' 'inherit (finalAttrs) src version;' $file
sd -F 'inherit version pname;' 'inherit (finalAttrs) version pname;' $file
sd -F 'inherit pname version;' 'inherit (finalAttrs) pname version;' $file
sd -F 'inherit pname src version;' 'inherit (finalAttrs) pname src version;' $file
sd -F 'inherit pname version src;' 'inherit (finalAttrs) pname version src;' $file
sd -F 'inherit src pname version;' 'inherit (finalAttrs) src pname version;' $file
sd -F 'inherit src version pname;' 'inherit (finalAttrs) src version pname;' $file
sd -F 'inherit version pname src;' 'inherit (finalAttrs) version pname src;' $file
sd -F 'inherit version src pname;' 'inherit (finalAttrs) version src pname;' $file
# other
sd -F 'makeLibraryPath buildInputs' 'makeLibraryPath finalAttrs.buildInputs' $file
sd -F 'nativeBuildInputs}' 'finalAttrs.nativeBuildInputs}' $file
sd -F 'buildInputs}' 'finalAttrs.buildInputs}' $file
sd -F 'propagatedBuildInputs}' 'finalAttrs.propagatedBuildInputs}' $file
sd -F 'desktopItem}' 'finalAttrs.desktopItem}' $file
sd -F 'runtimeLibs}' 'finalAttrs.runtimeLibs}' $file
sd -F 'makePythonPath dependencies' 'makePythonPath finalAttrs.dependencies' $file
sd -F 'makePythonPath propagatedBuildInputs' 'makePythonPath finalAttrs.propagatedBuildInputs' $file
sd -F 'libPath}' 'finalAttrs.libPath}' $file
sd -F 'runtimeDependencies}' 'finalAttrs.runtimeDependencies}' $file
sd -F 'runtimeDeps}' 'finalAttrs.runtimeDeps}' $file
sd -F 'nativeRuntimeInputs}' 'finalAttrs.nativeRuntimeInputs}' $file
sd -F '(!doCheck)' '(!finalAttrs.doCheck)' $file
sd -F 'optional doCheck' 'optional finalAttrs.doCheck' $file
sd -F 'optionals doCheck' 'optionals finalAttrs.doCheck' $file
sd -F '++ runtimeDependencies' '++ finalAttrs.runtimeDependencies' $file
# close finalAttrs lambda
echo ')' >>$file
# catch some errors early
if ! nixfmt $file
git restore $file
continue
end
if ! nixf-diagnose -i sema-primop-overridden $file
git restore $file
continue
end
end
set torestore (rg -F .finalAttrs --files-with-matches $scope)
if test (count $torestore) -gt 0
git restore $torestore
end
set torestore (rg -F finalAttrs.pname --files-with-matches $scope)
if test (count $torestore) -gt 0
git restore $torestore
end
# commit for faster eval times
git add pkgs
git commit --no-gpg-sign -m temp
set torestore
for file in $files
# file hasn't changed
if git diff --quiet $base $file
continue
end
# try to eval the package to definitely catch all errors
echo $file
set pname (string split / $file -f 4)
if ! nix eval .#$pname
set torestore $torestore $file
end
end
# restore files that don't eval
git reset --soft $base
git restore --staged .
if test (count $torestore) -gt 0
git restore $torestore
end
```
after that some manual cleanup was done:
- restoring files that cause changes in the number of lines
- restoring files that cause rebuilds
- restoring files that cause merge conflicts with staging
157 lines
3.7 KiB
Nix
157 lines
3.7 KiB
Nix
{
|
|
lib,
|
|
nixosTests,
|
|
cloud-utils,
|
|
dmidecode,
|
|
fetchFromGitHub,
|
|
iproute2,
|
|
openssh,
|
|
python3,
|
|
shadow,
|
|
systemd,
|
|
coreutils,
|
|
gitUpdater,
|
|
busybox,
|
|
procps,
|
|
}:
|
|
|
|
python3.pkgs.buildPythonApplication (finalAttrs: {
|
|
pname = "cloud-init";
|
|
version = "25.2";
|
|
pyproject = true;
|
|
|
|
namePrefix = "";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "canonical";
|
|
repo = "cloud-init";
|
|
tag = finalAttrs.version;
|
|
hash = "sha256-Ww76dhfoGrIbxPiXHxDjpgPsinmfrs42NnGmzhBeGC0=";
|
|
};
|
|
|
|
patches = [
|
|
./0001-add-nixos-support.patch
|
|
./0002-fix-test-logs-on-nixos.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"]'
|
|
|
|
substituteInPlace tests/unittests/cmd/test_clean.py \
|
|
--replace "/bin/bash" "/bin/sh"
|
|
'';
|
|
|
|
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
|
|
'';
|
|
|
|
build-system = with python3.pkgs; [
|
|
setuptools
|
|
];
|
|
|
|
propagatedBuildInputs = with python3.pkgs; [
|
|
configobj
|
|
jinja2
|
|
jsonpatch
|
|
jsonschema
|
|
netifaces
|
|
oauthlib
|
|
pyserial
|
|
pyyaml
|
|
requests
|
|
];
|
|
|
|
nativeCheckInputs = with python3.pkgs; [
|
|
pytest7CheckHook
|
|
httpretty
|
|
dmidecode
|
|
# needed for tests; at runtime we rather want the setuid wrapper
|
|
passlib
|
|
shadow
|
|
responses
|
|
pytest-mock
|
|
coreutils
|
|
procps
|
|
];
|
|
|
|
makeWrapperArgs = [
|
|
"--prefix PATH : ${
|
|
lib.makeBinPath [
|
|
dmidecode
|
|
cloud-utils.guest
|
|
busybox
|
|
]
|
|
}/bin"
|
|
];
|
|
|
|
disabledTests = [
|
|
# tries to create /var
|
|
"test_dhclient_run_with_tmpdir"
|
|
"test_dhcp_client_failover"
|
|
# 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"
|
|
"TestRemoveDefaultCaCerts"
|
|
# Doesn't work in the sandbox
|
|
"TestEphemeralDhcpNoNetworkSetup"
|
|
"TestHasURLConnectivity"
|
|
"TestReadFileOrUrl"
|
|
"TestConsumeUserDataHttp"
|
|
# Chef Omnibus
|
|
"TestInstallChefOmnibus"
|
|
# 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"
|
|
# https://github.com/canonical/cloud-init/issues/5002
|
|
"test_found_via_userdata"
|
|
];
|
|
|
|
preCheck = ''
|
|
# TestTempUtils.test_mkdtemp_default_non_root does not like TMPDIR=/build
|
|
export TMPDIR=/tmp
|
|
'';
|
|
|
|
pythonImportsCheck = [
|
|
"cloudinit"
|
|
];
|
|
|
|
passthru = {
|
|
tests = { inherit (nixosTests) cloud-init cloud-init-hostname; };
|
|
updateScript = gitUpdater { ignoredVersions = ".ubuntu.*"; };
|
|
};
|
|
|
|
meta = {
|
|
homepage = "https://github.com/canonical/cloud-init";
|
|
description = "Provides configuration and customization of cloud instance";
|
|
changelog = "https://github.com/canonical/cloud-init/raw/${finalAttrs.version}/ChangeLog";
|
|
license = with lib.licenses; [
|
|
asl20
|
|
gpl3Plus
|
|
];
|
|
maintainers = with lib.maintainers; [
|
|
illustris
|
|
jfroche
|
|
];
|
|
platforms = lib.platforms.all;
|
|
};
|
|
})
|