main: work in progress [might break]

This commit is contained in:
Leon van Kammen 2024-09-16 11:25:26 +00:00
parent 8fcc48dcff
commit 2f3fdf73ff
9 changed files with 210 additions and 2 deletions

View File

@ -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'; alias nano='echo "HINT: type Ctrl+x to quit" ;read;nano';
# start index.js # 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 # start index.html
test -f index.html && chmod +x index.html && ./index.html test -f index.html && chmod +x index.html && ./index.html

View File

@ -0,0 +1,3 @@
#!/bin/sh
cat lib/aframe/codemirror.js > /dev/browser/js
echo '<a-entity codemirror></a-entity>' >> /dev/browser/html

View File

@ -1 +0,0 @@
bar

View File

@ -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) => `<div class="codemirror">
</div>`,
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 <type> [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.
`
}
});

23
nix/chibicc.nix Normal file
View File

@ -0,0 +1,23 @@
{ pkgs ? import <nixpkgs> {} }:
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
'';
}

43
nix/configuration.nix Normal file
View File

@ -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;
}

12
nix/cross.nix Normal file
View File

@ -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 ];
}) {}

7
nix/hello.c Normal file
View File

@ -0,0 +1,7 @@
#include <stdio.h>
int main (void)
{
printf ("Hello, world!\n");
return 0;
}

1
nix/run.sh Executable file
View File

@ -0,0 +1 @@
nix-shell -p qemu --run 'qemu-system-i386 -cdrom dist/v86-linux.iso'