diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/.profile b/buildroot-v86/board/v86/rootfs_overlay/root/.profile index 29c1b9e..99aece8 100644 --- a/buildroot-v86/board/v86/rootfs_overlay/root/.profile +++ b/buildroot-v86/board/v86/rootfs_overlay/root/.profile @@ -9,7 +9,7 @@ alias mg='echo "HINT: type Ctrl+c Ctrl-x to quit";read;me'; alias nano='echo "HINT: type Ctrl+x to quit" ;read;nano'; # start index.js -test -f index.js && chmod +x index.js && ./index.js +test -f index.js && chmod +x index.js && ./index.js | grep -v undefined # start index.html test -f index.html && chmod +x index.html && ./index.html diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/bin/codemirror b/buildroot-v86/board/v86/rootfs_overlay/root/bin/codemirror new file mode 100755 index 0000000..baa6d76 --- /dev/null +++ b/buildroot-v86/board/v86/rootfs_overlay/root/bin/codemirror @@ -0,0 +1,3 @@ +#!/bin/sh +cat lib/aframe/codemirror.js > /dev/browser/js +echo '' >> /dev/browser/html diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/foo b/buildroot-v86/board/v86/rootfs_overlay/root/foo deleted file mode 100644 index 5716ca5..0000000 --- a/buildroot-v86/board/v86/rootfs_overlay/root/foo +++ /dev/null @@ -1 +0,0 @@ -bar diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/lib/aframe/codemirror.js b/buildroot-v86/board/v86/rootfs_overlay/root/lib/aframe/codemirror.js new file mode 100644 index 0000000..d801b30 --- /dev/null +++ b/buildroot-v86/board/v86/rootfs_overlay/root/lib/aframe/codemirror.js @@ -0,0 +1,120 @@ +if( AFRAME.components.codemirror ) delete AFRAME.components.codemirror + +AFRAME.registerComponent('codemirror', { + schema: { + foo: { type:"string"} + }, + + init: function () { + this.el.object3D.visible = false + //this.el.innerHTML = ` ` + this.requireAll() + }, + + requireAll: async function(){ + let s = await AFRAME.utils.require(this.requires) + setTimeout( () => this.el.setAttribute("dom",""), 300 ) + }, + + requires:{ + window: "com/window.js", + codemirror: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.1/codemirror.js", + codemirrorcss: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/codemirror.css", + cmtheme: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/theme/shadowfox.css" + }, + + dom: { + scale: 0.5, + events: ['click','keydown'], + html: (me) => `
+
`, + + css: (me) => `.codemirror{ + width:100%; + } + .wb-body + .codemirror{ overflow:hidden; } + .CodeMirror { + margin-top:18px; + } + .cm-s-shadowfox.CodeMirror { + background:transparent !important; + } + ` + }, + + events:{ + + // component events + DOMready: function(e){ + console.log(`title: codemirror; uid: ${this.el.dom.id}; attach: #overlay; dom: #${this.el.dom.id};`) + this.el.setAttribute("window", `title: codemirror; uid: ${this.el.dom.id}; attach: #overlay; dom: #${this.el.dom.id};`) + this.editor = CodeMirror( this.el.dom, { + value: "function myScript(){return 100;}\n", + mode: "javascript", + lineNumbers: true, + styleActiveLine: true, + matchBrackets: true, + Tab: "indentMore", + defaultTab: function(cm) { + if (cm.somethingSelected()) cm.indentSelection("add"); + else cm.replaceSelection(" ", "end"); + } + }) + this.editor.setOption("theme", "shadowfox") + }, + }, + + + manifest: { // HTML5 manifest to identify app to xrsh + "short_name": "Paste", + "name": "Paste", + "icons": [ + { + "src": "https://css.gg/clipboard.svg", + "type": "image/svg+xml", + "sizes": "512x512" + } + ], + "id": "/?source=pwa", + "start_url": "/?source=pwa", + "background_color": "#3367D6", + "display": "standalone", + "scope": "/", + "theme_color": "#3367D6", + "shortcuts": [ + { + "name": "What is the latest news?", + "cli":{ + "usage": "helloworld [options]", + "example": "helloworld news", + "args":{ + "--latest": {type:"string"} + } + }, + "short_name": "Today", + "description": "View weather information for today", + "url": "/today?source=pwa", + "icons": [{ "src": "/images/today.png", "sizes": "192x192" }] + } + ], + "description": "Paste the clipboard", + "screenshots": [ + { + "src": "/images/screenshot1.png", + "type": "image/png", + "sizes": "540x720", + "form_factor": "narrow" + } + ], + "help":` +Helloworld application + +This is a help file which describes the application. +It will be rendered thru troika text, and will contain +headers based on non-punctualized lines separated by linebreaks, +in above's case "\nHelloworld application\n" will qualify as header. + ` + } + +}); + diff --git a/nix/chibicc.nix b/nix/chibicc.nix new file mode 100644 index 0000000..dc0c5fe --- /dev/null +++ b/nix/chibicc.nix @@ -0,0 +1,23 @@ +{ pkgs ? import {} }: + +pkgs.mkShell { + buildInputs = [ + pkgs.pkg-config + pkgs.gnumake # For running make + pkgs.gcc_multi # GCC with multi-lib support (32-bit and 64-bit) + pkgs.glibc_multi + pkgs.gccMultiStdenv + pkgs.binutils + ]; + + # Set up environment variables for cross-compilation to 32-bit + shellHook = '' + export CC="gcc -m32 -static" + export CXX="g++ -m32 -static" + export LD="ld -m elf_i386" + echo "32-bit cross-compilation environment with static linking is set up." + git clone https://github.com/rui314/chibicc + cd chibicc + make + ''; +} diff --git a/nix/configuration.nix b/nix/configuration.nix new file mode 100644 index 0000000..c57b5ff --- /dev/null +++ b/nix/configuration.nix @@ -0,0 +1,43 @@ +# /etc/nixos/configuration.nix +{ config, pkgs, ... }: + +{ + # Set the hostname of the system + networking.hostName = "nixos-minimal"; + + # Enable the OpenSSH service (optional, useful for remote access) + services.openssh.enable = false; + + # Timezone configuration + time.timeZone = "UTC"; + + # Set the default shell to bash + users.defaultUserShell = pkgs.bash; + + # Create a minimal user (replace "your-user" with desired username) + users.users.yourUser = { + isNormalUser = true; + shell = pkgs.bash; + initialPassword = "password"; # Replace with a hashed password for production + }; + + # Boot loader (for booting the system) + boot.loader.grub.enable = true; + boot.loader.grub.version = 2; + boot.loader.grub.devices = [ "/dev/sda" ]; # Replace with your actual boot device + + # Allow unfree packages (if needed) + nixpkgs.config.allowUnfree = true; + + # Enable virtual console + console.useXkbConfig = true; + + # Enable bash as a package (part of the basic system environment) + environment.systemPackages = with pkgs; [ + bash + ]; + + # Disable the display manager (minimal CLI system, no graphical interface) + services.xserver.enable = false; +} + diff --git a/nix/cross.nix b/nix/cross.nix new file mode 100644 index 0000000..46cf107 --- /dev/null +++ b/nix/cross.nix @@ -0,0 +1,12 @@ +let + nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/release-24.05"; + pkgs = (import nixpkgs {}).pkgsCross.i686-embedded; +in + +# callPackage is needed due to https://github.com/NixOS/nixpkgs/pull/126844 +pkgs.pkgsStatic.callPackage ({ mkShell, zlib, pkg-config, file }: mkShell { + # these tools run on the build platform, but are configured to target the host platform + nativeBuildInputs = [ pkg-config file ]; + # libraries needed for the host platform + buildInputs = [ zlib ]; +}) {} diff --git a/nix/hello.c b/nix/hello.c new file mode 100644 index 0000000..b19d80e --- /dev/null +++ b/nix/hello.c @@ -0,0 +1,7 @@ +#include + +int main (void) +{ + printf ("Hello, world!\n"); + return 0; +} diff --git a/nix/run.sh b/nix/run.sh new file mode 100755 index 0000000..a155ecb --- /dev/null +++ b/nix/run.sh @@ -0,0 +1 @@ +nix-shell -p qemu --run 'qemu-system-i386 -cdrom dist/v86-linux.iso'