mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 06:00:45 -06:00
Compare commits
No commits in common. "a459ea2ad154d68ca70eeaca44bdd7a08e81d1c5" and "a287bee602add29ee0006c3832d81ba47acb4ed3" have entirely different histories.
a459ea2ad1
...
a287bee602
8 changed files with 168 additions and 42 deletions
54
flake.lock
54
flake.lock
|
@ -357,11 +357,11 @@
|
||||||
"xdph": "xdph"
|
"xdph": "xdph"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727714556,
|
"lastModified": 1727679999,
|
||||||
"narHash": "sha256-l4cPDA3xGtGdQmdSCAO2VyWg9xwW6//KwDYefdWtovQ=",
|
"narHash": "sha256-NWF3SKLMFjM0M93PDWM9+wKbc5XcnJEmojiZdNdPpUw=",
|
||||||
"ref": "refs/heads/main",
|
"ref": "refs/heads/main",
|
||||||
"rev": "5c6c300abfea2539ffad9bcbf857325eec5ab765",
|
"rev": "f6387536f62454f82039b42f641cd8c44153ad47",
|
||||||
"revCount": 5285,
|
"revCount": 5281,
|
||||||
"submodules": true,
|
"submodules": true,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/hyprwm/Hyprland/"
|
"url": "https://github.com/hyprwm/Hyprland/"
|
||||||
|
@ -547,11 +547,11 @@
|
||||||
"nixpkgs-lib": "nixpkgs-lib_2"
|
"nixpkgs-lib": "nixpkgs-lib_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727710043,
|
"lastModified": 1727611937,
|
||||||
"narHash": "sha256-NpTnTg8oOVvntlTi/t8BUe5msrMmkiZFiOW22fc7B+g=",
|
"narHash": "sha256-VTtaGRJGFWQzQd7u7iHUJiUUyMbJ3Jcv/ZsXlBXw0Ok=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "lib-aggregate",
|
"repo": "lib-aggregate",
|
||||||
"rev": "d03a5f88a345d26ca13918071d42dcc960233183",
|
"rev": "74c775886c8f89a0af4743a9144c5bbd04125725",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -563,11 +563,11 @@
|
||||||
"lix": {
|
"lix": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727783747,
|
"lastModified": 1727623796,
|
||||||
"narHash": "sha256-fLiDo55WLgikMaaZcFEpkCkL4fQiV7RNEjRn+LxiYao=",
|
"narHash": "sha256-IsdPqCIc7eZwU9I1mO2huN0t1wUxgDKgmV4UeLv3elA=",
|
||||||
"rev": "775292766025380d04004e42fefbdb8ca40b3fa3",
|
"rev": "aa33c34c9be074c9452976aa96d71091325c83ea",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/775292766025380d04004e42fefbdb8ca40b3fa3.tar.gz?rev=775292766025380d04004e42fefbdb8ca40b3fa3"
|
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/aa33c34c9be074c9452976aa96d71091325c83ea.tar.gz?rev=aa33c34c9be074c9452976aa96d71091325c83ea"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
|
@ -586,11 +586,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727752861,
|
"lastModified": 1726631249,
|
||||||
"narHash": "sha256-jowmo2aEzrEpPSM96IWtajuogdJm7DjAWxFTEb7Ct0s=",
|
"narHash": "sha256-b2rMO8+jKjY55d8uynX7FjV4NIPu/WzPux0kWOAzwoo=",
|
||||||
"rev": "fd186f535a4ac7ae35d98c1dd5d79f0a81b7976d",
|
"rev": "b0e6f359500d66670cc16f521e4f62d6a0a4864e",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/fd186f535a4ac7ae35d98c1dd5d79f0a81b7976d.tar.gz?rev=fd186f535a4ac7ae35d98c1dd5d79f0a81b7976d"
|
"url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/b0e6f359500d66670cc16f521e4f62d6a0a4864e.tar.gz?rev=b0e6f359500d66670cc16f521e4f62d6a0a4864e"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
|
@ -845,11 +845,11 @@
|
||||||
"nixpkgs": "nixpkgs_6"
|
"nixpkgs": "nixpkgs_6"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727710797,
|
"lastModified": 1727614831,
|
||||||
"narHash": "sha256-2Xr8tAZoLrMkvD0Sil6053x2Lbsy8cvmlk8sApSWdD0=",
|
"narHash": "sha256-ffvX/qhMqol1E7Rv+oRSVXxYgYvKy5bfZAyjYdq/9RI=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixpkgs-wayland",
|
"repo": "nixpkgs-wayland",
|
||||||
"rev": "50e4446e6dce9e1e52455f5b87bb91e83a538468",
|
"rev": "206b2a2a8505b9e8afb5d1b5ffea2b574b7983b6",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -892,11 +892,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_4": {
|
"nixpkgs_4": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727634051,
|
"lastModified": 1727348695,
|
||||||
"narHash": "sha256-S5kVU7U82LfpEukbn/ihcyNt2+EvG7Z5unsKW9H/yFA=",
|
"narHash": "sha256-J+PeFKSDV+pHL7ukkfpVzCOO7mBSrrpJ3svwBFABbhI=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "06cf0e1da4208d3766d898b7fdab6513366d45b9",
|
"rev": "1925c603f17fc89f4c8f6bf6f631a802ad85d784",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -1001,11 +1001,11 @@
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727785014,
|
"lastModified": 1727705464,
|
||||||
"narHash": "sha256-u9R0Atlcy1Y+r63zk66rjOwMij30ZLwoo6l1k7+OI08=",
|
"narHash": "sha256-AN+lqsNz64FXmi1bXwR4zj2Yl0j6ktGHQeE3VJsE1Ic=",
|
||||||
"owner": "roc-lang",
|
"owner": "roc-lang",
|
||||||
"repo": "roc",
|
"repo": "roc",
|
||||||
"rev": "aaeefc09b60313a28597372d3fdec041c1b96a22",
|
"rev": "775bce294b732dbdbeefed6d8d94516f13422210",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -1231,11 +1231,11 @@
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "nix",
|
"dir": "nix",
|
||||||
"lastModified": 1727738646,
|
"lastModified": 1727369985,
|
||||||
"narHash": "sha256-OlKbUvhtdgMBW/BvmA7TSAzbvR2AD+tGo9oaEXoS2MY=",
|
"narHash": "sha256-ywfXk25Z0dYDzxa+wlwcPlBIS+XusuQhZKcKdWsP+bw=",
|
||||||
"owner": "daylinmorgan",
|
"owner": "daylinmorgan",
|
||||||
"repo": "tsm",
|
"repo": "tsm",
|
||||||
"rev": "07dd5a5238e0ddc67b24772be7b1f742693b4535",
|
"rev": "bd94042d38826754e9ac8e35b15d22c64121039a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -8,5 +8,5 @@ buildNimblePackage {
|
||||||
verions = "unstable";
|
verions = "unstable";
|
||||||
src = lib.cleanSource ./.;
|
src = lib.cleanSource ./.;
|
||||||
nativeBuildInputs = [ openssl ];
|
nativeBuildInputs = [ openssl ];
|
||||||
nimbleDepsHash = "sha256-3p+PdGkQmKwz5tzJwX0aun3kSOLw/lwzqRkR9+6ECQE=";
|
nimbleDepsHash = "sha256-A2sQy4x+QyqltV7B1rRh7uRPvv7pDtVNOXZZl5LrHCY=";
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,23 +2,23 @@
|
||||||
"version": 2,
|
"version": 2,
|
||||||
"packages": {
|
"packages": {
|
||||||
"cligen": {
|
"cligen": {
|
||||||
"version": "1.7.6",
|
"version": "1.7.0",
|
||||||
"vcsRevision": "54f1da5d63cf7e116625e2392e85ae54c2b70719",
|
"vcsRevision": "4193f802796f15559c81c6dd56724d6f20345917",
|
||||||
"url": "https://github.com/c-blake/cligen.git",
|
"url": "https://github.com/c-blake/cligen.git",
|
||||||
"downloadMethod": "git",
|
"downloadMethod": "git",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"checksums": {
|
"checksums": {
|
||||||
"sha1": "853785ddace4ee4f3c6c21bdf7f5e9ff0358eb3f"
|
"sha1": "300bd7fdb6e48d2d98e34ed0661206b50331e99c"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"hwylterm": {
|
"hwylterm": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"vcsRevision": "d852761831bd748db24b42f15bc8e2d286232295",
|
"vcsRevision": "c2bcfd1f73dda97bd3e209c89e2abfe588f0977c",
|
||||||
"url": "https://github.com/daylinmorgan/hwylterm",
|
"url": "https://github.com/daylinmorgan/hwylterm",
|
||||||
"downloadMethod": "git",
|
"downloadMethod": "git",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"checksums": {
|
"checksums": {
|
||||||
"sha1": "7de2a93a03bd0659d8d70cc7c08315e0a7f15439"
|
"sha1": "1932229840c893c39acca0b50def19913678f5f0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"jsony": {
|
"jsony": {
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
## nix begat oizys
|
## nix begat oizys
|
||||||
import std/[os, tables, sequtils, strformat, strutils]
|
import std/[os, tables, sequtils, strformat,strutils]
|
||||||
import hwylterm, hwylterm/[cligen, logging]
|
|
||||||
import oizys/[context, github, nix, overlay]# 3, logging
|
import hwylterm
|
||||||
|
import hwylterm/cli
|
||||||
|
import oizys/[context, github, nix, overlay, logging]
|
||||||
|
|
||||||
addHandler(
|
addHandler(
|
||||||
newFancyConsoleLogger(
|
newFancyConsoleLogger(
|
||||||
levelThreshold = lvlAll,
|
levelThreshold=lvlAll,
|
||||||
|
useStderr = true,
|
||||||
fmtPrefix = $bb"[b magenta]oizys"
|
fmtPrefix = $bb"[b magenta]oizys"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import std/[logging, os, strformat, strutils]
|
import std/[logging, os, strformat, strutils]
|
||||||
from std/nativesockets import getHostname
|
from std/nativesockets import getHostname
|
||||||
import hwylterm, hwylterm/logging
|
import hwylterm
|
||||||
|
import ./logging
|
||||||
|
|
||||||
type
|
type
|
||||||
OizysContext* = object
|
OizysContext* = object
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import std/[httpclient,logging, os, strformat, strutils, json, tables, tempfiles]
|
import std/[httpclient,logging, os, strformat, strutils, json, tables, tempfiles]
|
||||||
import jsony, hwylterm, hwylterm/logging, zippy/ziparchives
|
import jsony, hwylterm, zippy/ziparchives
|
||||||
import ./[exec, context]
|
import ./[logging, exec, context]
|
||||||
|
|
||||||
# localPassC is used by zippy but the additional
|
# localPassC is used by zippy but the additional
|
||||||
# module mangling on nixos somehow breaks localPassC
|
# module mangling on nixos somehow breaks localPassC
|
||||||
|
|
117
pkgs/oizys-nim/src/oizys/logging.nim
Normal file
117
pkgs/oizys-nim/src/oizys/logging.nim
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
import std/[logging,strutils]
|
||||||
|
export logging
|
||||||
|
|
||||||
|
import hwylterm
|
||||||
|
|
||||||
|
var
|
||||||
|
handlers {.threadvar.}: seq[Logger]
|
||||||
|
|
||||||
|
#[
|
||||||
|
Level* = enum ## \
|
||||||
|
lvlAll, ## All levels active
|
||||||
|
lvlDebug, ## Debug level and above are active
|
||||||
|
lvlInfo, ## Info level and above are active
|
||||||
|
lvlNotice, ## Notice level and above are active
|
||||||
|
lvlWarn, ## Warn level and above are active
|
||||||
|
lvlError, ## Error level and above are active
|
||||||
|
lvlFatal, ## Fatal level and above are active
|
||||||
|
lvlNone ## No levels active; nothing is logged
|
||||||
|
]#
|
||||||
|
|
||||||
|
type
|
||||||
|
FancyConsoleLogger* = ref object of Logger
|
||||||
|
## A logger that writes log messages to the console.
|
||||||
|
##
|
||||||
|
## Create a new ``FancyConsoleLogger`` with the `newFancyConsoleLogger proc
|
||||||
|
## <#newConsoleLogger>`_.
|
||||||
|
##
|
||||||
|
useStderr*: bool ## If true, writes to stderr; otherwise, writes to stdout
|
||||||
|
flushThreshold*: Level ## Only messages that are at or above this
|
||||||
|
## threshold will be flushed immediately
|
||||||
|
fmtPrefix: string
|
||||||
|
fmtSep: string
|
||||||
|
fmtStrs: array[Level, string]
|
||||||
|
|
||||||
|
|
||||||
|
const defaultFlushThreshold = lvlAll
|
||||||
|
|
||||||
|
proc genFmtStr(
|
||||||
|
fmtPrefix, fmtSep, fmtSuffix, levelBb: string,
|
||||||
|
level: Level
|
||||||
|
): string =
|
||||||
|
var parts: seq[string]
|
||||||
|
if fmtPrefix != "": parts.add fmtPrefix
|
||||||
|
parts.add $LevelNames[level].bb(levelBb)
|
||||||
|
return parts.join(fmtSep) & fmtSuffix
|
||||||
|
|
||||||
|
|
||||||
|
proc newFancyConsoleLogger*(
|
||||||
|
levelThreshold = lvlAll,
|
||||||
|
fmtPrefix= "",
|
||||||
|
fmtSep = "|",
|
||||||
|
fmtSuffix ="| ",
|
||||||
|
useStderr = false,
|
||||||
|
flushThreshold = defaultFlushThreshold,
|
||||||
|
debugBb: string = "faint",
|
||||||
|
infoBb: string = "bold",
|
||||||
|
noticeBb: string = "bold",
|
||||||
|
warnBb: string = "bold yellow",
|
||||||
|
errorBb: string = "bold red",
|
||||||
|
fatalBb: string = "bold red"
|
||||||
|
): FancyConsoleLogger =
|
||||||
|
## Creates a new `FancyConsoleLogger<#ConsoleLogger>`_.
|
||||||
|
new result
|
||||||
|
let fmtStrs: array[Level, string] = [
|
||||||
|
genFmtStr(fmtPrefix,fmtSep, fmtSuffix, "", lvlAll),
|
||||||
|
genFmtStr(fmtPrefix,fmtSep, fmtSuffix, debugBb, lvlDebug),
|
||||||
|
genFmtStr(fmtPrefix,fmtSep, fmtSuffix, infobb, lvlInfo),
|
||||||
|
genFmtStr(fmtPrefix,fmtSep, fmtSuffix, noticeBb, lvlNotice),
|
||||||
|
genFmtStr(fmtPrefix,fmtSep, fmtSuffix, warnBb, lvlWarn),
|
||||||
|
genFmtStr(fmtPrefix,fmtSep, fmtSuffix, errorBb, lvlError),
|
||||||
|
genFmtStr(fmtPrefix,fmtSep, fmtSuffix, fatalBb, lvlFatal),
|
||||||
|
genFmtStr(fmtPrefix, fmtSep, fmtSuffix, "", lvlNone)
|
||||||
|
]
|
||||||
|
result.fmtPrefix = fmtPrefix
|
||||||
|
result.fmtSep = fmtSep
|
||||||
|
result.levelThreshold = levelThreshold
|
||||||
|
result.flushThreshold = flushThreshold
|
||||||
|
result.useStderr = useStderr
|
||||||
|
result.fmtStrs = fmtStrs
|
||||||
|
|
||||||
|
|
||||||
|
method log*(logger: FancyConsoleLogger, level: Level, args: varargs[string, `$`]) {.gcsafe.} =
|
||||||
|
## Logs to the console with the given `FancyConsoleLogger<#ConsoleLogger>`_ only.
|
||||||
|
##
|
||||||
|
## This method ignores the list of registered handlers.
|
||||||
|
##
|
||||||
|
## Whether the message is logged depends on both the ConsoleLogger's
|
||||||
|
## ``levelThreshold`` field and the global log filter set using the
|
||||||
|
## `setLogFilter proc<#setLogFilter,Level>`_.
|
||||||
|
##
|
||||||
|
## **Note:** Only error and fatal messages will cause the output buffer
|
||||||
|
## to be flushed immediately by default. Set ``flushThreshold`` when creating
|
||||||
|
## the logger to change this.
|
||||||
|
|
||||||
|
if level >= logger.levelThreshold:
|
||||||
|
let ln = substituteLog(logger.fmtStrs[level], level, args)
|
||||||
|
when defined(js): {.fatal: "handler does not support JS".}
|
||||||
|
try:
|
||||||
|
let handle =
|
||||||
|
if logger.useStderr: stderr
|
||||||
|
else: stdout
|
||||||
|
writeLine(handle, ln)
|
||||||
|
if level >= logger.flushThreshold: flushFile(handle)
|
||||||
|
except IOError:
|
||||||
|
discard
|
||||||
|
|
||||||
|
proc addHandlers*(handler: Logger) =
|
||||||
|
handlers.add(handler)
|
||||||
|
|
||||||
|
template errorQuit*(args: varargs[string, `$`]) =
|
||||||
|
error args
|
||||||
|
quit QuitFailure
|
||||||
|
|
||||||
|
template fatalQuit*(args: varargs[string, `$`]) =
|
||||||
|
fatal args
|
||||||
|
quit QuitFailure
|
||||||
|
|
|
@ -3,9 +3,9 @@ import std/[
|
||||||
enumerate, os, sequtils, strformat,
|
enumerate, os, sequtils, strformat,
|
||||||
strutils, sugar, logging, tables
|
strutils, sugar, logging, tables
|
||||||
]
|
]
|
||||||
import hwylterm, hwylterm/logging, jsony
|
import hwylterm, jsony
|
||||||
|
import ./[context, exec, logging]
|
||||||
|
|
||||||
import ./[context, exec]
|
|
||||||
|
|
||||||
proc nixCommand(cmd: string): string =
|
proc nixCommand(cmd: string): string =
|
||||||
result = "nix"
|
result = "nix"
|
||||||
|
@ -257,3 +257,8 @@ proc nixBuildWithCache*(minimal: bool, name: string, rest:seq[string]) =
|
||||||
let err = runCmd(cmd)
|
let err = runCmd(cmd)
|
||||||
quit err
|
quit err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue