2024-09-19 14:19:46 +00:00
{
coreutils ,
fetchFromGitHub ,
lib ,
python39 ,
bash ,
2023-01-11 07:51:40 +00:00
} :
let
2024-01-02 11:29:13 +00:00
# the latest python version that waagent test against according to https://github.com/Azure/WALinuxAgent/blob/28345a55f9b21dae89472111635fd6e41809d958/.github/workflows/ci_pr.yml#L75
python = python39 ;
2023-01-11 07:51:40 +00:00
in
2024-01-02 11:29:13 +00:00
python . pkgs . buildPythonApplication rec {
2023-01-11 07:51:40 +00:00
pname = " w a a g e n t " ;
2024-10-04 16:56:33 +00:00
version = " 2 . 1 1 . 1 . 1 2 " ;
2023-01-11 07:51:40 +00:00
src = fetchFromGitHub {
owner = " A z u r e " ;
repo = " W A L i n u x A g e n t " ;
2024-02-07 01:22:34 +00:00
rev = " r e f s / t a g s / v ${ version } " ;
2024-10-04 16:56:33 +00:00
hash = " s h a 2 5 6 - 1 M a P j z 9 h W b / k J x u y J A U W P k 0 6 5 v p S y x 2 j q 1 Z S l D B 4 y F o = " ;
2023-01-11 07:51:40 +00:00
} ;
2023-11-16 04:20:00 +00:00
patches = [
2024-01-02 11:29:13 +00:00
# Suppress the following error when waagent tries to configure sshd:
2023-11-16 04:20:00 +00:00
# Read-only file system: '/etc/ssh/sshd_config'
./dont-configure-sshd.patch
] ;
2023-01-11 07:51:40 +00:00
doCheck = false ;
2024-09-19 14:19:46 +00:00
# Replace tools used in udev rules with their full path and ensure they are present.
2024-01-02 11:29:13 +00:00
postPatch = ''
2024-09-19 14:19:46 +00:00
substituteInPlace config/66-azure-storage.rules \
- - replace-fail readlink $ { coreutils } /bin/readlink \
- - replace-fail cut $ { coreutils } /bin/cut \
- - replace-fail /bin/sh $ { bash } /bin/sh
2024-01-02 11:29:13 +00:00
substituteInPlace config/99-azure-product-uuid.rules \
2024-09-19 14:19:46 +00:00
- - replace-fail " / b i n / c h m o d " " ${ coreutils } / b i n / c h m o d "
2024-01-02 11:29:13 +00:00
'' ;
propagatedBuildInputs = [ python . pkgs . distro ] ;
# The udev rules are placed to the wrong place.
# Move them to their default location.
# Keep $out/${python.sitePackages}/usr/sbin/waagent where it is.
# waagent re-executes itself in UpdateHandler.run_latest, even if autoupdate
# is disabled, manually spawning a python interprever with argv0.
# We can't use the default python program wrapping mechanism, as it uses
# wrapProgram which doesn't support --argv0.
# So instead we make our own wrapper in $out/bin/waagent, setting PATH and
# PYTHONPATH.
# PATH contains our PYTHON, and PYTHONPATH stays set, so this should somewhat
# still work.
preFixup = ''
mv $ out / $ { python . sitePackages } /etc $ out /
2023-01-11 07:51:40 +00:00
2024-01-02 11:29:13 +00:00
buildPythonPath
mkdir - p $ out/bin
makeWrapper $ out / $ { python . sitePackages } /usr/sbin/waagent $ out/bin/waagent \
- - set PYTHONPATH $ PYTHONPATH \
- - prefix PATH : $ program_PATH \
- - argv0 $ out / $ { python . sitePackages } /usr/sbin/waagent
2023-01-11 07:51:40 +00:00
'' ;
2024-01-02 11:29:13 +00:00
dontWrapPythonPrograms = false ;
2023-01-11 07:51:40 +00:00
meta = {
2024-06-20 14:57:18 +00:00
description = " M i c r o s o f t A z u r e L i n u x A g e n t ( w a a g e n t ) " ;
2024-04-21 15:54:59 +00:00
mainProgram = " w a a g e n t " ;
2024-01-02 11:29:13 +00:00
longDescription = ''
The Microsoft Azure Linux Agent ( waagent )
manages Linux provisioning and VM interaction with the Azure
Fabric Controller'' ;
2023-01-11 07:51:40 +00:00
homepage = " h t t p s : / / g i t h u b . c o m / A z u r e / W A L i n u x A g e n t " ;
license = with lib . licenses ; [ asl20 ] ;
} ;
}