From 053973dd415e4848316c65393be10ee35850a98e Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sat, 28 Aug 2021 06:37:52 -0500 Subject: [PATCH] testing with jails --- ' | 28 ++++++++++++++++++++ .editorconfig | 2 +- README.md | 50 ++++++++++++------------------------ compile-database/index.ts | 3 --- jails/.gitignore | 1 + jails/default.nix | 14 ++++++++++ jails/ocamlStudentModule.nix | 34 ++++++++++++++++++++++++ 7 files changed, 95 insertions(+), 37 deletions(-) create mode 100644 ' create mode 100644 jails/.gitignore create mode 100644 jails/default.nix create mode 100644 jails/ocamlStudentModule.nix diff --git a/' b/' new file mode 100644 index 0000000..1db7909 --- /dev/null +++ b/' @@ -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} + ''; +} diff --git a/.editorconfig b/.editorconfig index fe226f3..c9a90a1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,5 +3,5 @@ root = true [*] indent_style = space -[*.{svelte,ts,json,rst}] +[*.{md,svelte,ts,json,rst}] indent_size = 2 diff --git a/README.md b/README.md index 82510ca..ca58753 100644 --- a/README.md +++ b/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. diff --git a/compile-database/index.ts b/compile-database/index.ts index 309065a..a768a40 100644 --- a/compile-database/index.ts +++ b/compile-database/index.ts @@ -4,9 +4,6 @@ import * as yaml from "js-yaml"; import { init } from "./db"; -class Page { -} - async function main() { // TODO: configure this thru cmdline or something later let materials_dir = "../material"; diff --git a/jails/.gitignore b/jails/.gitignore new file mode 100644 index 0000000..c4a847d --- /dev/null +++ b/jails/.gitignore @@ -0,0 +1 @@ +/result diff --git a/jails/default.nix b/jails/default.nix new file mode 100644 index 0000000..f351a9f --- /dev/null +++ b/jails/default.nix @@ -0,0 +1,14 @@ +{ pkgs ? import {} }: + +let + ocamlStudentModule = pkgs.callPackage ./ocamlStudentModule.nix {}; +in +pkgs.stdenv.mkDerivation { + name = "edujails"; + src = ./.; + + installPhase = '' + mkdir -p $out/bin + cp ${ocamlStudentModule} $out/bin/ocamlStudentModule + ''; +} diff --git a/jails/ocamlStudentModule.nix b/jails/ocamlStudentModule.nix new file mode 100644 index 0000000..ab56caf --- /dev/null +++ b/jails/ocamlStudentModule.nix @@ -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 + ''; +}