clan-app: Fix nix run .#clan-app
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
from typing import Any, ClassVar
|
from typing import Any, ClassVar
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
@@ -56,9 +57,7 @@ class MainApplication(Adw.Application):
|
|||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
|
|
||||||
site_index: Path = (
|
site_index: Path = Path(os.getenv("WEBUI_PATH", ".")).resolve() / "index.html"
|
||||||
Path(__file__).parent.parent / Path("clan_app/.webui/index.html")
|
|
||||||
).resolve()
|
|
||||||
self.content_uri = f"file://{site_index}"
|
self.content_uri = f"file://{site_index}"
|
||||||
self.window: MainWindow | None = None
|
self.window: MainWindow | None = None
|
||||||
self.connect("activate", self.on_activate)
|
self.connect("activate", self.on_activate)
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ python3.pkgs.buildPythonApplication rec {
|
|||||||
|
|
||||||
makeWrapperArgs = [
|
makeWrapperArgs = [
|
||||||
"--set FONTCONFIG_FILE ${fontconfig.out}/etc/fonts/fonts.conf"
|
"--set FONTCONFIG_FILE ${fontconfig.out}/etc/fonts/fonts.conf"
|
||||||
|
"--set WEBUI_PATH $out/${python3.sitePackages}/clan_app/.webui"
|
||||||
# This prevents problems with mixed glibc versions that might occur when the
|
# This prevents problems with mixed glibc versions that might occur when the
|
||||||
# cli is called through a browser built against another glibc
|
# cli is called through a browser built against another glibc
|
||||||
"--unset LD_LIBRARY_PATH"
|
"--unset LD_LIBRARY_PATH"
|
||||||
|
|||||||
@@ -79,7 +79,9 @@ def test_generate_public_var(
|
|||||||
)
|
)
|
||||||
monkeypatch.chdir(flake.path)
|
monkeypatch.chdir(flake.path)
|
||||||
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
|
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
|
||||||
store = in_repo.FactStore(Machine(name="my_machine", flake=FlakeId(flake.path)))
|
store = in_repo.FactStore(
|
||||||
|
Machine(name="my_machine", flake=FlakeId(str(flake.path)))
|
||||||
|
)
|
||||||
assert store.exists("my_generator", "my_value")
|
assert store.exists("my_generator", "my_value")
|
||||||
assert store.get("my_generator", "my_value").decode() == "hello\n"
|
assert store.get("my_generator", "my_value").decode() == "hello\n"
|
||||||
|
|
||||||
@@ -103,10 +105,12 @@ def test_generate_secret_var_sops(
|
|||||||
sops_setup.init()
|
sops_setup.init()
|
||||||
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
|
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
|
||||||
in_repo_store = in_repo.FactStore(
|
in_repo_store = in_repo.FactStore(
|
||||||
Machine(name="my_machine", flake=FlakeId(flake.path))
|
Machine(name="my_machine", flake=FlakeId(str(flake.path)))
|
||||||
)
|
)
|
||||||
assert not in_repo_store.exists("my_generator", "my_secret")
|
assert not in_repo_store.exists("my_generator", "my_secret")
|
||||||
sops_store = sops.SecretStore(Machine(name="my_machine", flake=FlakeId(flake.path)))
|
sops_store = sops.SecretStore(
|
||||||
|
Machine(name="my_machine", flake=FlakeId(str(flake.path)))
|
||||||
|
)
|
||||||
assert sops_store.exists("my_generator", "my_secret")
|
assert sops_store.exists("my_generator", "my_secret")
|
||||||
assert sops_store.get("my_generator", "my_secret").decode() == "hello\n"
|
assert sops_store.get("my_generator", "my_secret").decode() == "hello\n"
|
||||||
|
|
||||||
@@ -132,10 +136,12 @@ def test_generate_secret_var_sops_with_default_group(
|
|||||||
cli.run(["secrets", "groups", "add-user", "my_group", sops_setup.user])
|
cli.run(["secrets", "groups", "add-user", "my_group", sops_setup.user])
|
||||||
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
|
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
|
||||||
in_repo_store = in_repo.FactStore(
|
in_repo_store = in_repo.FactStore(
|
||||||
Machine(name="my_machine", flake=FlakeId(flake.path))
|
Machine(name="my_machine", flake=FlakeId(str(flake.path)))
|
||||||
)
|
)
|
||||||
assert not in_repo_store.exists("my_generator", "my_secret")
|
assert not in_repo_store.exists("my_generator", "my_secret")
|
||||||
sops_store = sops.SecretStore(Machine(name="my_machine", flake=FlakeId(flake.path)))
|
sops_store = sops.SecretStore(
|
||||||
|
Machine(name="my_machine", flake=FlakeId(str(flake.path)))
|
||||||
|
)
|
||||||
assert sops_store.exists("my_generator", "my_secret")
|
assert sops_store.exists("my_generator", "my_secret")
|
||||||
assert sops_store.get("my_generator", "my_secret").decode() == "hello\n"
|
assert sops_store.get("my_generator", "my_secret").decode() == "hello\n"
|
||||||
|
|
||||||
@@ -184,7 +190,7 @@ def test_generate_secret_var_password_store(
|
|||||||
)
|
)
|
||||||
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
|
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
|
||||||
store = password_store.SecretStore(
|
store = password_store.SecretStore(
|
||||||
Machine(name="my_machine", flake=FlakeId(flake.path))
|
Machine(name="my_machine", flake=FlakeId(str(flake.path)))
|
||||||
)
|
)
|
||||||
assert store.exists("my_generator", "my_secret")
|
assert store.exists("my_generator", "my_secret")
|
||||||
assert store.get("my_generator", "my_secret").decode() == "hello\n"
|
assert store.get("my_generator", "my_secret").decode() == "hello\n"
|
||||||
@@ -224,18 +230,22 @@ def test_generate_secret_for_multiple_machines(
|
|||||||
cli.run(["vars", "generate", "--flake", str(flake.path)])
|
cli.run(["vars", "generate", "--flake", str(flake.path)])
|
||||||
# check if public vars have been created correctly
|
# check if public vars have been created correctly
|
||||||
in_repo_store1 = in_repo.FactStore(
|
in_repo_store1 = in_repo.FactStore(
|
||||||
Machine(name="machine1", flake=FlakeId(flake.path))
|
Machine(name="machine1", flake=FlakeId(str(flake.path)))
|
||||||
)
|
)
|
||||||
in_repo_store2 = in_repo.FactStore(
|
in_repo_store2 = in_repo.FactStore(
|
||||||
Machine(name="machine2", flake=FlakeId(flake.path))
|
Machine(name="machine2", flake=FlakeId(str(flake.path)))
|
||||||
)
|
)
|
||||||
assert in_repo_store1.exists("my_generator", "my_value")
|
assert in_repo_store1.exists("my_generator", "my_value")
|
||||||
assert in_repo_store2.exists("my_generator", "my_value")
|
assert in_repo_store2.exists("my_generator", "my_value")
|
||||||
assert in_repo_store1.get("my_generator", "my_value").decode() == "machine1\n"
|
assert in_repo_store1.get("my_generator", "my_value").decode() == "machine1\n"
|
||||||
assert in_repo_store2.get("my_generator", "my_value").decode() == "machine2\n"
|
assert in_repo_store2.get("my_generator", "my_value").decode() == "machine2\n"
|
||||||
# check if secret vars have been created correctly
|
# check if secret vars have been created correctly
|
||||||
sops_store1 = sops.SecretStore(Machine(name="machine1", flake=FlakeId(flake.path)))
|
sops_store1 = sops.SecretStore(
|
||||||
sops_store2 = sops.SecretStore(Machine(name="machine2", flake=FlakeId(flake.path)))
|
Machine(name="machine1", flake=FlakeId(str(flake.path)))
|
||||||
|
)
|
||||||
|
sops_store2 = sops.SecretStore(
|
||||||
|
Machine(name="machine2", flake=FlakeId(str(flake.path)))
|
||||||
|
)
|
||||||
assert sops_store1.exists("my_generator", "my_secret")
|
assert sops_store1.exists("my_generator", "my_secret")
|
||||||
assert sops_store2.exists("my_generator", "my_secret")
|
assert sops_store2.exists("my_generator", "my_secret")
|
||||||
assert sops_store1.get("my_generator", "my_secret").decode() == "machine1\n"
|
assert sops_store1.get("my_generator", "my_secret").decode() == "machine1\n"
|
||||||
@@ -263,7 +273,7 @@ def test_dependant_generators(
|
|||||||
monkeypatch.chdir(flake.path)
|
monkeypatch.chdir(flake.path)
|
||||||
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
|
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
|
||||||
in_repo_store = in_repo.FactStore(
|
in_repo_store = in_repo.FactStore(
|
||||||
Machine(name="my_machine", flake=FlakeId(flake.path))
|
Machine(name="my_machine", flake=FlakeId(str(flake.path)))
|
||||||
)
|
)
|
||||||
assert in_repo_store.exists("parent_generator", "my_value")
|
assert in_repo_store.exists("parent_generator", "my_value")
|
||||||
assert in_repo_store.get("parent_generator", "my_value").decode() == "hello\n"
|
assert in_repo_store.get("parent_generator", "my_value").decode() == "hello\n"
|
||||||
@@ -302,7 +312,7 @@ def test_prompt(
|
|||||||
monkeypatch.setattr("sys.stdin", StringIO(input_value))
|
monkeypatch.setattr("sys.stdin", StringIO(input_value))
|
||||||
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
|
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
|
||||||
in_repo_store = in_repo.FactStore(
|
in_repo_store = in_repo.FactStore(
|
||||||
Machine(name="my_machine", flake=FlakeId(flake.path))
|
Machine(name="my_machine", flake=FlakeId(str(flake.path)))
|
||||||
)
|
)
|
||||||
assert in_repo_store.exists("my_generator", "my_value")
|
assert in_repo_store.exists("my_generator", "my_value")
|
||||||
assert in_repo_store.get("my_generator", "my_value").decode() == input_value
|
assert in_repo_store.get("my_generator", "my_value").decode() == input_value
|
||||||
@@ -339,9 +349,11 @@ def test_share_flag(
|
|||||||
monkeypatch.chdir(flake.path)
|
monkeypatch.chdir(flake.path)
|
||||||
sops_setup.init()
|
sops_setup.init()
|
||||||
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
|
cli.run(["vars", "generate", "--flake", str(flake.path), "my_machine"])
|
||||||
sops_store = sops.SecretStore(Machine(name="my_machine", flake=FlakeId(flake.path)))
|
sops_store = sops.SecretStore(
|
||||||
|
Machine(name="my_machine", flake=FlakeId(str(flake.path)))
|
||||||
|
)
|
||||||
in_repo_store = in_repo.FactStore(
|
in_repo_store = in_repo.FactStore(
|
||||||
Machine(name="my_machine", flake=FlakeId(flake.path))
|
Machine(name="my_machine", flake=FlakeId(str(flake.path)))
|
||||||
)
|
)
|
||||||
# check secrets stored correctly
|
# check secrets stored correctly
|
||||||
assert sops_store.exists("shared_generator", "my_secret", shared=True)
|
assert sops_store.exists("shared_generator", "my_secret", shared=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user