Skip to content

Commit 0bf2cd3

Browse files
committed
add package for nixos-anywhere
1 parent 8e3b70c commit 0bf2cd3

File tree

4 files changed

+105
-2
lines changed

4 files changed

+105
-2
lines changed

pyproject.toml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "nixos-anywhere-pxe"
7+
description = "Install NixOS with PXE"
8+
dynamic = ["version"]
9+
scripts = { nixos-anywhere-pxe = "nixos_anywhere_pxe:main"}
10+
11+
[tool.pytest.ini_options]
12+
addopts = "--cov . --cov-report term --cov-fail-under=100 --no-cov-on-fail"
13+
14+
[tool.mypy]
15+
python_version = "3.10"
16+
warn_redundant_casts = true
17+
disallow_untyped_calls = true
18+
disallow_untyped_defs = true
19+
no_implicit_optional = true
20+
21+
[[tool.mypy.overrides]]
22+
module = "setuptools.*"
23+
ignore_missing_imports = true
24+
25+
[[tool.mypy.overrides]]
26+
module = "pytest.*"
27+
ignore_missing_imports = true
28+
29+
[tool.ruff]
30+
line-length = 88
31+
32+
select = ["E", "F", "I"]
33+
ignore = [ "E501" ]
34+
35+
[tool.black]
36+
line-length = 88
37+
target-version = ['py310']
38+
include = '\.pyi?$'
39+
exclude = '''
40+
/(
41+
\.git
42+
| \.hg
43+
| \.mypy_cache
44+
| \.tox
45+
| \.venv
46+
| _build
47+
| buck-out
48+
| build
49+
| dist
50+
# The following are specific to Black, you probably don't want those.
51+
| blib2to3
52+
| tests/data
53+
| profiling
54+
)/
55+
'''

src/flake-module.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
perSystem = { config, pkgs, ... }: {
33
packages = {
44
nixos-anywhere = pkgs.callPackage ./. { };
5+
nixos-anywhere-pxe = pkgs.callPackage ./nixos_anywhere_pxe { };
56
default = config.packages.nixos-anywhere;
67
};
78
devShells.default = config.packages.nixos-anywhere.devShell;

nixos-anywhere-pxe.py renamed to src/nixos_anywhere_pxe/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
NIXOS_ANYWHERE_SH = Path(__file__).parent.absolute() / "src/nixos-anywhere.sh"
2323

24+
2425
def run(
2526
cmd: Union[str, list[str]],
2627
input: Optional[str] = None,
@@ -384,13 +385,14 @@ def build_pxe_image(netboot_image_flake: str) -> Path:
384385
)
385386
return Path(res.stdout.strip())
386387

388+
387389
def pause():
388390
print("")
389391
# no clue how to flush stdin with python. Gonna wait for a specific string instead (as opposed to wait for [enter]).
390392
answer = ""
391-
while (answer != "continue"):
393+
while answer != "continue":
392394
answer = input(
393-
"Answer 'continue' to terminate this script and tear down the network to the server: "
395+
"Answer 'continue' to terminate this script and tear down the network to the server: "
394396
)
395397

396398

src/nixos_anywhere_pxe/default.nix

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{ pkgs
2+
, lib
3+
, python3
4+
, ruff
5+
, runCommand
6+
}:
7+
let
8+
src = ../..;
9+
10+
devDependencies = lib.attrValues {
11+
inherit (pkgs) ruff;
12+
inherit (python3.pkgs)
13+
black
14+
mypy
15+
pytest
16+
pytest-cov
17+
pytest-subprocess
18+
setuptools
19+
wheel
20+
;
21+
};
22+
23+
package = python3.pkgs.buildPythonPackage {
24+
name = "nixos-anywhere-pxe";
25+
inherit src;
26+
format = "pyproject";
27+
nativeBuildInputs = [
28+
python3.pkgs.setuptools
29+
];
30+
passthru.tests = { inherit nixos-anywhere-pxe-mypy; };
31+
passthru.devDependencies = devDependencies;
32+
};
33+
34+
checkPython = python3.withPackages (_ps: devDependencies);
35+
36+
nixos-anywhere-pxe-mypy = runCommand "nixos-anywhere-pxe-mypy" { } ''
37+
cp -r ${src} ./src
38+
chmod +w -R ./src
39+
cd src
40+
${checkPython}/bin/mypy .
41+
touch $out
42+
'';
43+
44+
in
45+
package

0 commit comments

Comments
 (0)