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

View file

@ -30,12 +30,14 @@
extra-substituters = [ extra-substituters = [
"https://hyprland.cachix.org" "https://hyprland.cachix.org"
"https://nixpkgs-wayland.cachix.org" "https://nixpkgs-wayland.cachix.org"
"https://daylin.cachix.org" # "https://daylin.cachix.org"
"https://cache.garnix.io"
]; ];
extra-trusted-public-keys = [ extra-trusted-public-keys = [
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA=" "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 = _: {}; outputs = _: {};

View file

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

View file

@ -37,11 +37,11 @@
trusted-users = ["@wheel"]; trusted-users = ["@wheel"];
accept-flake-config = true; accept-flake-config = true;
substituters = [ # substituters = [
"https://daylin.cachix.org" # "https://daylin.cachix.org"
]; # ];
trusted-public-keys = [ # trusted-public-keys = [
"daylin.cachix.org-1:fLdSnbhKjtOVea6H9KqXeir+PyhO+sDSPhEW66ClE/k=" # "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 from std/nativesockets import getHostname
let summaryFile = getEnv("GITHUB_STEP_SUMMARY") let summaryFile = getEnv("GITHUB_STEP_SUMMARY")
proc info(args: varargs[string, `$`]) = proc info(args: varargs[string, `$`]) =
stdout.styledWriteLine( stdout.styledWriteLine(
fgCyan, "oizys", resetStyle, "|", fgCyan, "oizys", resetStyle, "|",
@ -18,15 +17,18 @@ proc error(args: varargs[string, `$`]) =
args.join("") args.join("")
) )
proc execQuit(cmd: string) =
quit (execCmd cmd)
type type
OizysContext = object OizysContext = object
flake, host: string flake, host: string
extraArgs: seq[string]
cache = "daylin" cache = "daylin"
pinix: bool = true 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 = proc newCtx(): OizysContext =
result = OizysContext() result = OizysContext()
result.flake = getEnv("FLAKE_PATH", getEnv("HOME") / "oizys") result.flake = getEnv("FLAKE_PATH", getEnv("HOME") / "oizys")
@ -48,11 +50,11 @@ proc systemFlakePath(c: OizysContext): string =
proc build(c: OizysContext) = proc build(c: OizysContext) =
## build nixos ## build nixos
execQuit c.cmd & " build " & c.systemFlakePath execQuit c, c.cmd, "build", c.systemFlakePath
proc dry(c: OizysContext) = proc dry(c: OizysContext) =
## poor man's nix flake check ## 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) = proc cache(c: OizysContext) =
let start = now() let start = now()
@ -77,7 +79,7 @@ proc cache(c: OizysContext) =
proc nixosRebuild(c: OizysContext, subcmd: string) = proc nixosRebuild(c: OizysContext, subcmd: string) =
let cmd = if c.pinix: "pixos-rebuild" else: "nixos-rebuild" 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) = proc boot(c: OizysContext) =
## nixos rebuild boot ## nixos rebuild boot
@ -119,7 +121,7 @@ proc runCmd(c: OizysContext, cmd: string) =
quit 1 quit 1
proc parseFlag(c: var OizysContext, key, val: string) = proc parseFlag(c: var OizysContext, kind: CmdLineKind, key, val: string) =
case key: case key:
of "h", "help": of "h", "help":
echo usage; quit 0 echo usage; quit 0
@ -129,23 +131,31 @@ proc parseFlag(c: var OizysContext, key, val: string) =
c.flake = val c.flake = val
of "no-pinix": of "no-pinix":
c.pinix = false c.pinix = false
else:
c.extraArgs.add (if kind == cmdLongOption: "--" else: "-") & key
c.extraArgs.add val
when isMainModule: when isMainModule:
import std/parseopt
var var
c = newCtx() c = newCtx()
subcmd: string 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 case kind
of cmdArgument: of cmdArgument:
echo key
subcmd = key subcmd = key
of cmdLongOption, cmdShortOption: of cmdLongOption, cmdShortOption:
parseFlag c, key, val if key == "":
break
parseFlag c, kind, key, val
of cmdEnd: of cmdEnd:
discard discard
if subcmd == "": if subcmd == "":
echo "please specify a command" echo "please specify a command"
echo usage; quit 1 echo usage; quit 1
c.extraArgs = p.remainingArgs
check c check c
runCmd c, subcmd runCmd c, subcmd