2024-03-17 18:48:49 +00:00
|
|
|
{
|
|
|
|
python3,
|
|
|
|
runCommand,
|
|
|
|
setuptools,
|
|
|
|
copyDesktopItems,
|
|
|
|
pygobject3,
|
|
|
|
wrapGAppsHook,
|
|
|
|
gtk4,
|
|
|
|
gnome,
|
|
|
|
pygobject-stubs,
|
|
|
|
gobject-introspection,
|
|
|
|
clan-cli,
|
|
|
|
makeDesktopItem,
|
|
|
|
libadwaita,
|
2024-03-22 18:08:35 +00:00
|
|
|
weston,
|
2023-11-23 13:37:05 +00:00
|
|
|
}:
|
|
|
|
let
|
|
|
|
source = ./.;
|
2024-03-01 11:15:44 +00:00
|
|
|
desktop-file = makeDesktopItem {
|
2024-03-01 11:52:05 +00:00
|
|
|
name = "org.clan.vm-manager";
|
2024-03-01 11:15:44 +00:00
|
|
|
exec = "clan-vm-manager %u";
|
|
|
|
icon = ./clan_vm_manager/assets/clan_white.png;
|
|
|
|
desktopName = "cLAN Manager";
|
|
|
|
startupWMClass = "clan";
|
|
|
|
mimeTypes = [ "x-scheme-handler/clan" ];
|
|
|
|
};
|
2023-11-23 13:37:05 +00:00
|
|
|
in
|
2024-03-19 06:00:59 +00:00
|
|
|
python3.pkgs.buildPythonApplication rec {
|
2023-11-23 13:37:05 +00:00
|
|
|
name = "clan-vm-manager";
|
|
|
|
src = source;
|
|
|
|
format = "pyproject";
|
|
|
|
|
|
|
|
makeWrapperArgs = [
|
|
|
|
# This prevents problems with mixed glibc versions that might occur when the
|
|
|
|
# cli is called through a browser built against another glibc
|
|
|
|
"--unset LD_LIBRARY_PATH"
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
setuptools
|
|
|
|
copyDesktopItems
|
|
|
|
wrapGAppsHook
|
|
|
|
gobject-introspection
|
|
|
|
];
|
|
|
|
|
2024-03-17 18:48:49 +00:00
|
|
|
buildInputs = [
|
|
|
|
gtk4
|
|
|
|
libadwaita
|
|
|
|
gnome.adwaita-icon-theme
|
|
|
|
];
|
2024-03-09 16:15:32 +00:00
|
|
|
|
|
|
|
# We need to propagate the build inputs to nix fmt / treefmt
|
2024-03-12 15:49:18 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
(python3.pkgs.toPythonModule clan-cli)
|
2024-03-19 06:00:59 +00:00
|
|
|
passthru.externalPythonDeps
|
2024-03-12 15:49:18 +00:00
|
|
|
];
|
2023-11-23 13:37:05 +00:00
|
|
|
|
2024-03-22 18:08:35 +00:00
|
|
|
checkPython = python3.withPackages (_ps: clan-cli.passthru.pytestDependencies);
|
|
|
|
|
|
|
|
devDependencies = [
|
|
|
|
checkPython
|
|
|
|
weston
|
|
|
|
] ++ nativeBuildInputs ++ buildInputs ++ propagatedBuildInputs;
|
|
|
|
|
|
|
|
passthru.checkPython = checkPython;
|
|
|
|
passthru.devDependencies = devDependencies;
|
|
|
|
|
2023-11-23 13:37:05 +00:00
|
|
|
# also re-expose dependencies so we test them in CI
|
2024-03-01 11:15:44 +00:00
|
|
|
passthru = {
|
|
|
|
inherit desktop-file;
|
2024-03-19 06:00:59 +00:00
|
|
|
# Keep external dependencies in a separate lists to refer to thm elsewhere
|
|
|
|
# This helps avoiding issues like dev-shells accidentally depending on
|
|
|
|
# nix derivations of local packages.
|
|
|
|
externalPythonDeps = [
|
|
|
|
pygobject3
|
|
|
|
pygobject-stubs
|
|
|
|
];
|
2024-03-01 11:15:44 +00:00
|
|
|
tests = {
|
2024-03-22 18:08:35 +00:00
|
|
|
clan-vm-manager-pytest =
|
|
|
|
runCommand "clan-vm-manager-pytest" { nativeBuildInputs = devDependencies; }
|
|
|
|
''
|
|
|
|
cp -r ${source} ./src
|
|
|
|
chmod +w -R ./src
|
|
|
|
cd ./src
|
|
|
|
|
|
|
|
export NIX_STATE_DIR=$TMPDIR/nix IN_NIX_SANDBOX=1
|
|
|
|
${checkPython}/bin/python -m pytest -m "not impure" ./tests
|
|
|
|
touch $out
|
|
|
|
'';
|
2024-03-01 11:15:44 +00:00
|
|
|
clan-vm-manager-no-breakpoints = runCommand "clan-vm-manager-no-breakpoints" { } ''
|
|
|
|
if grep --include \*.py -Rq "breakpoint()" ${source}; then
|
|
|
|
echo "breakpoint() found in ${source}:"
|
|
|
|
grep --include \*.py -Rn "breakpoint()" ${source}
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
};
|
2023-11-23 13:37:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# Don't leak python packages into a devshell.
|
|
|
|
# It can be very confusing if you `nix run` than load the cli from the devshell instead.
|
|
|
|
postFixup = ''
|
|
|
|
rm $out/nix-support/propagated-build-inputs
|
|
|
|
'';
|
|
|
|
checkPhase = ''
|
|
|
|
PYTHONPATH= $out/bin/clan-vm-manager --help
|
|
|
|
'';
|
2024-03-17 18:48:49 +00:00
|
|
|
desktopItems = [ desktop-file ];
|
2023-11-23 13:37:05 +00:00
|
|
|
}
|