|
|
|
|
@@ -1,16 +1,16 @@
|
|
|
|
|
{
|
|
|
|
|
python3Full,
|
|
|
|
|
runCommand,
|
|
|
|
|
setuptools,
|
|
|
|
|
copyDesktopItems,
|
|
|
|
|
clan-cli,
|
|
|
|
|
makeDesktopItem,
|
|
|
|
|
webview-ui,
|
|
|
|
|
webview-lib,
|
|
|
|
|
fontconfig,
|
|
|
|
|
pythonRuntime,
|
|
|
|
|
}:
|
|
|
|
|
let
|
|
|
|
|
source = ./.;
|
|
|
|
|
|
|
|
|
|
desktop-file = makeDesktopItem {
|
|
|
|
|
name = "org.clan.app";
|
|
|
|
|
exec = "clan-app %u";
|
|
|
|
|
@@ -25,24 +25,29 @@ let
|
|
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
pyDeps = ps: [
|
|
|
|
|
ps.tkinter
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
# Dependencies required for running tests
|
|
|
|
|
pyTestDeps =
|
|
|
|
|
ps:
|
|
|
|
|
with ps;
|
|
|
|
|
[
|
|
|
|
|
(python3Full.pkgs.toPythonModule pytest)
|
|
|
|
|
# Testing framework
|
|
|
|
|
pytest-cov # Generate coverage reports
|
|
|
|
|
pytest-subprocess # fake the real subprocess behavior to make your tests more independent.
|
|
|
|
|
pytest-xdist # Run tests in parallel on multiple cores
|
|
|
|
|
pytest-timeout # Add timeouts to your tests
|
|
|
|
|
ps.pytest
|
|
|
|
|
ps.pytest-cov # Generate coverage reports
|
|
|
|
|
ps.pytest-subprocess # fake the real subprocess behavior to make your tests more independent.
|
|
|
|
|
ps.pytest-xdist # Run tests in parallel on multiple cores
|
|
|
|
|
ps.pytest-timeout # Add timeouts to your tests
|
|
|
|
|
]
|
|
|
|
|
++ pytest.propagatedBuildInputs;
|
|
|
|
|
++ ps.pytest.propagatedBuildInputs;
|
|
|
|
|
|
|
|
|
|
clan-cli-module = [ (python3Full.pkgs.toPythonModule clan-cli) ];
|
|
|
|
|
clan-cli-module = [
|
|
|
|
|
(pythonRuntime.pkgs.toPythonModule (clan-cli.override { inherit pythonRuntime; }))
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
in
|
|
|
|
|
python3Full.pkgs.buildPythonApplication rec {
|
|
|
|
|
pythonRuntime.pkgs.buildPythonApplication {
|
|
|
|
|
name = "clan-app";
|
|
|
|
|
src = source;
|
|
|
|
|
format = "pyproject";
|
|
|
|
|
@@ -51,7 +56,7 @@ python3Full.pkgs.buildPythonApplication rec {
|
|
|
|
|
preFixup = ''
|
|
|
|
|
makeWrapperArgs+=(
|
|
|
|
|
--set FONTCONFIG_FILE ${fontconfig.out}/etc/fonts/fonts.conf
|
|
|
|
|
--set WEBUI_PATH "$out/${python3Full.sitePackages}/clan_app/.webui"
|
|
|
|
|
--set WEBUI_PATH "$out/${pythonRuntime.sitePackages}/clan_app/.webui"
|
|
|
|
|
--set WEBVIEW_LIB_DIR "${webview-lib}/lib"
|
|
|
|
|
# This prevents problems with mixed glibc versions that might occur when the
|
|
|
|
|
# cli is called through a browser built against another glibc
|
|
|
|
|
@@ -62,7 +67,7 @@ python3Full.pkgs.buildPythonApplication rec {
|
|
|
|
|
|
|
|
|
|
# Deps needed only at build time
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
|
setuptools
|
|
|
|
|
(pythonRuntime.withPackages (ps: [ ps.setuptools ]))
|
|
|
|
|
copyDesktopItems
|
|
|
|
|
fontconfig
|
|
|
|
|
];
|
|
|
|
|
@@ -71,8 +76,9 @@ python3Full.pkgs.buildPythonApplication rec {
|
|
|
|
|
# same values for your Python package within Nix largely stems from ensuring
|
|
|
|
|
# that all necessary dependencies are consistently available both
|
|
|
|
|
# at build time and runtime,
|
|
|
|
|
buildInputs = clan-cli-module ++ runtimeDependencies;
|
|
|
|
|
propagatedBuildInputs = buildInputs;
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
|
(pythonRuntime.withPackages (ps: clan-cli-module ++ (pyDeps ps)))
|
|
|
|
|
] ++ runtimeDependencies;
|
|
|
|
|
|
|
|
|
|
# also re-expose dependencies so we test them in CI
|
|
|
|
|
passthru = {
|
|
|
|
|
@@ -81,7 +87,7 @@ python3Full.pkgs.buildPythonApplication rec {
|
|
|
|
|
runCommand "clan-app-pytest"
|
|
|
|
|
{
|
|
|
|
|
buildInputs = runtimeDependencies ++ [
|
|
|
|
|
(python3Full.withPackages (ps: clan-cli-module ++ (pyTestDeps ps)))
|
|
|
|
|
(pythonRuntime.withPackages (ps: clan-cli-module ++ (pyTestDeps ps) ++ (pyDeps ps)))
|
|
|
|
|
fontconfig
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
@@ -105,7 +111,7 @@ python3Full.pkgs.buildPythonApplication rec {
|
|
|
|
|
echo "STARTING ..."
|
|
|
|
|
export WEBVIEW_LIB_DIR="${webview-lib}/lib"
|
|
|
|
|
export NIX_STATE_DIR=$TMPDIR/nix IN_NIX_SANDBOX=1
|
|
|
|
|
python3 -m pytest -s -m "not impure" ./tests
|
|
|
|
|
python -m pytest -s -m "not impure" ./tests
|
|
|
|
|
touch $out
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
@@ -113,11 +119,12 @@ python3Full.pkgs.buildPythonApplication rec {
|
|
|
|
|
|
|
|
|
|
# Additional pass-through attributes
|
|
|
|
|
passthru.desktop-file = desktop-file;
|
|
|
|
|
passthru.devshellDeps = ps: (pyTestDeps ps);
|
|
|
|
|
passthru.devshellPyDeps = ps: (pyTestDeps ps) ++ (pyDeps ps);
|
|
|
|
|
passthru.pythonRuntime = pythonRuntime;
|
|
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
|
mkdir -p $out/${python3Full.sitePackages}/clan_app/.webui
|
|
|
|
|
cp -r ${webview-ui}/lib/node_modules/@clan/webview-ui/dist/* $out/${python3Full.sitePackages}/clan_app/.webui
|
|
|
|
|
mkdir -p $out/${pythonRuntime.sitePackages}/clan_app/.webui
|
|
|
|
|
cp -r ${webview-ui}/lib/node_modules/@clan/webview-ui/dist/* $out/${pythonRuntime.sitePackages}/clan_app/.webui
|
|
|
|
|
mkdir -p $out/share/icons/hicolor
|
|
|
|
|
cp -r ./clan_app/assets/white-favicons/* $out/share/icons/hicolor
|
|
|
|
|
'';
|
|
|
|
|
|