Skip to content

Commit 10b1561

Browse files
committed
.
1 parent b3396e1 commit 10b1561

File tree

7 files changed

+182
-95
lines changed

7 files changed

+182
-95
lines changed

docs/Makefile

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,9 @@ tmp:
2020
mkdir $@
2121

2222
tmp/all-done: .gitignore flake.nix index.html
23-
nix develop --command sh -c "\
24-
[ ! -z $$STAGE ] && openssl req -subj '/C=..' -nodes -x509 -keyout tmp/privkey.pem -out tmp/fullchain.pem && http-server --tls --cert tmp/fullchain.pem --key tmp/privkey.pem || true"
23+
nix develop .#all
2524
touch $@
2625

2726
tmp/check-done: .gitignore flake.nix index.html
28-
nix develop .#check --command sh -c "\
29-
set -e && \
30-
nixfmt flake.nix && \
31-
nix flake check && \
32-
[ -e index.html ] && js-beautify --end-with-newline --indent-inner-html --no-preserve-newlines --type html --replace index.html && \
33-
[ -e script.js ] && biome check --unsafe --write script.js || true && \
34-
if ls -ap | grep -v -E -x './|../|.env|.gitignore|CNAME|Makefile|index.html|index.js|flake.lock|flake.nix|prm/|pyscript/|python/|script.js|style.css|tmp/' | grep -q .; then exit 1; fi && \
35-
test $$(basename $$(pwd)) = 'docs'"
27+
nix develop .#check
3628
touch $@

