mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-11-10 00:43:15 -06:00
Compare commits
No commits in common. "c344266975ed2693cf462a09656baea143978a25" and "18091e6ded861ed60a269436a595b2aed9bac214" have entirely different histories.
c344266975
...
18091e6ded
14 changed files with 163 additions and 27 deletions
2
.github/workflows/update.yml
vendored
2
.github/workflows/update.yml
vendored
|
@ -130,7 +130,7 @@ jobs:
|
||||||
- run: |
|
- run: |
|
||||||
echo "# System Diff" >> $GITHUB_STEP_SUMMARY
|
echo "# System Diff" >> $GITHUB_STEP_SUMMARY
|
||||||
nix run "nixpkgs#nvd" -- --color always diff ./current ./updated >> summary.md
|
nix run "nixpkgs#nvd" -- --color always diff ./current ./updated >> summary.md
|
||||||
printf '```\n%s\n```\n' "$(nix run "nixpkgs#nvd" -- diff ./current ./updated)" >> $GITHUB_STEP_SUMMARY
|
printf '```\n%s```\n' "$(nix run "nixpkgs#nvd" -- diff ./current ./updated)" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
- run: df -h
|
- run: df -h
|
||||||
|
|
||||||
|
|
12
flake.lock
12
flake.lock
|
@ -744,11 +744,11 @@
|
||||||
"nixpkgs": "nixpkgs_6"
|
"nixpkgs": "nixpkgs_6"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726608298,
|
"lastModified": 1726604396,
|
||||||
"narHash": "sha256-jnkrX5WjYDRh6kYHHmf0mjOSiJNtrqDI/h2coistP7w=",
|
"narHash": "sha256-N96NVHAYUxK4L7uaeKi45a+v61VIpimzHyQsKctBpb4=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixpkgs-wayland",
|
"repo": "nixpkgs-wayland",
|
||||||
"rev": "0e4800bea63d6e60d1917c934ad7c5bba935d345",
|
"rev": "e2d0b0171ddf364b687d091ee603d0c3a7079166",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -1184,11 +1184,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726619268,
|
"lastModified": 1726575046,
|
||||||
"narHash": "sha256-YlVh/GZX/BA33RlkFRm3WZESFnVP0EXVLc/goXVYKVY=",
|
"narHash": "sha256-XD2qJ30wTLUz7BOXVz1wY/q+RJBvI7f6ksGJrYMbFAg=",
|
||||||
"owner": "mitchellh",
|
"owner": "mitchellh",
|
||||||
"repo": "zig-overlay",
|
"repo": "zig-overlay",
|
||||||
"rev": "04a63b5774dc3f9d5be373b03f4e461fe3b7d9d2",
|
"rev": "a2f15c93b689b31044d5604fb0cd5bac818daf01",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
"vt.default_blu=46,168,161,175,250,231,213,222,112,168,161,175,250,231,213,200"
|
"vt.default_blu=46,168,161,175,250,231,213,222,112,168,161,175,250,231,213,200"
|
||||||
];
|
];
|
||||||
|
|
||||||
boot.kernelPackages = pkgs.linuxPackages_latest;
|
boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_latest;
|
||||||
boot.tmp.cleanOnBoot = true;
|
boot.tmp.cleanOnBoot = true;
|
||||||
boot.loader = {
|
boot.loader = {
|
||||||
systemd-boot = enabled // {
|
systemd-boot = enabled // {
|
||||||
|
|
|
@ -8,5 +8,5 @@ buildNimblePackage {
|
||||||
verions = "unstable";
|
verions = "unstable";
|
||||||
src = lib.cleanSource ./.;
|
src = lib.cleanSource ./.;
|
||||||
nativeBuildInputs = [ openssl ];
|
nativeBuildInputs = [ openssl ];
|
||||||
nimbleDepsHash = "sha256-U44sZSUcus9minOs/Euy4h071eU9Cn83RnYb5jiKibo=";
|
nimbleDepsHash = "sha256-WeTbNoF+TuzWriqoHWk5DBVgBXtNBIBHMkwy8/+a2JA=";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
{
|
{
|
||||||
"version": 2,
|
"version": 2,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
"bbansi": {
|
||||||
|
"version": "0.1.1",
|
||||||
|
"vcsRevision": "9a85d9ed028f06f1ed1ee6851480a51408a6004e",
|
||||||
|
"url": "https://github.com/daylinmorgan/bbansi",
|
||||||
|
"downloadMethod": "git",
|
||||||
|
"dependencies": [],
|
||||||
|
"checksums": {
|
||||||
|
"sha1": "b338433f9a7a1b788b7583674c2b14096ced29ee"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cligen": {
|
"cligen": {
|
||||||
"version": "1.7.0",
|
"version": "1.7.0",
|
||||||
"vcsRevision": "4193f802796f15559c81c6dd56724d6f20345917",
|
"vcsRevision": "4193f802796f15559c81c6dd56724d6f20345917",
|
||||||
|
@ -11,16 +21,6 @@
|
||||||
"sha1": "300bd7fdb6e48d2d98e34ed0661206b50331e99c"
|
"sha1": "300bd7fdb6e48d2d98e34ed0661206b50331e99c"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"hwylterm": {
|
|
||||||
"version": "0.1.0",
|
|
||||||
"vcsRevision": "f743d4b2dc93e41d0e8b5bb0a3e5f26ffc2534e1",
|
|
||||||
"url": "https://github.com/daylinmorgan/hwylterm",
|
|
||||||
"downloadMethod": "git",
|
|
||||||
"dependencies": [],
|
|
||||||
"checksums": {
|
|
||||||
"sha1": "5a5e00533d5cf2660872738cabf8b7572128b05b"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"jsony": {
|
"jsony": {
|
||||||
"version": "1.1.5",
|
"version": "1.1.5",
|
||||||
"vcsRevision": "ea811bec7fa50f5abd3088ba94cda74285e93f18",
|
"vcsRevision": "ea811bec7fa50f5abd3088ba94cda74285e93f18",
|
||||||
|
|
|
@ -14,4 +14,4 @@ requires "nim >= 2.0.8"
|
||||||
requires "cligen"
|
requires "cligen"
|
||||||
requires "jsony"
|
requires "jsony"
|
||||||
requires "zippy"
|
requires "zippy"
|
||||||
requires "https://github.com/daylinmorgan/hwylterm#HEAD"
|
requires "https://github.com/daylinmorgan/bbansi#9a85d9e"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
## nix begat oizys
|
## nix begat oizys
|
||||||
import std/[os, tables, sequtils, strformat,strutils]
|
import std/[os, tables, sequtils, strformat,strutils]
|
||||||
|
|
||||||
import cligen, hwylterm
|
import cligen, bbansi
|
||||||
import oizys/[context, github, nix, overlay, logging]
|
import oizys/[context, github, nix, overlay, logging]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import std/[logging, os, strformat, strutils]
|
import std/[logging, os, strformat, strutils]
|
||||||
from std/nativesockets import getHostname
|
from std/nativesockets import getHostname
|
||||||
import hwylterm
|
import bbansi
|
||||||
import ./logging
|
import ./logging
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
@ -3,7 +3,7 @@ import std/[
|
||||||
strutils, streams, logging
|
strutils, streams, logging
|
||||||
]
|
]
|
||||||
|
|
||||||
import hwylterm
|
import ./spin
|
||||||
|
|
||||||
|
|
||||||
func addArgs*(cmd: var string, args: openArray[string]) =
|
func addArgs*(cmd: var string, args: openArray[string]) =
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import std/[httpclient,logging, os, strformat, strutils, json, tables, tempfiles]
|
import std/[httpclient,logging, os, strformat, strutils, json, tables, tempfiles]
|
||||||
import jsony, hwylterm, zippy/ziparchives
|
import jsony, bbansi, zippy/ziparchives
|
||||||
import ./[logging, exec, context]
|
import ./[logging, exec, context]
|
||||||
|
|
||||||
# localPassC is used by zippy but the additional
|
# localPassC is used by zippy but the additional
|
||||||
|
|
|
@ -22,4 +22,3 @@ code
|
||||||
direnv
|
direnv
|
||||||
comma-with-db
|
comma-with-db
|
||||||
nix-index-with-db
|
nix-index-with-db
|
||||||
python
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import std/[logging,strutils]
|
import std/[logging,strutils]
|
||||||
export logging
|
export logging
|
||||||
|
|
||||||
import hwylterm
|
import bbansi
|
||||||
|
|
||||||
var
|
var
|
||||||
handlers {.threadvar.}: seq[Logger]
|
handlers {.threadvar.}: seq[Logger]
|
||||||
|
|
|
@ -3,7 +3,7 @@ import std/[
|
||||||
enumerate, os, sequtils, strformat,
|
enumerate, os, sequtils, strformat,
|
||||||
strutils, sugar, logging, tables
|
strutils, sugar, logging, tables
|
||||||
]
|
]
|
||||||
import hwylterm, jsony
|
import bbansi, jsony
|
||||||
import ./[context, exec, logging]
|
import ./[context, exec, logging]
|
||||||
|
|
||||||
|
|
||||||
|
|
137
pkgs/oizys-nim/src/oizys/spin.nim
Normal file
137
pkgs/oizys-nim/src/oizys/spin.nim
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
import std/[os, locks, sequtils, terminal]
|
||||||
|
|
||||||
|
import bbansi
|
||||||
|
|
||||||
|
type
|
||||||
|
SpinnerKind* = enum
|
||||||
|
Dots
|
||||||
|
Spinner* = object
|
||||||
|
interval*: int
|
||||||
|
frames*: seq[string]
|
||||||
|
|
||||||
|
proc makeSpinner*(interval: int, frames: seq[string]): Spinner =
|
||||||
|
Spinner(interval: interval, frames: frames)
|
||||||
|
|
||||||
|
const Spinners*: array[SpinnerKind, Spinner] = [
|
||||||
|
# Dots
|
||||||
|
Spinner(interval: 80, frames: @["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"]),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
Spinny = ref object
|
||||||
|
t: Thread[Spinny]
|
||||||
|
lock: Lock
|
||||||
|
text: string
|
||||||
|
running: bool
|
||||||
|
frames: seq[string]
|
||||||
|
frame: string
|
||||||
|
interval: int
|
||||||
|
customSymbol: bool
|
||||||
|
style: string
|
||||||
|
|
||||||
|
EventKind = enum
|
||||||
|
Stop, SymbolChange, TextChange,
|
||||||
|
|
||||||
|
SpinnyEvent = object
|
||||||
|
kind: EventKind
|
||||||
|
payload: string
|
||||||
|
|
||||||
|
var spinnyChannel: Channel[SpinnyEvent]
|
||||||
|
|
||||||
|
proc newSpinny*(text: string, s: Spinner): Spinny =
|
||||||
|
let style = "bold blue"
|
||||||
|
Spinny(
|
||||||
|
text: text,
|
||||||
|
running: true,
|
||||||
|
frames: mapIt(s.frames, $bb(it, style)),
|
||||||
|
customSymbol: false,
|
||||||
|
interval: s.interval,
|
||||||
|
style: "bold blue"
|
||||||
|
)
|
||||||
|
|
||||||
|
proc newSpinny*(text: string, spinType: SpinnerKind): Spinny =
|
||||||
|
newSpinny(text, Spinners[spinType])
|
||||||
|
|
||||||
|
proc setSymbolColor*(spinny: Spinny, style: string) =
|
||||||
|
spinny.frames = mapIt(spinny.frames, $bb(it, style))
|
||||||
|
|
||||||
|
proc setSymbol*(spinny: Spinny, symbol: string) =
|
||||||
|
spinnyChannel.send(SpinnyEvent(kind: SymbolChange, payload: symbol))
|
||||||
|
|
||||||
|
proc setText*(spinny: Spinny, text: string) =
|
||||||
|
spinnyChannel.send(SpinnyEvent(kind: TextChange, payload: text))
|
||||||
|
|
||||||
|
proc handleEvent(spinny: Spinny, eventData: SpinnyEvent): bool =
|
||||||
|
result = true
|
||||||
|
case eventData.kind
|
||||||
|
of Stop:
|
||||||
|
result = false
|
||||||
|
of SymbolChange:
|
||||||
|
spinny.customSymbol = true
|
||||||
|
spinny.frame = eventData.payload
|
||||||
|
of TextChange:
|
||||||
|
spinny.text = eventData.payload
|
||||||
|
|
||||||
|
proc spinnyLoop(spinny: Spinny) {.thread.} =
|
||||||
|
var frameCounter = 0
|
||||||
|
|
||||||
|
while spinny.running:
|
||||||
|
let data = spinnyChannel.tryRecv()
|
||||||
|
if data.dataAvailable:
|
||||||
|
# If we received a Stop event
|
||||||
|
if not spinny.handleEvent(data.msg):
|
||||||
|
spinnyChannel.close()
|
||||||
|
# This is required so we can reopen the same channel more than once
|
||||||
|
# See https://github.com/nim-lang/Nim/issues/6369
|
||||||
|
spinnyChannel = default(typeof(spinnyChannel))
|
||||||
|
# TODO: Do we need spinny.running at all?
|
||||||
|
spinny.running = false
|
||||||
|
break
|
||||||
|
|
||||||
|
stdout.flushFile()
|
||||||
|
if not spinny.customSymbol:
|
||||||
|
spinny.frame = spinny.frames[frameCounter]
|
||||||
|
|
||||||
|
withLock spinny.lock:
|
||||||
|
eraseLine()
|
||||||
|
stdout.write(spinny.frame & " " & spinny.text)
|
||||||
|
stdout.flushFile()
|
||||||
|
|
||||||
|
sleep spinny.interval
|
||||||
|
|
||||||
|
if frameCounter >= spinny.frames.len - 1:
|
||||||
|
frameCounter = 0
|
||||||
|
else:
|
||||||
|
frameCounter += 1
|
||||||
|
|
||||||
|
proc start*(spinny: Spinny) =
|
||||||
|
initLock spinny.lock
|
||||||
|
spinnyChannel.open()
|
||||||
|
createThread(spinny.t, spinnyLoop, spinny)
|
||||||
|
|
||||||
|
proc stop(spinny: Spinny, kind: EventKind, payload = "") =
|
||||||
|
spinnyChannel.send(SpinnyEvent(kind: kind, payload: payload))
|
||||||
|
spinnyChannel.send(SpinnyEvent(kind: Stop))
|
||||||
|
joinThread spinny.t
|
||||||
|
eraseLine stdout
|
||||||
|
flushFile stdout
|
||||||
|
|
||||||
|
|
||||||
|
proc stop*(spinny: Spinny) =
|
||||||
|
spinny.stop(Stop)
|
||||||
|
|
||||||
|
template withSpinner*(msg: string = "", body: untyped): untyped =
|
||||||
|
var spinner {.inject.} = newSpinny(msg, Dots)
|
||||||
|
if isatty(stdout): # don't spin if it's not a tty
|
||||||
|
start spinner
|
||||||
|
|
||||||
|
body
|
||||||
|
|
||||||
|
if isatty(stdout):
|
||||||
|
stop spinner
|
||||||
|
|
||||||
|
template withSpinner*(body: untyped): untyped =
|
||||||
|
withSpinner("", body)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue