forked from Projects/qotd
Compare commits
3 Commits
remove-git
...
add-vm
| Author | SHA1 | Date | |
|---|---|---|---|
|
77998b3ef5
|
|||
|
d15e8e5cf9
|
|||
|
3a1dcee2db
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
*.uasm
|
*.uasm
|
||||||
result
|
result
|
||||||
|
*.qcow2
|
||||||
|
|||||||
21
README.md
21
README.md
@@ -1,6 +1,23 @@
|
|||||||
this is wip
|
# QOTD daemon
|
||||||
|
|
||||||
the idea was to create a uiua program that serves the [qotd port
|
> [! CAUTION]
|
||||||
|
> This is WIP
|
||||||
|
|
||||||
|
The idea was to create a uiua program that serves the [qotd port
|
||||||
17](https://en.wikipedia.org/wiki/QOTD) then host it on one of pvv's machines.
|
17](https://en.wikipedia.org/wiki/QOTD) then host it on one of pvv's machines.
|
||||||
this to learn about socket programming in uiua, and to show some love to the
|
this to learn about socket programming in uiua, and to show some love to the
|
||||||
oft-forgotten port 17.
|
oft-forgotten port 17.
|
||||||
|
|
||||||
|
## Building and running
|
||||||
|
|
||||||
|
**Build:**
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ nix build
|
||||||
|
```
|
||||||
|
|
||||||
|
**Run in VM:**
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ nix run .#vm
|
||||||
|
```
|
||||||
|
|||||||
74
flake.nix
74
flake.nix
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
outputs = { self, nixpkgs }:
|
outputs = { self, nixpkgs }:
|
||||||
let
|
let
|
||||||
inherit (nixpkgs) lib;
|
inherit (nixpkgs) lib;
|
||||||
|
|
||||||
@@ -16,6 +16,19 @@
|
|||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
in f system pkgs);
|
in f system pkgs);
|
||||||
in {
|
in {
|
||||||
|
apps = forAllSystems (
|
||||||
|
system: pkgs: {
|
||||||
|
default = {
|
||||||
|
type = "app";
|
||||||
|
program = "${lib.getExe self.packages.${system}.default}";
|
||||||
|
};
|
||||||
|
vm = {
|
||||||
|
type = "app";
|
||||||
|
program = "${self.nixosConfigurations.vm.config.system.build.vm}/bin/run-nixos-vm";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
devShells = forAllSystems (system: pkgs: {
|
devShells = forAllSystems (system: pkgs: {
|
||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
@@ -33,5 +46,64 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
nixosModules.default = ./nix/module.nix;
|
nixosModules.default = ./nix/module.nix;
|
||||||
|
|
||||||
|
nixosConfigurations.vm = nixpkgs.lib.nixosSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
overlays = [
|
||||||
|
self.overlays.default
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
modules = [
|
||||||
|
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
|
||||||
|
self.nixosModules.default
|
||||||
|
({ config, pkgs, ... }: {
|
||||||
|
system.stateVersion = config.system.nixos.release;
|
||||||
|
virtualisation.graphics = false;
|
||||||
|
users.extraUsers.root.password = "root";
|
||||||
|
services.getty.autologinUser = "root";
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
netcat
|
||||||
|
];
|
||||||
|
|
||||||
|
users.motd = ''
|
||||||
|
=======================
|
||||||
|
|
||||||
|
Welcome to the qotd vm!
|
||||||
|
|
||||||
|
Try running:
|
||||||
|
|
||||||
|
nc localhost 17
|
||||||
|
|
||||||
|
=======================
|
||||||
|
'';
|
||||||
|
|
||||||
|
services.qotd = {
|
||||||
|
enable = true;
|
||||||
|
quotes = [
|
||||||
|
''
|
||||||
|
"rm -rf /"
|
||||||
|
|
||||||
|
- felixalb on bekkalokk, 2026 (probably)
|
||||||
|
''
|
||||||
|
''
|
||||||
|
( U I U A )
|
||||||
|
汎用配列指向プログラミング言語
|
||||||
|
|
||||||
|
- frero, 2025
|
||||||
|
''
|
||||||
|
''
|
||||||
|
bwaaa :3
|
||||||
|
|
||||||
|
- oysteikt on gitea, 2024
|
||||||
|
''
|
||||||
|
];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
47
main.uasm
Normal file
47
main.uasm
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
"quotes"
|
||||||
|
["f_read_all_str",1]
|
||||||
|
"\n\n---\n\n"
|
||||||
|
["SPLIT_BY",[[1,1,["BOX",6]]],5]
|
||||||
|
[["DUP",11],["LEN",7],["RAND",8],["MUL",9],["FLOOR",10]]
|
||||||
|
["PICK",12]
|
||||||
|
["UN_BOX",13]
|
||||||
|
{"bind_global":[0,15]}
|
||||||
|
"127.0.0.1:10017"
|
||||||
|
["tcp_listen",16]
|
||||||
|
"listening on localhost:10017"
|
||||||
|
["print",17]
|
||||||
|
["DO",[[1,1,[["DUP",19],["tcp_accept",20],{"copy_to_under":[1,20]},{"call_global":[0,[0,1]]},["write",21],{"pop_under":[1,20]},["close",20]]],[0,1,[[],[1],{"flags":"SORTED_UP | SORTED_DOWN"}]]],18]
|
||||||
|
["close",23]
|
||||||
|
|
||||||
|
BINDINGS
|
||||||
|
const null
|
||||||
|
|
||||||
|
FUNCTIONS
|
||||||
|
|
||||||
|
SPANS
|
||||||
|
"main.ua" [3,1,13,13] [3,6,18,18]
|
||||||
|
"main.ua" [4,19,53,46] [4,20,54,47]
|
||||||
|
"main.ua" [4,5,37,32] [4,6,40,33]
|
||||||
|
"main.ua" [4,3,34,30] [4,4,36,31]
|
||||||
|
"main.ua" [4,1,28,28] [4,2,31,29]
|
||||||
|
"main.ua" [4,2,31,29] [4,3,34,30]
|
||||||
|
"main.ua" [5,9,75,56] [5,10,78,57]
|
||||||
|
"main.ua" [5,8,72,55] [5,9,75,56]
|
||||||
|
"main.ua" [5,7,70,54] [5,8,72,55]
|
||||||
|
"main.ua" [5,6,67,53] [5,7,70,54]
|
||||||
|
"main.ua" [5,4,63,51] [5,5,66,52]
|
||||||
|
"main.ua" [5,3,60,50] [5,4,63,51]
|
||||||
|
"main.ua" [5,2,57,49] [5,3,60,50]
|
||||||
|
"main.ua" [5,1,55,48] [5,2,57,49]
|
||||||
|
"main.ua" [6,1,80,59] [6,2,81,60]
|
||||||
|
"main.ua" [10,1,123,100] [10,6,128,105]
|
||||||
|
"main.ua" [11,1,147,124] [11,3,149,126]
|
||||||
|
"main.ua" [12,1,181,158] [12,2,184,159]
|
||||||
|
"main.ua" [13,15,202,175] [13,16,203,176]
|
||||||
|
"main.ua" [13,4,191,164] [13,9,196,169]
|
||||||
|
"main.ua" [13,10,197,170] [13,12,199,172]
|
||||||
|
"main.ua" [13,3,188,163] [13,4,191,164]
|
||||||
|
"main.ua" [15,1,207,180] [15,4,210,183]
|
||||||
|
|
||||||
|
FILES
|
||||||
|
main.ua: "# find qotd\n\n&fras \"quotes\"\n⊜□¬ ⦷\"\\n\\n---\\n\\n\".\n°□⊡⊸(⌊×⚂⧻)\nq ←\n\n# continuously wait for connection\n\n&tcpl \"127.0.0.1:10017\"\n&p \"listening on localhost:10017\"\n⍢(\n ⍜&tcpa(&w q).\n)1\n&cl\n"
|
||||||
@@ -51,4 +51,6 @@ stdenvNoCC.mkDerivation {
|
|||||||
install -Dm555 "$wrapperPath" "$out"/bin/qotd
|
install -Dm555 "$wrapperPath" "$out"/bin/qotd
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
meta.mainProgram = "qotd";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user