docs/flake.nix

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,39 @@
1414
system:
1515
let
1616
pkgs = import nixpkgs { inherit system; };
17-
packages = with pkgs; [ ];
17+
packagesAll = [
18+
pkgs.http-server
19+
pkgs.openssl
20+
];
21+
packagesCheck = [
22+
pkgs.biome
23+
pkgs.nixfmt-rfc-style
24+
pkgs.nodePackages.js-beautify
25+
pkgs.nodejs
26+
];
1827
in
19-
with pkgs;
2028
{
21-
devShells.default = pkgs.mkShell {
22-
buildInputs = packages ++ [
23-
http-server
24-
openssl
25-
];
26-
shellHook = '''';
29+
devShells.all = pkgs.mkShell {
30+
buildInputs = packagesAll;
31+
shellHook = ''
32+
[ ! -z $STAGE ] && openssl req -subj '/C=..' -nodes -x509 -keyout tmp/privkey.pem -out tmp/fullchain.pem && http-server --tls --cert tmp/fullchain.pem --key tmp/privkey.pem || true
33+
exit
34+
'';
2735
};
2836
devShells.check = pkgs.mkShell {
29-
buildInputs = packages ++ [
30-
biome
31-
nixfmt-rfc-style
32-
nodePackages.js-beautify
33-
nodejs
34-
];
37+
buildInputs = packagesAll ++ packagesCheck;
38+
shellHook = ''
39+
set -e
40+
nix flake check
41+
nix fmt
42+
[ -e index.html ] && js-beautify --end-with-newline --indent-inner-html --no-preserve-newlines --type html --replace index.html
43+
[ -e script.js ] && biome check --unsafe --write script.js || true
44+
ls -ap | grep -v -E -x './|../|.env|.gitignore|CNAME|Makefile|index.html|index.js|flake.lock|flake.nix|prm/|pyscript/|python/|script.js|style.css|tmp/' | grep -q . && exit 1 || true
45+
test $(basename $(pwd)) = 'docs'
46+
'';
3547
};
48+
devShells.default = pkgs.mkShell { buildInputs = packagesAll; };
49+
formatter = pkgs.nixfmt-rfc-style;
3650
}
3751
);
3852
}

latex/Makefile

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,9 @@ tmp:
2323
mkdir $@
2424

2525
tmp/all-done: .gitignore flake.nix ms.bib ms.tex
26-
nix develop --command sh -c '\
27-
set -e && \
28-
latexmk -outdir=tmp/ -pdf ms.tex && \
29-
touch tmp/ms.bbl && \
30-
cp tmp/ms.bbl . && \
31-
tar cf tmp/tex.tar ms.bbl ms.bib ms.tex $(grep "^INPUT ./" tmp/ms.fls | uniq | cut -b 9-) && \
32-
rm ms.bbl'
26+
nix develop .#all
3327
touch $@
3428

3529
tmp/check-done: .gitignore flake.nix ms.bib ms.tex
36-
nix develop .#check --command sh -c "\
37-
set -e && \
38-
nixfmt flake.nix && \
39-
nix flake check && \
40-
latexmk -outdir=tmp/ -pdf ms.tex && \
41-
checkcites tmp/ms.aux && \
42-
chktex ms.tex && \
43-
lacheck ms.tex && \
44-
ls -ap | grep -v -E -x './|../|.gitignore|Makefile|flake.lock|flake.nix|ms.bib|ms.tex|prm/|python/|tmp/' | grep -q . && exit 1 || true && \
45-
test $$(basename $$(pwd)) = 'latex'"
30+
nix develop .#check
4631
touch $@

latex/flake.nix

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,36 @@
1616
pkgs = import nixpkgs { inherit system; };
1717
packages = with pkgs; [ texlive.combined.scheme-full ];
1818
in
19-
with pkgs;
2019
{
20+
devShells.all = pkgs.mkShell {
21+
buildInputs = packages;
22+
shellHook = ''
23+
set -e
24+
latexmk -outdir=tmp/ -pdf ms.tex
25+
touch tmp/ms.bbl
26+
cp tmp/ms.bbl .
27+
tar cf tmp/tex.tar ms.bbl ms.bib ms.tex $(grep "^INPUT ./" tmp/ms.fls | uniq | cut -b 9-)
28+
rm ms.bbl
29+
exit
30+
'';
31+
};
32+
devShells.check = pkgs.mkShell {
33+
buildInputs = packages ++ [ pkgs.nixfmt-rfc-style ];
34+
shellHook = ''
35+
set -e
36+
nix flake check
37+
nix fmt
38+
latexmk -outdir=tmp/ -pdf ms.tex
39+
checkcites tmp/ms.aux
40+
chktex ms.tex
41+
lacheck ms.tex
42+
ls -ap | grep -v -E -x './|../|.gitignore|Makefile|flake.lock|flake.nix|ms.bib|ms.tex|prm/|python/|tmp/' | grep -q . && exit 1 || true
43+
test $(basename $(pwd)) = 'latex'
44+
exit
45+
'';
46+
};
2147
devShells.default = pkgs.mkShell { buildInputs = packages; };
22-
devShells.check = pkgs.mkShell { buildInputs = packages ++ [ nixfmt-rfc-style ]; };
48+
formatter = pkgs.nixfmt-rfc-style;
2349
}
2450
);
2551
}

latex/python/Makefile

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,9 @@ tmp:
2020
mkdir $@
2121

2222
tmp/all-done: .gitignore flake.nix main.py
23-
nix develop --command sh -c "\
24-
set -e && \
25-
PYTHONDONTWRITEBYTECODE=1 python3 main.py && \
26-
exit"
23+
nix develop .#all
2724
touch $@
2825

2926
tmp/check-done: .gitignore flake.nix main.py
30-
nix develop .#check --command sh -c "\
31-
set -e && \
32-
export PYTHONDONTWRITEBYTECODE=1 && \
33-
nixfmt flake.nix && \
34-
nix flake check && \
35-
check-python-script main.py && \
36-
ruff format --cache-dir tmp/ruff main.py && \
37-
ruff check --cache-dir tmp/ruff --exit-non-zero-on-fix --fix --select ALL --unsafe-fixes main.py && \
38-
mypy --cache-dir tmp/mypy --ignore-missing-imports --strict main.py && \
39-
if [ -d 'templates/' ]; then djlint templates/ --lint --profile=jinja --quiet --reformat; fi && \
40-
[ -z $$STAGE ] || (unset STAGE && pydoc -w main && mv main.html tmp/) && \
41-
ls -ap | grep -v -E -x './|../|.env|.gitignore|Makefile|flake.lock|flake.nix|main.py|prm/|pyproject.toml|python/|result|static/|templates/|tmp/' | grep -q . && exit 1 || true && \
42-
test $$(basename $$(pwd)) = 'python'"
27+
nix develop .#check
4328
touch $@

latex/python/flake.lock

Lines changed: 75 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

latex/python/flake.nix

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
inputs = {
33
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
44
flake-utils.url = "github:numtide/flake-utils";
5-
check-python-script.url = "github:pbizopoulos/check-python-script/main?dir=python";
5+
check-python-script.url = "github:pbizopoulos/check-python-script?dir=python";
6+
onnxscript.url = "github:pbizopoulos/nixpkgs?dir=onnxscript";
67
};
78

89
outputs =
@@ -11,6 +12,7 @@
1112
nixpkgs,
1213
flake-utils,
1314
check-python-script,
15+
onnxscript,
1416
}:
1517
flake-utils.lib.eachDefaultSystem (
1618
system:
@@ -19,40 +21,53 @@
1921
inherit system;
2022
config.allowUnfree = true;
2123
};
22-
onnxscript = pkgs.python3Packages.buildPythonPackage rec {
23-
pname = "onnxscript";
24-
version = "0.1.0.dev20240701";
25-
format = "wheel";
26-
src = pkgs.python3Packages.fetchPypi rec {
27-
inherit pname version format;
28-
sha256 = "hTNedOxupvqtXwx3nu43Gb/kjeAPODBuTtKe4FP20qQ=";
29-
dist = python;
30-
python = "py3";
31-
};
32-
};
33-
packages = with pkgs; [
34-
onnxscript
35-
python3Packages.matplotlib
36-
python3Packages.onnx
37-
python3Packages.pandas
38-
python3Packages.scipy
39-
python3Packages.torch-bin
40-
python3Packages.torchvision-bin
41-
python3Packages.types-requests
24+
packagesAll = [
25+
onnxscript.packages.${system}.default
26+
pkgs.python3Packages.matplotlib
27+
pkgs.python3Packages.onnx
28+
pkgs.python3Packages.pandas
29+
pkgs.python3Packages.scipy
30+
pkgs.python3Packages.torch-bin
31+
pkgs.python3Packages.torchvision-bin
32+
pkgs.python3Packages.types-requests
33+
];
34+
packagesCheck = [
35+
check-python-script.packages.${system}.default
36+
pkgs.djlint
37+
pkgs.mypy
38+
pkgs.nixfmt-rfc-style
39+
pkgs.ruff
4240
];
4341
in
44-
with pkgs;
4542
{
46-
devShells.default = pkgs.mkShell { buildInputs = packages; };
43+
devShells.all = pkgs.mkShell {
44+
buildInputs = packagesAll;
45+
shellHook = ''
46+
set -e
47+
PYTHONDONTWRITEBYTECODE=1 python3 main.py || exit
48+
exit
49+
'';
50+
};
4751
devShells.check = pkgs.mkShell {
48-
buildInputs = packages ++ [
49-
check-python-script.packages.${system}.default
50-
djlint
51-
mypy
52-
nixfmt-rfc-style
53-
ruff
54-
];
52+
buildInputs = packagesAll ++ packagesCheck;
53+
shellHook = ''
54+
set -e
55+
export PYTHONDONTWRITEBYTECODE=1
56+
nix flake check
57+
nix fmt
58+
check-python-script main.py
59+
ruff format --cache-dir tmp/ruff main.py
60+
ruff check --cache-dir tmp/ruff --exit-non-zero-on-fix --fix --select ALL --unsafe-fixes main.py
61+
mypy --cache-dir tmp/mypy --ignore-missing-imports --strict main.py
62+
if [ -d 'templates/' ]; then djlint templates/ --lint --profile=jinja --quiet --reformat; fi
63+
[ -z $STAGE ] || (unset STAGE && pydoc -w main && mv main.html tmp/)
64+
ls -ap | grep -v -E -x './|../|.env|.gitignore|Makefile|flake.lock|flake.nix|main.py|prm/|pyproject.toml|python/|result|static/|templates/|tmp/' | grep -q . && exit 1 || true
65+
test $(basename $(pwd)) = 'python'
66+
exit
67+
'';
5568
};
69+
devShells.default = pkgs.mkShell { buildInputs = packagesAll; };
70+
formatter = pkgs.nixfmt-rfc-style;
5671
}
5772
);
5873
}

0 commit comments

Comments
 (0)