clan-vm-manager: add nix package
This commit is contained in:
parent
2e54575474
commit
f68c10a008
|
@ -33,7 +33,6 @@
|
||||||
"aarch64-darwin"
|
"aarch64-darwin"
|
||||||
];
|
];
|
||||||
imports = [
|
imports = [
|
||||||
|
|
||||||
./checks/flake-module.nix
|
./checks/flake-module.nix
|
||||||
./devShell.nix
|
./devShell.nix
|
||||||
./formatter.nix
|
./formatter.nix
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
# Because we depend on nixpkgs sources, uploading to builders takes a long time
|
|
||||||
|
|
||||||
source_up
|
source_up
|
||||||
|
|
||||||
|
nix_direnv_watch_file flake-module.nix default.nix
|
||||||
|
|
||||||
if type nix_direnv_watch_file &>/dev/null; then
|
# Because we depend on nixpkgs sources, uploading to builders takes a long time
|
||||||
nix_direnv_watch_file flake-module.nix
|
|
||||||
nix_direnv_watch_file default.nix
|
|
||||||
else
|
|
||||||
direnv watch flake-module.nix
|
|
||||||
direnv watch default.nix
|
|
||||||
fi
|
|
||||||
use flake .#clan-cli --builders ''
|
use flake .#clan-cli --builders ''
|
||||||
|
|
|
@ -41,11 +41,6 @@ let
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
argcomplete # optional dependency: if not enabled, shell completion will not work
|
argcomplete # optional dependency: if not enabled, shell completion will not work
|
||||||
wrapGAppsHook
|
|
||||||
gtk3
|
|
||||||
glib
|
|
||||||
gobject-introspection
|
|
||||||
pygobject3
|
|
||||||
];
|
];
|
||||||
|
|
||||||
pytestDependencies = runtimeDependencies ++ dependencies ++ [
|
pytestDependencies = runtimeDependencies ++ dependencies ++ [
|
||||||
|
|
|
@ -45,7 +45,6 @@ mkShell {
|
||||||
export PATH="$tmp_path/python/bin:${checkScript}/bin:$PATH"
|
export PATH="$tmp_path/python/bin:${checkScript}/bin:$PATH"
|
||||||
export PYTHONPATH="$repo_root:$tmp_path/python/${pythonWithDeps.sitePackages}:"
|
export PYTHONPATH="$repo_root:$tmp_path/python/${pythonWithDeps.sitePackages}:"
|
||||||
|
|
||||||
|
|
||||||
export XDG_DATA_DIRS="$tmp_path/share''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
|
export XDG_DATA_DIRS="$tmp_path/share''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
|
||||||
export fish_complete_path="$tmp_path/share/fish/vendor_completions.d''${fish_complete_path:+:$fish_complete_path}"
|
export fish_complete_path="$tmp_path/share/fish/vendor_completions.d''${fish_complete_path:+:$fish_complete_path}"
|
||||||
mkdir -p \
|
mkdir -p \
|
||||||
|
|
6
pkgs/clan-vm-manager/.envrc
Normal file
6
pkgs/clan-vm-manager/.envrc
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
source_up
|
||||||
|
|
||||||
|
nix_direnv_watch_file flake-module.nix default.nix
|
||||||
|
|
||||||
|
# Because we depend on nixpkgs sources, uploading to builders takes a long time
|
||||||
|
use flake .#clan-vm-manager --builders ''
|
12
pkgs/clan-vm-manager/bin/clan-vm-manager
Executable file
12
pkgs/clan-vm-manager/bin/clan-vm-manager
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.insert(
|
||||||
|
0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
|
||||||
|
)
|
||||||
|
|
||||||
|
from clan_vm_manager import main # NOQA
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
|
@ -6,6 +6,8 @@ start_app: Optional[Callable] = None
|
||||||
from .app import start_app
|
from .app import start_app
|
||||||
|
|
||||||
|
|
||||||
def register_parser(parser: argparse.ArgumentParser) -> None:
|
def main() -> None:
|
||||||
parser = argparse.ArgumentParser(description="clan-vm-manager")
|
parser = argparse.ArgumentParser(description="clan-vm-manager")
|
||||||
parser.set_defaults(func=start_app)
|
parser.set_defaults(func=start_app)
|
||||||
|
args = parser.parse_args()
|
||||||
|
args.func(args)
|
||||||
|
|
57
pkgs/clan-vm-manager/default.nix
Normal file
57
pkgs/clan-vm-manager/default.nix
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
{ python3
|
||||||
|
, runCommand
|
||||||
|
, setuptools
|
||||||
|
, copyDesktopItems
|
||||||
|
, pygobject3
|
||||||
|
, wrapGAppsHook
|
||||||
|
, gtk3
|
||||||
|
, gnome
|
||||||
|
, gobject-introspection
|
||||||
|
, clan-cli
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
source = ./.;
|
||||||
|
in
|
||||||
|
python3.pkgs.buildPythonApplication {
|
||||||
|
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
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = [ gtk3 gnome.adwaita-icon-theme ];
|
||||||
|
propagatedBuildInputs = [ pygobject3 clan-cli ];
|
||||||
|
|
||||||
|
# also re-expose dependencies so we test them in CI
|
||||||
|
passthru.tests = {
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# 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
|
||||||
|
'';
|
||||||
|
meta.mainProgram = "clan";
|
||||||
|
}
|
12
pkgs/clan-vm-manager/flake-module.nix
Normal file
12
pkgs/clan-vm-manager/flake-module.nix
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{ ... }: {
|
||||||
|
perSystem = { config, pkgs, ... }: {
|
||||||
|
devShells.clan-vm-manager = pkgs.callPackage ./shell.nix {
|
||||||
|
inherit (config.packages) clan-cli clan-vm-manager;
|
||||||
|
};
|
||||||
|
packages.clan-vm-manager = pkgs.python3.pkgs.callPackage ./default.nix {
|
||||||
|
inherit (config.packages) clan-cli;
|
||||||
|
};
|
||||||
|
|
||||||
|
checks = config.packages.clan-vm-manager.tests;
|
||||||
|
};
|
||||||
|
}
|
28
pkgs/clan-vm-manager/pyproject.toml
Normal file
28
pkgs/clan-vm-manager/pyproject.toml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "clan-vm-manager"
|
||||||
|
dynamic = ["version"]
|
||||||
|
scripts = { clan-vm-manager = "clan_vm_manager:main" }
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
clan_vm_manager = ["*.glade"]
|
||||||
|
|
||||||
|
[tool.mypy]
|
||||||
|
python_version = "3.10"
|
||||||
|
warn_redundant_casts = true
|
||||||
|
disallow_untyped_calls = true
|
||||||
|
disallow_untyped_defs = true
|
||||||
|
no_implicit_optional = true
|
||||||
|
|
||||||
|
[[tool.mypy.overrides]]
|
||||||
|
module = "gi.*"
|
||||||
|
ignore_missing_imports = true
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
line-length = 88
|
||||||
|
|
||||||
|
select = ["E", "F", "I", "N"]
|
||||||
|
ignore = ["E501", "E402"]
|
15
pkgs/clan-vm-manager/shell.nix
Normal file
15
pkgs/clan-vm-manager/shell.nix
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{ clan-vm-manager, clan-cli, mkShell, ruff, python3 }:
|
||||||
|
let
|
||||||
|
pythonWithDeps = python3.withPackages (ps: clan-vm-manager.propagatedBuildInputs);
|
||||||
|
in
|
||||||
|
mkShell {
|
||||||
|
buildInputs = [ pythonWithDeps ] ++ clan-vm-manager.buildInputs;
|
||||||
|
nativeBuildInputs = [
|
||||||
|
ruff
|
||||||
|
] ++ clan-vm-manager.nativeBuildInputs;
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
rm -f ../clan-cli/clan_cli/nixpkgs
|
||||||
|
ln -sf ${clan-cli.nixpkgs} ../clan-cli/clan_cli/nixpkgs
|
||||||
|
'';
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
{ ... }: {
|
{ ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
./clan-cli/flake-module.nix
|
./clan-cli/flake-module.nix
|
||||||
|
./clan-vm-manager/flake-module.nix
|
||||||
./installer/flake-module.nix
|
./installer/flake-module.nix
|
||||||
./ui/flake-module.nix
|
./ui/flake-module.nix
|
||||||
./theme/flake-module.nix
|
./theme/flake-module.nix
|
||||||
|
|
Loading…
Reference in New Issue
Block a user