mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 10:10:45 -06:00
Compare commits
1 commit
88af7af855
...
571557af3c
Author | SHA1 | Date | |
---|---|---|---|
571557af3c |
7 changed files with 56 additions and 86 deletions
28
flake.lock
28
flake.lock
|
@ -357,11 +357,11 @@
|
||||||
"xdph": "xdph"
|
"xdph": "xdph"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727992844,
|
"lastModified": 1727900725,
|
||||||
"narHash": "sha256-4qhURtbqfaaGfBRz+Fu3iT2QOW7xn7Cl749i5SRZEQM=",
|
"narHash": "sha256-yS4oC5G/FKrsrRjk03cGzTEXHAwfjP7azFHoKvlFfD8=",
|
||||||
"ref": "refs/heads/main",
|
"ref": "refs/heads/main",
|
||||||
"rev": "aed529f695bc62f5fa45dc94c545275ebb49bc48",
|
"rev": "de68e065fe861d7ca01eca267df4c305bc6e73c2",
|
||||||
"revCount": 5288,
|
"revCount": 5287,
|
||||||
"submodules": true,
|
"submodules": true,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/hyprwm/Hyprland/"
|
"url": "https://github.com/hyprwm/Hyprland/"
|
||||||
|
@ -729,17 +729,17 @@
|
||||||
"treefmt-nix": "treefmt-nix"
|
"treefmt-nix": "treefmt-nix"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727483986,
|
"lastModified": 1726640797,
|
||||||
"narHash": "sha256-8F97zAu+icDC9ZYS7m+Y58oZQ7R3gVuXMvzAfgkVmJo=",
|
"narHash": "sha256-tuqkFa7ZxcGwU8gTbKO61oGMdTmG9CiaI+NiaOV7SCI=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixd",
|
"repo": "nixd",
|
||||||
"rev": "05ff3db3d1da26eafd5f58c7104e4f9ff6630894",
|
"rev": "e2f0d908d6f2ee7bf72c620ed3c78817143b50ae",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"ref": "2.4.0",
|
|
||||||
"repo": "nixd",
|
"repo": "nixd",
|
||||||
|
"rev": "e2f0d908d6f2ee7bf72c620ed3c78817143b50ae",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -977,11 +977,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727969805,
|
"lastModified": 1727382008,
|
||||||
"narHash": "sha256-eotOuafJ+KcfEYuZVYYTdcj0ST3RG+GOEsomkOQqYp0=",
|
"narHash": "sha256-t9SNSBXzECHI5KdWbJXsN2ATpXqq7JBGag/1BgY3yfE=",
|
||||||
"owner": "daylinmorgan",
|
"owner": "daylinmorgan",
|
||||||
"repo": "pixi-flake",
|
"repo": "pixi-flake",
|
||||||
"rev": "d4ea6b52b804cd20d4b661b568389e35e372e2f5",
|
"rev": "935278026a29a12589bb594533905d329bd16a9d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -1311,11 +1311,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1728001744,
|
"lastModified": 1727656237,
|
||||||
"narHash": "sha256-6bYvaXkZK4XZ8o2cyjWkv5pvJKXHioQ9nJbW+7qaURQ=",
|
"narHash": "sha256-qfZ7nYqYmzPc3Ei9hvWRrFu3Mn3WJ2akyYvaoPOOHcM=",
|
||||||
"owner": "mitchellh",
|
"owner": "mitchellh",
|
||||||
"repo": "zig-overlay",
|
"repo": "zig-overlay",
|
||||||
"rev": "a2aa0972982b43cff53b409075512874a9887bc2",
|
"rev": "5bdd678ad99cd0069dfa6a5822c1d82d45d34ad2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
nixos-wsl.url = "github:nix-community/NixOS-WSL";
|
nixos-wsl.url = "github:nix-community/NixOS-WSL";
|
||||||
nix-index-database.url = "github:nix-community/nix-index-database";
|
nix-index-database.url = "github:nix-community/nix-index-database";
|
||||||
# pipe support added
|
# pipe support added
|
||||||
nixd.url = "github:nix-community/nixd/2.4.0";
|
nixd.url = "github:nix-community/nixd/e2f0d908d6f2ee7bf72c620ed3c78817143b50ae";
|
||||||
|
|
||||||
lix = {
|
lix = {
|
||||||
url = "https://git.lix.systems/lix-project/lix/archive/main.tar.gz";
|
url = "https://git.lix.systems/lix-project/lix/archive/main.tar.gz";
|
||||||
|
|
|
@ -47,22 +47,21 @@ let
|
||||||
# ["a" "b"] -> {a.enable = true; b.enable = true;}
|
# ["a" "b"] -> {a.enable = true; b.enable = true;}
|
||||||
enableAttrs =
|
enableAttrs =
|
||||||
attrs:
|
attrs:
|
||||||
attrs
|
listToAttrs (
|
||||||
|> map (attr: {
|
map (attr: {
|
||||||
name = attr;
|
name = attr;
|
||||||
value = enabled;
|
value = enabled;
|
||||||
})
|
}) attrs
|
||||||
|> listToAttrs;
|
);
|
||||||
|
|
||||||
# ["a" "b"] -> {a.enable = false; b.enable = false;}
|
# ["a" "b"] -> {a.enable = false; b.enable = false;}
|
||||||
disableAttrs =
|
disableAttrs =
|
||||||
attrs:
|
attrs:
|
||||||
attrs
|
listToAttrs (
|
||||||
|> map (attr: {
|
map (attr: {
|
||||||
name = attr;
|
name = attr;
|
||||||
value = disabled;
|
value = disabled;
|
||||||
})
|
}) attrs
|
||||||
|> listToAttrs;
|
);
|
||||||
|
|
||||||
mkIfIn = name: list: prev.mkIf (builtins.elem name list);
|
mkIfIn = name: list: prev.mkIf (builtins.elem name list);
|
||||||
|
|
||||||
|
@ -111,8 +110,7 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
loadOverlays =
|
loadOverlays =
|
||||||
inputs: dir:
|
inputs: dir: readDir dir
|
||||||
readDir dir
|
|
||||||
|> attrNames
|
|> attrNames
|
||||||
|> filter (f: f != "default.nix")
|
|> filter (f: f != "default.nix")
|
||||||
|> map (f: import (../overlays + "/${f}") { inherit inputs; });
|
|> map (f: import (../overlays + "/${f}") { inherit inputs; });
|
||||||
|
|
|
@ -8,5 +8,5 @@ buildNimblePackage {
|
||||||
verions = "unstable";
|
verions = "unstable";
|
||||||
src = lib.cleanSource ./.;
|
src = lib.cleanSource ./.;
|
||||||
nativeBuildInputs = [ openssl ];
|
nativeBuildInputs = [ openssl ];
|
||||||
nimbleDepsHash = "sha256-RceRnhEkei3RfSCTOJsIiw4GSCyhOZhKoEVHNSw/KvA=";
|
nimbleDepsHash = "sha256-3p+PdGkQmKwz5tzJwX0aun3kSOLw/lwzqRkR9+6ECQE=";
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,12 @@
|
||||||
},
|
},
|
||||||
"hwylterm": {
|
"hwylterm": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"vcsRevision": "7e82f7ba5a24d816a79b3a5ea49f32b4c7a5ef7e",
|
"vcsRevision": "d852761831bd748db24b42f15bc8e2d286232295",
|
||||||
"url": "https://github.com/daylinmorgan/hwylterm",
|
"url": "https://github.com/daylinmorgan/hwylterm",
|
||||||
"downloadMethod": "git",
|
"downloadMethod": "git",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"checksums": {
|
"checksums": {
|
||||||
"sha1": "d6d97bdff3fcdfcf4b39b144fa5f27a6b9f9494d"
|
"sha1": "7de2a93a03bd0659d8d70cc7c08315e0a7f15439"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"jsony": {
|
"jsony": {
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
## 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 hwylterm, hwylterm/[cligen, logging]
|
||||||
import oizys/[context, github, nix, overlay, logging]
|
import oizys/[context, github, nix, overlay]# 3, logging
|
||||||
|
|
||||||
|
addHandler(
|
||||||
|
newFancyConsoleLogger(
|
||||||
|
fmtPrefix = $bb"[b magenta]oizys"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
proc confirm(q: string): bool =
|
proc confirm(q: string): bool =
|
||||||
stderr.write $(q & bb"[yellow] (Y/n) ")
|
stderr.write $(q & bb"[yellow] (Y/n) ")
|
||||||
|
@ -23,7 +28,7 @@ overlay:
|
||||||
resetCache: bool = false,
|
resetCache: bool = false,
|
||||||
rest: seq[string],
|
rest: seq[string],
|
||||||
) =
|
) =
|
||||||
setupLoggers(debug)
|
if not debug: setLogFilter(lvlInfo)
|
||||||
updateContext(host, flake, debug, resetCache)
|
updateContext(host, flake, debug, resetCache)
|
||||||
|
|
||||||
proc dry(minimal: bool = false) =
|
proc dry(minimal: bool = false) =
|
||||||
|
@ -77,6 +82,16 @@ proc checkExes() =
|
||||||
if findExe("nix") == "":
|
if findExe("nix") == "":
|
||||||
fatalQuit "oizys requires nix"
|
fatalQuit "oizys requires nix"
|
||||||
|
|
||||||
|
func `//`[A, B](pairs: openArray[(A, B)]): Table[A, B] =
|
||||||
|
pairs.toTable()
|
||||||
|
func `//`[A, B](t1: var Table[A,B], t2: Table[A,B]) =
|
||||||
|
for k, v in t2.pairs(): t1[k] = v
|
||||||
|
func `//`[A, B](t1: Table[A, B], t2: Table[A, B]): Table[A, B] =
|
||||||
|
result // t1; result // t2
|
||||||
|
func `//`[A, B](pairs: openArray[(A,B)], t2: Table[A,B]): Table[A,B] =
|
||||||
|
// pairs // t2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
import cligen
|
import cligen
|
||||||
|
@ -100,15 +115,17 @@ when isMainModule:
|
||||||
"name" : "name of cachix binary cache"
|
"name" : "name of cachix binary cache"
|
||||||
} // sharedHelp
|
} // sharedHelp
|
||||||
let
|
let
|
||||||
|
# clUse must be set here using clCfg doesn't seem to work with dispatchMutli ...
|
||||||
|
clUse* = $bb("$command $args\n${doc}[bold]Options[/]:\n$options")
|
||||||
osUsage = $bb("$command [[subcmd] $args\n$doc[bold]Options[/]:\n$options")
|
osUsage = $bb("$command [[subcmd] $args\n$doc[bold]Options[/]:\n$options")
|
||||||
|
|
||||||
dispatchMulti(
|
dispatchMulti(
|
||||||
[build, help = sharedHelp, usage = clCfg.use ],
|
[build, help = sharedHelp, usage = clUse ],
|
||||||
[cache, help = cacheHelp , usage = clCfg.use ],
|
[cache, help = cacheHelp , usage = clUse ],
|
||||||
[ci, help = ciHelp , usage = clCfg.use ],
|
[ci, help = ciHelp , usage = clUse ],
|
||||||
[dry, help = sharedHelp, usage = clCfg.use ],
|
[dry, help = sharedHelp, usage = clUse ],
|
||||||
[osCmd, help = sharedHelp, usage = osUsage, cmdName = "os"],
|
[osCmd, help = sharedHelp, usage = osUsage, cmdName = "os"],
|
||||||
[output, help = sharedHelp, usage = clCfg.use],
|
[output, help = sharedHelp, usage = clUse],
|
||||||
[update, help = updateHelp, usage = clCfg.use],
|
[update, help = updateHelp, usage = clUse],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
## nix begat oizys
|
|
||||||
import std/[logging, os]
|
|
||||||
import hwylterm, hwylterm/logging
|
|
||||||
export logging
|
|
||||||
|
|
||||||
|
|
||||||
proc getDataDir(): string =
|
|
||||||
## Returns the data directory of the current user for applications.
|
|
||||||
# follows std/os.getCacheDir
|
|
||||||
# which in turn follows https://crates.io/crates/platform-dirs
|
|
||||||
result =
|
|
||||||
when defined(windows):
|
|
||||||
getEnv("LOCALAPPDATA")
|
|
||||||
elif defined(osx):
|
|
||||||
getEnv("XDG_DATA_HOME", getEnv("HOME") / "Library/Application Support")
|
|
||||||
else:
|
|
||||||
getEnv("XDG_DATA_HOME", getEnv("HOME") / ".local/share")
|
|
||||||
|
|
||||||
result.normalizePathEnd(false)
|
|
||||||
|
|
||||||
proc getOizysLogPath(): string =
|
|
||||||
let dataDir = getDataDir()
|
|
||||||
createDir(dataDir / "oizys")
|
|
||||||
result = dataDir / "oizys" / "oizys.log"
|
|
||||||
|
|
||||||
|
|
||||||
setLogFilter(lvlAll)
|
|
||||||
|
|
||||||
proc setupLoggers*(debug: bool) =
|
|
||||||
let logLevel =
|
|
||||||
if not debug: lvlInfo
|
|
||||||
else: lvlAll
|
|
||||||
addHandler(
|
|
||||||
newFancyConsoleLogger(
|
|
||||||
fmtPrefix = $bb"[b magenta]oizys",
|
|
||||||
levelThreshold = logLevel
|
|
||||||
)
|
|
||||||
)
|
|
||||||
addHandler(
|
|
||||||
newRollingFileLogger(
|
|
||||||
getOizysLogPath(),
|
|
||||||
mode = fmAppend,
|
|
||||||
fmtStr = "$datetime | $levelid:"
|
|
||||||
)
|
|
||||||
)
|
|
Loading…
Reference in a new issue