pkgs(vars-generator): init new package to generate vars

This commit is contained in:
Johannes Kirschbauer
2025-04-18 15:46:11 +02:00
parent 310b6c8345
commit a01437d01e
7 changed files with 92 additions and 1 deletions

View File

@@ -9,6 +9,7 @@
./webview-ui/flake-module.nix
./distro-packages/flake-module.nix
./icon-update/flake-module.nix
./vars-generate/flake-module.nix
];
flake.packages.x86_64-linux =

View File

View File

@@ -148,7 +148,7 @@ def parse_args() -> argparse.Namespace:
return parser.parse_args()
if __name__ == "__main__":
def main() -> None:
os.environ["CLAN_NO_COMMIT"] = "1"
args = parse_args()
test_dir = args.repo_root / args.test_dir
@@ -181,3 +181,7 @@ if __name__ == "__main__":
f.seek(0)
os.environ["SOPS_AGE_KEY_FILE"] = f.name
generate_vars(list(machines))
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,14 @@
{
buildPythonApplication,
python,
clan-cli,
}:
buildPythonApplication {
name = "vars-generate";
src = ./.;
format = "pyproject";
buildInputs = [ (python.pkgs.toPythonModule clan-cli) ];
nativeBuildInputs = [
(python.withPackages (ps: [ ps.setuptools ]))
];
}

View File

@@ -0,0 +1,17 @@
{ ... }:
{
perSystem =
{
config,
pkgs,
...
}:
{
# devShells.vars-generator = pkgs.callPackage ./shell.nix {
# };
packages.vars-generator = pkgs.python3.pkgs.callPackage ./default.nix {
inherit (config.packages) clan-cli;
};
};
}

View File

@@ -0,0 +1,34 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "vars-generate"
description = "vars generate"
dynamic = ["version"]
scripts = { vars-generate = "cli:main.main" }
[project.urls]
Homepage = "https://clan.lol/"
Documentation = "https://docs.clan.lol/"
Repository = "https://git.clan.lol/clan/clan-core"
[tool.setuptools.packages.find]
exclude = ["result", "**/__pycache__"]
[tool.pytest.ini_options]
testpaths = "tests"
faulthandler_timeout = 60
log_level = "DEBUG"
log_format = "%(levelname)s: %(message)s\n %(pathname)s:%(lineno)d::%(funcName)s"
addopts = "--cov . --cov-report term --cov-report html:.reports/html --no-cov-on-fail --durations 5 --color=yes --new-first" # Add --pdb for debugging
norecursedirs = "tests/helpers"
[tool.mypy]
python_version = "3.12"
warn_redundant_casts = true
disallow_untyped_calls = true
disallow_untyped_defs = true
no_implicit_optional = true

View File

@@ -0,0 +1,21 @@
# Test that we can generate vars
{
vars.generators = {
test_generator_1 = {
files.hello = {
secret = false;
};
script = ''
echo "hello world 1" > $out/hello
'';
};
test_generator_2 = {
files.hello = {
secret = false;
};
script = ''
echo "hello world 2" > $out/hello
'';
};
};
}