Compare commits

...

5 commits

Author SHA1 Message Date
8766668a1c
improve command line parsing in oizys cli 2024-02-27 13:27:20 -06:00
b63bd12d6a
update lock 2024-02-27 12:51:34 -06:00
60a1c20747
to revert 2024-02-27 12:51:16 -06:00
57d0d2a9fb
add another sub 2024-02-27 12:39:13 -06:00
9ae0260cc0
print out command 2024-02-27 12:22:06 -06:00
5 changed files with 42 additions and 31 deletions

View file

@ -169,11 +169,11 @@
},
"locked": {
"dir": "inputs",
"lastModified": 1709052087,
"narHash": "sha256-iVkXKOCGoMAlvPrZQau4hEBFK3lWRmvrPfs25parGW4=",
"lastModified": 1709059876,
"narHash": "sha256-zc4rfNB4EkFmU67E8J7zpe2pqFD1ONXQgBw2ptow5jY=",
"owner": "daylinmorgan",
"repo": "oizys",
"rev": "c0b2603a31b07e939c5663cfd1b1effa47da5d69",
"rev": "60a1c20747ef729ba07e8bbc18fa8caebdd85010",
"type": "github"
},
"original": {
@ -271,11 +271,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1708976803,
"narHash": "sha256-yvRygcySjjSvj5JTaCdo7lPqJ/2mBV2XQ94Oaq/14qw=",
"lastModified": 1709038661,
"narHash": "sha256-Ys611iT6pChGv954aa4f8oKoDKJG3IXjJjPhnj6uaLY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "548a86b335d7ecd8b57ec617781f5e652ab0c38e",
"rev": "8520c158aee718c6e87b56881105fc4223c3c723",
"type": "github"
},
"original": {
@ -314,11 +314,11 @@
]
},
"locked": {
"lastModified": 1709050816,
"narHash": "sha256-8pFTejdM2+L0XMp2/sKtXxx6S7348oLDW10uGrmYvds=",
"lastModified": 1709054151,
"narHash": "sha256-XRF+8hpY5+g5jxld8EMERVtIfJM6WMdVKW5Mnm912xo=",
"owner": "nix-community",
"repo": "nixpkgs-wayland",
"rev": "022be38bbf1d4be94cff0d382108bece8ad0d2ad",
"rev": "c4fff942ce8dc430bb33f983dab44d308c2966a9",
"type": "github"
},
"original": {

View file

@ -30,12 +30,14 @@
extra-substituters = [
"https://hyprland.cachix.org"
"https://nixpkgs-wayland.cachix.org"
"https://daylin.cachix.org"
# "https://daylin.cachix.org"
"https://cache.garnix.io"
];
extra-trusted-public-keys = [
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
"daylin.cachix.org-1:fLdSnbhKjtOVea6H9KqXeir+PyhO+sDSPhEW66ClE/k="
# "daylin.cachix.org-1:fLdSnbhKjtOVea6H9KqXeir+PyhO+sDSPhEW66ClE/k="
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
];
};
outputs = _: {};

View file

@ -4,7 +4,6 @@
pkgs,
...
}: let
inherit (lib) mkIfIn;
cfg = config.oizys.languages;
in {

View file

@ -37,11 +37,11 @@
trusted-users = ["@wheel"];
accept-flake-config = true;
substituters = [
"https://daylin.cachix.org"
];
trusted-public-keys = [
"daylin.cachix.org-1:fLdSnbhKjtOVea6H9KqXeir+PyhO+sDSPhEW66ClE/k="
];
# substituters = [
# "https://daylin.cachix.org"
# ];
# trusted-public-keys = [
# "daylin.cachix.org-1:fLdSnbhKjtOVea6H9KqXeir+PyhO+sDSPhEW66ClE/k="
# ];
};
}

View file

@ -1,9 +1,8 @@
import std/[os, osproc, tables, times, strutils, terminal]
import std/[os, osproc, parseopt, times, strutils, terminal]
from std/nativesockets import getHostname
let summaryFile = getEnv("GITHUB_STEP_SUMMARY")
proc info(args: varargs[string, `$`]) =
stdout.styledWriteLine(
fgCyan, "oizys", resetStyle, "|",
@ -18,15 +17,18 @@ proc error(args: varargs[string, `$`]) =
args.join("")
)
proc execQuit(cmd: string) =
quit (execCmd cmd)
type
OizysContext = object
flake, host: string
extraArgs: seq[string]
cache = "daylin"
pinix: bool = true
proc execQuit(c: OizysContext, args: varargs[string]) =
let cmd = (@args & c.extraArgs).join(" ")
info "exec: ", cmd
quit (execCmd cmd)
proc newCtx(): OizysContext =
result = OizysContext()
result.flake = getEnv("FLAKE_PATH", getEnv("HOME") / "oizys")
@ -48,11 +50,11 @@ proc systemFlakePath(c: OizysContext): string =
proc build(c: OizysContext) =
## build nixos
execQuit c.cmd & " build " & c.systemFlakePath
execQuit c, c.cmd, "build", c.systemFlakePath
proc dry(c: OizysContext) =
## poor man's nix flake check
execQuit c.cmd & " build " & c.systemFlakePath & " --dry-run"
execQuit c, c.cmd, "build", c.systemFlakePath, "--dry-run"
proc cache(c: OizysContext) =
let start = now()
@ -77,7 +79,7 @@ proc cache(c: OizysContext) =
proc nixosRebuild(c: OizysContext, subcmd: string) =
let cmd = if c.pinix: "pixos-rebuild" else: "nixos-rebuild"
execQuit "sudo " & cmd & " " & subcmd & " " & " --flake " & c.flake
execQuit c, "sudo", cmd, subcmd, "--flake", c.flake
proc boot(c: OizysContext) =
## nixos rebuild boot
@ -119,7 +121,7 @@ proc runCmd(c: OizysContext, cmd: string) =
quit 1
proc parseFlag(c: var OizysContext, key, val: string) =
proc parseFlag(c: var OizysContext, kind: CmdLineKind, key, val: string) =
case key:
of "h", "help":
echo usage; quit 0
@ -129,23 +131,31 @@ proc parseFlag(c: var OizysContext, key, val: string) =
c.flake = val
of "no-pinix":
c.pinix = false
else:
c.extraArgs.add (if kind == cmdLongOption: "--" else: "-") & key
c.extraArgs.add val
when isMainModule:
import std/parseopt
var
c = newCtx()
subcmd: string
for kind, key, val in getopt(longNoVal = @["no-nom"]):
var p = initOptParser(
longNoVal = @["no-pinix", "help", ""], shortNoVal = {'h'}
)
for kind, key, val in p.getopt():
case kind
of cmdArgument:
echo key
subcmd = key
of cmdLongOption, cmdShortOption:
parseFlag c, key, val
if key == "":
break
parseFlag c, kind, key, val
of cmdEnd:
discard
if subcmd == "":
echo "please specify a command"
echo usage; quit 1
c.extraArgs = p.remainingArgs
check c
runCmd c, subcmd