Loading pkgs/by-name/ni/nixos-rebuild-ng/README.md +32 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,38 @@ an attempt of the rewrite. And use `nixos-rebuild-ng` instead of `nixos-rebuild`. ## Development Run: ```console nix-build -A nixos-rebuild-ng.tests.ci ``` The command above will run the unit tests and linters, and also check if the code is formatted. However, sometimes is more convenient to run just a few tests to debug, in this case you can run: ```console nix-shell -A nixos-rebuild-ng.devShell ``` The command above should automatically put you inside `src` directory, and you can run: ```console # run program python -m nixos_rebuild # run tests python -m pytest # check types mypy . # fix lint issues ruff check --fix . # format code ruff format . ``` ## Current caveats - For now we will install it in `nixos-rebuild-ng` path by default, to avoid Loading pkgs/by-name/ni/nixos-rebuild-ng/package.nix +35 −30 Original line number Diff line number Diff line { lib, installShellFiles, mkShell, nix, nixos-rebuild, nixos-rebuild-ng, python3, runCommand, withNgSuffix ? true, Loading Loading @@ -60,25 +60,30 @@ python3.pkgs.buildPythonApplication rec { pytestFlagsArray = [ "-vv" ]; # NOTE: this is a CI test rather than a build-time test because we want to # keep the build closures small passthru.tests = { ci = runCommand "${pname}-ci" { nativeBuildInputs = [ nixos-rebuild-ng # to trigger build (python3.withPackages ( passthru = let python-with-pkgs = python3.withPackages ( ps: with ps; [ mypy pytest ruff types-tabulate # dependencies tabulate ] )) ]; } '' ); in { devShell = mkShell { packages = [ python-with-pkgs ]; shellHook = '' cd pkgs/by-name/ni/nixos-rebuild-ng/src || true ''; }; # NOTE: this is a passthru test rather than a build-time test because we # want to keep the build closures small tests.ci = runCommand "${pname}-ci" { nativeBuildInputs = [ python-with-pkgs ]; } '' export RUFF_CACHE_DIR="$(mktemp -d)" echo -e "\x1b[32m## run mypy\x1b[0m" Loading pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/__init__.py +0 −4 Original line number Diff line number Diff line Loading @@ -231,7 +231,3 @@ def main() -> None: raise ex else: sys.exit(str(ex)) if __name__ == "__main__": main() pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/__main__.py 0 → 100644 +4 −0 Original line number Diff line number Diff line from . import main if __name__ == "__main__": main() Loading
pkgs/by-name/ni/nixos-rebuild-ng/README.md +32 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,38 @@ an attempt of the rewrite. And use `nixos-rebuild-ng` instead of `nixos-rebuild`. ## Development Run: ```console nix-build -A nixos-rebuild-ng.tests.ci ``` The command above will run the unit tests and linters, and also check if the code is formatted. However, sometimes is more convenient to run just a few tests to debug, in this case you can run: ```console nix-shell -A nixos-rebuild-ng.devShell ``` The command above should automatically put you inside `src` directory, and you can run: ```console # run program python -m nixos_rebuild # run tests python -m pytest # check types mypy . # fix lint issues ruff check --fix . # format code ruff format . ``` ## Current caveats - For now we will install it in `nixos-rebuild-ng` path by default, to avoid Loading
pkgs/by-name/ni/nixos-rebuild-ng/package.nix +35 −30 Original line number Diff line number Diff line { lib, installShellFiles, mkShell, nix, nixos-rebuild, nixos-rebuild-ng, python3, runCommand, withNgSuffix ? true, Loading Loading @@ -60,25 +60,30 @@ python3.pkgs.buildPythonApplication rec { pytestFlagsArray = [ "-vv" ]; # NOTE: this is a CI test rather than a build-time test because we want to # keep the build closures small passthru.tests = { ci = runCommand "${pname}-ci" { nativeBuildInputs = [ nixos-rebuild-ng # to trigger build (python3.withPackages ( passthru = let python-with-pkgs = python3.withPackages ( ps: with ps; [ mypy pytest ruff types-tabulate # dependencies tabulate ] )) ]; } '' ); in { devShell = mkShell { packages = [ python-with-pkgs ]; shellHook = '' cd pkgs/by-name/ni/nixos-rebuild-ng/src || true ''; }; # NOTE: this is a passthru test rather than a build-time test because we # want to keep the build closures small tests.ci = runCommand "${pname}-ci" { nativeBuildInputs = [ python-with-pkgs ]; } '' export RUFF_CACHE_DIR="$(mktemp -d)" echo -e "\x1b[32m## run mypy\x1b[0m" Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/__init__.py +0 −4 Original line number Diff line number Diff line Loading @@ -231,7 +231,3 @@ def main() -> None: raise ex else: sys.exit(str(ex)) if __name__ == "__main__": main()
pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/__main__.py 0 → 100644 +4 −0 Original line number Diff line number Diff line from . import main if __name__ == "__main__": main()