testing with jails
This commit is contained in:
parent
cf562b6ec1
commit
053973dd41
7 changed files with 95 additions and 37 deletions
28
'
Normal file
28
'
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
{ writeTextFile, nsjail }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inner = writeTextFile {
|
||||||
|
name = "ocamlStudentModuleInner";
|
||||||
|
executable = true;
|
||||||
|
text = ''
|
||||||
|
INTERFACE_FILE=$1
|
||||||
|
STUDENT_FILE=$2
|
||||||
|
DRIVER_FILE=$3
|
||||||
|
|
||||||
|
ocamlc -o student.cmi $INTERFACE_FILE
|
||||||
|
ocamlc -o student.cmo $STUDENT_FILE
|
||||||
|
ocaml student.cmo $DRIVER_FILE
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
writeTextFile {
|
||||||
|
name = "ocamlStudentModule";
|
||||||
|
executable = true;
|
||||||
|
text = ''
|
||||||
|
JAIL=$(mktemp -d)
|
||||||
|
${nsjail}/bin/nsjail \
|
||||||
|
-Mo \ # launch a single process using clone/execve
|
||||||
|
--chroot $JAIL
|
||||||
|
${inner}
|
||||||
|
'';
|
||||||
|
}
|
|
@ -3,5 +3,5 @@ root = true
|
||||||
[*]
|
[*]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
|
|
||||||
[*.{svelte,ts,json,rst}]
|
[*.{md,svelte,ts,json,rst}]
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
50
README.md
50
README.md
|
@ -1,38 +1,22 @@
|
||||||
# create-svelte
|
education project
|
||||||
|
===
|
||||||
|
|
||||||
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte);
|
The education project is just my personal ideal education system. Here are its
|
||||||
|
goals:
|
||||||
|
|
||||||
## Creating a project
|
- **Learning is measured through mastery, which is measured through tests.**
|
||||||
|
Mastery is similar to what Anki uses and is trained with spaced repetition.
|
||||||
|
Notably, doing well on a test once doesn't indicate complete mastery and
|
||||||
|
failing a test doesn't indicate complete unmastery. Skipping a question
|
||||||
|
lowers mastery a bit less than getting it wrong.
|
||||||
|
|
||||||
If you're seeing this, you've probably already done this step. Congrats!
|
- **Learning by doing.** Many different types of activity formats that should
|
||||||
|
all contribute to mastery of the given concepts. In addition, mastery of
|
||||||
|
certain concepts should also backpropagate to the concepts it depends on. The
|
||||||
|
planned list of activity types are:
|
||||||
|
* Classic multiple-choice problems
|
||||||
|
* Short-answer problems (for math)
|
||||||
|
* Write a short program (+ linting)
|
||||||
|
* Write a bigger project
|
||||||
|
|
||||||
```bash
|
|
||||||
# create a new project in the current directory
|
|
||||||
npm init svelte@next
|
|
||||||
|
|
||||||
# create a new project in my-app
|
|
||||||
npm init svelte@next my-app
|
|
||||||
```
|
|
||||||
|
|
||||||
> Note: the `@next` is temporary
|
|
||||||
|
|
||||||
## Developing
|
|
||||||
|
|
||||||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run dev
|
|
||||||
|
|
||||||
# or start the server and open the app in a new browser tab
|
|
||||||
npm run dev -- --open
|
|
||||||
```
|
|
||||||
|
|
||||||
## Building
|
|
||||||
|
|
||||||
Before creating a production version of your app, install an [adapter](https://kit.svelte.dev/docs#adapters) for your target environment. Then:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run build
|
|
||||||
```
|
|
||||||
|
|
||||||
> You can preview the built app with `npm run preview`, regardless of whether you installed an adapter. This should _not_ be used to serve your app in production.
|
|
||||||
|
|
|
@ -4,9 +4,6 @@ import * as yaml from "js-yaml";
|
||||||
|
|
||||||
import { init } from "./db";
|
import { init } from "./db";
|
||||||
|
|
||||||
class Page {
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
// TODO: configure this thru cmdline or something later
|
// TODO: configure this thru cmdline or something later
|
||||||
let materials_dir = "../material";
|
let materials_dir = "../material";
|
||||||
|
|
1
jails/.gitignore
vendored
Normal file
1
jails/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/result
|
14
jails/default.nix
Normal file
14
jails/default.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
|
|
||||||
|
let
|
||||||
|
ocamlStudentModule = pkgs.callPackage ./ocamlStudentModule.nix {};
|
||||||
|
in
|
||||||
|
pkgs.stdenv.mkDerivation {
|
||||||
|
name = "edujails";
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp ${ocamlStudentModule} $out/bin/ocamlStudentModule
|
||||||
|
'';
|
||||||
|
}
|
34
jails/ocamlStudentModule.nix
Normal file
34
jails/ocamlStudentModule.nix
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
{ writeTextFile, nsjail }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inner = writeTextFile {
|
||||||
|
name = "ocamlStudentModuleInner";
|
||||||
|
executable = true;
|
||||||
|
text = ''
|
||||||
|
#!/bin/sh
|
||||||
|
INTERFACE_FILE=$1
|
||||||
|
STUDENT_FILE=$2
|
||||||
|
DRIVER_FILE=$3
|
||||||
|
|
||||||
|
ocamlc -o student.cmi $INTERFACE_FILE
|
||||||
|
ocamlc -o student.cmo $STUDENT_FILE
|
||||||
|
ocaml student.cmo $DRIVER_FILE
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
writeTextFile {
|
||||||
|
name = "ocamlStudentModule";
|
||||||
|
executable = true;
|
||||||
|
text = ''
|
||||||
|
JAIL=$(mktemp -d)
|
||||||
|
mkdir -p $JAIL/bin
|
||||||
|
cp ${inner} $JAIL/bin/ocamlStudentModule
|
||||||
|
${nsjail}/bin/nsjail \
|
||||||
|
-Mo \
|
||||||
|
--chroot $JAIL \
|
||||||
|
-R /bin/sh \
|
||||||
|
-R /bin/ls \
|
||||||
|
/bin/ls
|
||||||
|
# /bin/ocamlStudentModule
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue