Skip to content

Commit 79f4e0b

Browse files
committed
convert to flakes
1 parent a5a9794 commit 79f4e0b

20 files changed

+379
-237
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/workflow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ jobs:
55
runs-on: ubuntu-20.04
66
steps:
77
- uses: actions/checkout@v4
8+
- uses: cachix/install-nix-action@v27
89
- run: |
910
cd docs/ && make clean check all && cd ..
1011
cd latex/python/ && make clean check all && cd ../..

README

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
# Requirements
77
# POSIX Shell & Utilities
88
# Git
9-
# Docker
10-
# NVIDIA Container Toolkit (Optional)
9+
# Nix
1110

1211
# Download
1312
git clone git@github.com:pbizopoulos/signal2image-modules-in-deep-neural-networks-for-eeg-classification ~/github.com/pbizopoulos/signal2image-modules-in-deep-neural-networks-for-eeg-classification

docs/.dockerignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/Dockerfile

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/Makefile

Lines changed: 18 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,36 @@
11
.POSIX:
22

3-
cmd = node index.js
3+
all: tmp tmp/all-done
44

5-
all: tmp/all-done
6-
7-
check: tmp/check-done
5+
check: tmp tmp/check-done
86

97
clean:
108
rm -rf tmp/
119

12-
.dockerignore:
13-
printf '*\n!package.json\n' > $@
14-
1510
.gitignore:
1611
printf '.env\ntmp/\n' > $@
1712

18-
Dockerfile:
19-
printf 'FROM node\nRUN apt-get update && apt-get install -y jq\nWORKDIR /usr/src/app\nCOPY package.json /usr/src/\nRUN npm install --omit=dev --prefix /usr/src\nRUN npm install --global $$(jq --raw-output ".devDependencies | to_entries[] | \\"\(.key)@\(.value)\\"" /usr/src/package.json)\n' > $@
20-
21-
index.js:
22-
printf 'const dns = require("node:dns"); const fs = require("node:fs"); const https = require("node:https"); const os = require("node:os"); const serveHandler = require("serve-handler"); const server = https.createServer({ cert: fs.readFileSync("tmp/fullchain.pem"), key: fs.readFileSync("tmp/privkey.pem"), }, (request, response) => { return serveHandler(request, response); }); if (process.env.STAGE) { server.listen(443, "0.0.0.0", () => { dns.lookup(os.hostname(), (err, address) => { console.log(`Container IP address: https://$${address}`); }); process.on("SIGINT", () => { process.exit(0); }); }); }' > $@
13+
flake.nix:
14+
nix flake init
2315

24-
package.json:
25-
printf '{"stylelint":{"extends":"stylelint-config-standard","plugins":["stylelint-order"],"rules":{"order/properties-alphabetical-order":true}},"dependencies":{"serve":"latest"},"devDependencies":{"@biomejs/biome":"latest","css-validator":"latest","html-validate":"latest","js-beautify":"latest","linkinator":"latest","sort-package-json":"latest","stylelint":"latest","stylelint-config-standard":"latest","stylelint-order":"latest"}}' > $@
16+
index.html:
17+
touch $@
2618

2719
tmp:
2820
mkdir $@
2921

30-
tmp/all-done: index.js tmp tmp/fullchain.pem
31-
docker container run \
32-
$$(test -t 0 && printf '%s' '--interactive --tty') \
33-
--detach-keys 'ctrl-^,ctrl-^' \
34-
--env STAGE=$(STAGE) \
35-
--rm \
36-
--user $$(id -u):$$(id -g) \
37-
--volume $$(pwd):/usr/src/app/ \
38-
$$(docker image build --quiet .) $(cmd)
39-
touch $@
40-
41-
tmp/check-css-done: style.css
42-
docker container run \
43-
--rm \
44-
--volume $$(pwd):/usr/src/app/ \
45-
$$(docker image build --quiet .) /bin/sh -c '\
46-
stylelint --fix style.css && \
47-
css-validator --profile css3svg style.css'
22+
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"
4825
touch $@
4926

50-
tmp/check-done: .dockerignore .gitignore Dockerfile package.json tmp
51-
$(MAKE) $$(test -s style.css && printf 'tmp/check-css-done') $$(test -s index.html && printf 'tmp/check-html-done') tmp/check-js-done
52-
if ls -ap | grep -v -E -x './|../|.dockerignore|.env|.gitignore|CNAME|Dockerfile|Makefile|docs/|index.html|index.js|package.json|prm/|pyscript/|python/|script.js|style.css|tmp/' | grep -q .; then false; fi
53-
test $$(basename $$(pwd)) = "docs"
27+
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/|python/|script.js|style.css|tmp/' | grep -q .; then exit 1; fi && \
35+
test $$(basename $$(pwd)) = 'docs'"
5436
touch $@
55-
56-
tmp/check-html-done: index.html
57-
docker container run \
58-
--rm \
59-
--volume $$(pwd):/usr/src/app/ \
60-
$$(docker image build --quiet .) /bin/sh -c '\
61-
js-beautify --end-with-newline --indent-inner-html --no-preserve-newlines --type html --replace index.html && \
62-
linkinator index.html && \
63-
html-validate index.html'
64-
touch $@
65-
66-
tmp/check-js-done: index.js
67-
docker container run \
68-
--rm \
69-
--volume $$(pwd):/usr/src/app/ \
70-
$$(docker image build --quiet .) /bin/sh -c "\
71-
script_js=$$([ -e script.js ] && echo script.js) && \
72-
style_css=$$([ -e style.css ] && echo style.css) && \
73-
sort-package-json package.json && \
74-
biome check --apply-unsafe index.js package.json \$$script_js \$$style_css"
75-
touch $@
76-
77-
tmp/fullchain.pem: .dockerignore .gitignore Dockerfile package.json
78-
docker container run \
79-
--rm \
80-
--user $$(id -u):$$(id -g) \
81-
--volume $$(pwd):/usr/src/app/ \
82-
$$(docker image build --quiet .) openssl req -subj "/C=.." -nodes -x509 -keyout tmp/privkey.pem -out $@

docs/flake.lock

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

docs/flake.nix

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
4+
flake-utils.url = "github:numtide/flake-utils";
5+
};
6+
7+
outputs =
8+
{
9+
self,
10+
nixpkgs,
11+
flake-utils,
12+
}:
13+
flake-utils.lib.eachDefaultSystem (
14+
system:
15+
let
16+
pkgs = import nixpkgs { inherit system; };
17+
packages = with pkgs; [ ];
18+
in
19+
with pkgs;
20+
{
21+
devShells.default = pkgs.mkShell {
22+
buildInputs = packages ++ [
23+
http-server
24+
openssl
25+
];
26+
shellHook = '''';
27+
};
28+
devShells.check = pkgs.mkShell {
29+
buildInputs = packages ++ [
30+
biome
31+
nixfmt-rfc-style
32+
nodePackages.js-beautify
33+
nodejs
34+
];
35+
};
36+
}
37+
);
38+
}

docs/package.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

latex/.dockerignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)