├── .env ├── .github └── workflows │ └── go.yml ├── .gitignore ├── Makefile ├── README.md ├── bin ├── 386 │ └── ricket ├── amd64 │ └── ricket └── arm │ └── ricket ├── go.mod ├── go.sum ├── mkfile ├── package.rc ├── ricket.go ├── ricket.troff └── test.wasm /.env: -------------------------------------------------------------------------------- 1 | GOOS=plan9 2 | -------------------------------------------------------------------------------- /.github/workflows/go.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a golang project 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go 3 | 4 | name: Go 5 | 6 | on: 7 | push: 8 | branches: [ "main" ] 9 | pull_request: 10 | branches: [ "main" ] 11 | 12 | jobs: 13 | 14 | build: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v3 18 | 19 | - name: Set up Go 20 | uses: actions/setup-go@v4 21 | with: 22 | go-version: '1.20' 23 | 24 | - name: Install dependencies 25 | run: go get . 26 | 27 | - name: Build 28 | run: GOOS=plan9 go build -v ./... 29 | 30 | - name: Test 31 | run: GOOS=plan9 go test -v ./... 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SlashScreen/ricket/abf622b2ac356cc642dacfe2294275f225fd1398/.gitignore -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ARCHS = amd64 arm 386 2 | 3 | build: 4 | @echo "Building Ricket for: $(ARCHS)" 5 | @$(foreach arch, $(ARCHS), mkdir -p bin/$(arch) ; GOOS=plan9 GOARCH=$(arch) go build -o bin/$(arch)/ricket ;) 6 | @echo "Built plan 9 executables." 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ricket 2 | 3 | ## What is Ricket? 4 | 5 | Ricket is an attempt to open up the WASI platform to the Plan 9 OS, and hopefully allow more software to be used on Plan 9 with little cost to the developer. 6 | 7 | Ricket is a frontend and toolset for [wazero](https://github.com/tetratelabs/wazero) tailored specifically for use with Plan 9. 8 | 9 | Special thanks to Ori on the #cat-v IRC channel for making this more Plan 9-like. 10 | 11 | Installing on a 9front system is easy: 12 | 13 | ```shell 14 | git/clone https://github.com/SlashScreen/ricket 15 | cd ricket 16 | mk install 17 | ``` 18 | 19 | ## Project status 20 | 21 | Ricket is now in beta- it should work, but it may have bugs. If something goes wrong, file a bug report! 22 | 23 | ## Project goals 24 | 25 | - [x] Be able to run WASI programs at all 26 | - [X] Be able to run WASI programs on Plan 9 27 | - [X] Be able to package WASI programs as standalone apps 28 | -------------------------------------------------------------------------------- /bin/386/ricket: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SlashScreen/ricket/abf622b2ac356cc642dacfe2294275f225fd1398/bin/386/ricket -------------------------------------------------------------------------------- /bin/amd64/ricket: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SlashScreen/ricket/abf622b2ac356cc642dacfe2294275f225fd1398/bin/amd64/ricket -------------------------------------------------------------------------------- /bin/arm/ricket: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SlashScreen/ricket/abf622b2ac356cc642dacfe2294275f225fd1398/bin/arm/ricket -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module ricket 2 | 3 | go 1.19 4 | 5 | require github.com/tetratelabs/wazero v1.4.0 6 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/tetratelabs/wazero v1.2.1 h1:J4X2hrGzJvt+wqltuvcSjHQ7ujQxA9gb6PeMs4qlUWs= 2 | github.com/tetratelabs/wazero v1.2.1/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= 3 | github.com/tetratelabs/wazero v1.3.2-0.20230730235628-1f8c908f1c61 h1:yPFIE2EV4ztzCwR5wC9IhZbKbCu2aokdk+v12wUSeZM= 4 | github.com/tetratelabs/wazero v1.3.2-0.20230730235628-1f8c908f1c61/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= 5 | github.com/tetratelabs/wazero v1.4.0 h1:9/MirYvmkJ/zSUOygKY/ia3t+e+RqIZXKbylIby1WYk= 6 | github.com/tetratelabs/wazero v1.4.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A= 7 | -------------------------------------------------------------------------------- /mkfile: -------------------------------------------------------------------------------- 1 | install:VQ: 2 | mkdir -p /$objtype/bin/ricket 3 | cp bin/$objtype/ricket /$objtype/bin/ricket/run 4 | cp package.rc /$objtype/bin/ricket/package 5 | cp ricket.troff /sys/man/1/ricket 6 | echo Ricket is now installed on your system. 7 | 8 | clean:VQ: 9 | rm -rf /$objtype/bin/ricket 10 | rm -f /sys/man/1/ricket 11 | echo Bye, ricket! 12 | 13 | build:VQ: 14 | echo Please note that go 1.19+ must be installed on the system for this to work. 15 | echo Attempting to build ricket from source. 16 | GOARCH=$objtype go build . 17 | -------------------------------------------------------------------------------- /package.rc: -------------------------------------------------------------------------------- 1 | #!/bin/rc 2 | 3 | flagfmt='o:out out' 4 | args='wasmfile' 5 | if(! eval `''{aux/getflags $*} || ~ $#* 0) 6 | exec aux/usage 7 | if(~ $#out 0) 8 | out = wasm.out 9 | {echo '#!/bin/ricket/run'; cat $1} > $out 10 | chmod +x $out 11 | -------------------------------------------------------------------------------- /ricket.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "crypto/rand" 6 | _ "embed" 7 | "log" 8 | "os" 9 | 10 | "github.com/tetratelabs/wazero" 11 | "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1" 12 | ) 13 | 14 | func main() { 15 | if len(os.Args) == 0 { 16 | help() 17 | } else { 18 | run(os.Args[1]) 19 | } 20 | } 21 | 22 | func run(path string) { 23 | // Instantiate runtime 24 | ctx := context.Background() 25 | r := wazero.NewRuntimeWithConfig(ctx, wazero.NewRuntimeConfigInterpreter()) 26 | defer r.Close(ctx) 27 | 28 | wasi_snapshot_preview1.MustInstantiate(ctx, r) 29 | 30 | // Read program 31 | wasm, err := os.ReadFile(path) 32 | if err != nil { 33 | log.Panicf("failed to read WASM file: %v\n", err) 34 | } 35 | 36 | // if present, strip off #! line 37 | if len(wasm) > 2 && string(wasm[0:2]) == "#!" { 38 | for i := 2; i < len(wasm); i++ { 39 | if wasm[i] == byte('\n') { 40 | wasm = wasm[i+1:] 41 | break 42 | } 43 | } 44 | } 45 | 46 | var wasmArgs []string 47 | if len(os.Args) > 3 { 48 | wasmArgs = os.Args[3:] 49 | } 50 | 51 | // Run program 52 | conf := wazero.NewModuleConfig(). 53 | WithStdout(os.Stdout). 54 | WithStderr(os.Stderr). 55 | WithStdin(os.Stdin). 56 | WithSysNanosleep(). 57 | WithSysNanotime(). 58 | WithSysWalltime(). 59 | WithFSConfig(wazero.NewFSConfig()). 60 | WithRandSource(rand.Reader). 61 | WithArgs(wasmArgs...) 62 | 63 | _, err = r.InstantiateWithConfig(ctx, wasm, conf) 64 | if err != nil { 65 | log.Panicf("failed to instantiate WASM program: %v\n", err) 66 | } 67 | } 68 | 69 | func help() { 70 | println(` 71 | usage: ricket/run path [ args ... ] 72 | run 'man ricket' for more info. 73 | `) 74 | } 75 | -------------------------------------------------------------------------------- /ricket.troff: -------------------------------------------------------------------------------- 1 | .TH MAN 1 2 | .SH NAME 3 | 4 | ricket \- run and manage WASI programs 5 | 6 | .SH SYNOPSIS 7 | 8 | .PP 9 | .B ricket run 10 | .B path 11 | [ 12 | .BI args ... 13 | ] 14 | 15 | .PP 16 | .B ricket package 17 | [ 18 | .B -o 19 | .I output 20 | ] 21 | path 22 | 23 | 24 | .SH DESCRIPTION 25 | 26 | .PP 27 | .I ricket 28 | is a WASI runtime for Plan 9 from Bell Labs, which allows for running CLI 29 | applications written in languages that cannot natively compile to Plan 9. 30 | 31 | .PP 32 | .B ricket run 33 | will run the .wasm file at the path specified by 34 | .BR path . 35 | Any 36 | .B args 37 | will be passed into the program. 38 | 39 | .PP 40 | .B ricket/package 41 | will change the wasm file in 42 | .BR path . 43 | to make it act as an executable, assuming ricket is installed on the system. 44 | .B -o output 45 | is the optional output file path. 46 | 47 | .SH BUGS 48 | 49 | While not strictly a bug, 50 | .I ricket 51 | must interperet the WASM file, which can be slow as dirt. Perhaps JIT compilation will be availible in the future. 52 | -------------------------------------------------------------------------------- /test.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SlashScreen/ricket/abf622b2ac356cc642dacfe2294275f225fd1398/test.wasm --------------------------------------------------------------------------------