Merge pull request 'pkgs(vars-generator): init new package to generate vars' (#3357) from hsjobeki/clan-core:patch-2 into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3357
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
./webview-ui/flake-module.nix
|
./webview-ui/flake-module.nix
|
||||||
./distro-packages/flake-module.nix
|
./distro-packages/flake-module.nix
|
||||||
./icon-update/flake-module.nix
|
./icon-update/flake-module.nix
|
||||||
|
./vars-generate/flake-module.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
flake.packages.x86_64-linux =
|
flake.packages.x86_64-linux =
|
||||||
|
|||||||
0
pkgs/vars-generate/cli/__init_.py
Normal file
0
pkgs/vars-generate/cli/__init_.py
Normal file
@@ -148,7 +148,7 @@ def parse_args() -> argparse.Namespace:
|
|||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main() -> None:
|
||||||
os.environ["CLAN_NO_COMMIT"] = "1"
|
os.environ["CLAN_NO_COMMIT"] = "1"
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
test_dir = args.repo_root / args.test_dir
|
test_dir = args.repo_root / args.test_dir
|
||||||
@@ -181,3 +181,7 @@ if __name__ == "__main__":
|
|||||||
f.seek(0)
|
f.seek(0)
|
||||||
os.environ["SOPS_AGE_KEY_FILE"] = f.name
|
os.environ["SOPS_AGE_KEY_FILE"] = f.name
|
||||||
generate_vars(list(machines))
|
generate_vars(list(machines))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
14
pkgs/vars-generate/default.nix
Normal file
14
pkgs/vars-generate/default.nix
Normal 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 ]))
|
||||||
|
];
|
||||||
|
}
|
||||||
17
pkgs/vars-generate/flake-module.nix
Normal file
17
pkgs/vars-generate/flake-module.nix
Normal 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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
34
pkgs/vars-generate/pyproject.toml
Normal file
34
pkgs/vars-generate/pyproject.toml
Normal 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
|
||||||
|
|
||||||
21
pkgs/vars-generate/test/vars.nix
Normal file
21
pkgs/vars-generate/test/vars.nix
Normal 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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user