Compare commits

..

No commits in common. "dea2d9e473ffcc34198ea8601a233664643751f1" and "defb301c9027c4ba5f63a24649516529a38e7de2" have entirely different histories.

12 changed files with 139 additions and 166 deletions

View file

@ -41,7 +41,7 @@ jobs:
- uses: ./.github/actions/nix - uses: ./.github/actions/nix
with: with:
attic_token: ${{ secrets.ATTIC_TOKEN }} attic_token: ${{ secrets.ATTIC_TOKEN }}
# clean: true clean: true
btrfs: true btrfs: true
- name: write lock file - name: write lock file

View file

@ -2,13 +2,6 @@ name: Flake Update / Build
on: on:
workflow_dispatch: workflow_dispatch:
inputs:
hosts:
description: 'list of hosts to build'
required: true
default: 'othalan,algiz'
type: string
schedule: schedule:
# At minute 00:00 on Monday, Wednesday, and Friday. # At minute 00:00 on Monday, Wednesday, and Friday.
- cron: 0 0 * * 1,3,5 - cron: 0 0 * * 1,3,5
@ -58,11 +51,9 @@ jobs:
nix run . nix run .
-- --
cache cache
--host,="${{ inputs.hosts }}" --host,=",othalan,algiz"
--flake . --flake .
--debug --debug
--
--quiet
- name: Commit Updates - name: Commit Updates
uses: daylin-bot/actions/commit-and-push@main uses: daylin-bot/actions/commit-and-push@main
@ -70,7 +61,7 @@ jobs:
push-args: --set-upstream --force origin flake-lock push-args: --set-upstream --force origin flake-lock
build-full: build-full-at-once:
needs: build-minimal needs: build-minimal
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -90,35 +81,125 @@ jobs:
- uses: ./.github/actions/nix - uses: ./.github/actions/nix
with: with:
attic_token: ${{ secrets.ATTIC_TOKEN }} attic_token: ${{ secrets.ATTIC_TOKEN }}
# clean: true clean: true
btrfs: true btrfs: true
- name: Pre-build oizys - name: Pre-build oizys
run: nix build . run: nix build .
- name: Build Current and Updated Systems - name: Build
run: > run: >
nix run . nix run .
-- --
ci update build
--host,="${{ inputs.hosts }}" "$(nix run . -- output --host,=othalan,algiz,mannaz,naudiz --flake .)"
--flake . --flake .
--debug --debug
-- --
--quiet --keep-going
--out-link current
- run: git checkout flake-lock
- name: Pre-build oizys
run: nix build .
- name: Build Updated
run: >
nix run .
--
build
"$(nix run . -- output --host,=othalan,algiz,mannaz,naudiz --flake .)"
--flake .
--debug
--
--keep-going
--out-link updated
- run: ls
# - run: |
# echo "# System Diff" >> $GITHUB_STEP_SUMMARY
# 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
#
- run: df -h
# - uses: actions/upload-artifact@v4
# with:
# name: ${{ matrix.host }}-summary
# path: summary.md
#
build-full:
needs: build-minimal
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
host:
- othalan
- algiz
- mannaz
- naudiz
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# needed to access ghostty repo for now
- name: Setup SSH
uses: MrSquaare/ssh-setup-action@v3
with:
host: github.com
private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- uses: daylin-bot/actions/setup@main
- uses: ./.github/actions/nix
with:
attic_token: ${{ secrets.ATTIC_TOKEN }}
clean: true
btrfs: true
- name: Pre-build oizys
run: nix build .
- name: Build
run: >
nix run .
--
build
"$(nix run . -- output --host "${{ matrix.host }}" --flake .)"
--flake .
--debug
--
--keep-going
--out-link current
- run: git checkout flake-lock
- name: Pre-build oizys
run: nix build .
- name: Build Updated
run: >
nix run .
--
build
"$(nix run . -- output --host "${{ matrix.host }}" --flake .)"
--flake .
--debug
--
--keep-going
--out-link updated
- run: | - run: |
echo "# system diffs" >> $GITHUB_STEP_SUMMARY echo "# System Diff" >> $GITHUB_STEP_SUMMARY
hosts="${{ inputs.hosts }}" nix run "nixpkgs#nvd" -- --color always diff ./current ./updated >> summary.md
for host in ${hosts//,/ }; do printf '```\n%s\n```\n' "$(nix run "nixpkgs#nvd" -- diff ./current ./updated)" >> $GITHUB_STEP_SUMMARY
echo "## $host" >> $GITHUB_STEP_SUMMARY
nix run "nixpkgs#nvd" -- --color always diff ./$host-current ./$host-updated >> $host-summary.md
printf '```\n%s\n```\n' "$(nix run "nixpkgs#nvd" -- diff ./$host-current ./$host-updated)" >> $GITHUB_STEP_SUMMARY
done
- run: df -h - run: df -h
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
name: summary name: ${{ matrix.host }}-summary
path: '*-summary.md' path: summary.md

View file

@ -8,7 +8,7 @@ buildNimblePackage {
verions = "unstable"; verions = "unstable";
src = lib.cleanSource ./.; src = lib.cleanSource ./.;
nativeBuildInputs = [ openssl ]; nativeBuildInputs = [ openssl ];
nimbleDepsHash = "sha256-IWdlWC+j2h15WjVXXdDyxDZsb0/Ti1+jy6RfmqHFkjs="; nimbleDepsHash = "sha256-1YoGvWvoJJSMauDbeH8ZHuK+QQot48Mkye9TeWteT8k=";
meta = { meta = {
description = "nix begat oizys"; description = "nix begat oizys";

View file

@ -3,12 +3,12 @@
"packages": { "packages": {
"hwylterm": { "hwylterm": {
"version": "0.1.0", "version": "0.1.0",
"vcsRevision": "ef573dc0f8bf39f80704f92cfab39e1b9af82492", "vcsRevision": "c5f70cec4e40ba396f59162e98c359a1a1ea4fe1",
"url": "https://github.com/daylinmorgan/hwylterm", "url": "https://github.com/daylinmorgan/hwylterm",
"downloadMethod": "git", "downloadMethod": "git",
"dependencies": [], "dependencies": [],
"checksums": { "checksums": {
"sha1": "ccb51201898b5e913ffee1e18bdf4d9fc4004386" "sha1": "5727969a8e82e29a7581c13cc7cc45996dbca5a1"
} }
}, },
"jsony": { "jsony": {

View file

@ -1,5 +1,5 @@
## nix begat oizys ## nix begat oizys
import std/[os, osproc, sequtils, strformat, strutils, tables] import std/[os, osproc, sequtils, strformat, strutils]
import hwylterm, hwylterm/[hwylcli] import hwylterm, hwylterm/[hwylcli]
import oizys/[context, github, nix, logging] import oizys/[context, github, nix, logging]
@ -33,10 +33,11 @@ hwylCli:
? "set minimal" ? "set minimal"
- m - m
preSub: preSub:
setupLoggers() setupLoggers(debug)
updateContext(host, flake, debug, resetCache) updateContext(host, flake, debug, resetCache)
subcommands: subcommands:
[build] [build]
... "nix build" ... "nix build"
flags: flags:
@ -64,40 +65,15 @@ hwylCli:
nixBuildWithCache(name, args, service, jobs) nixBuildWithCache(name, args, service, jobs)
[ci] [ci]
... "builtin ci" ... "trigger GHA"
# current behavior adds this block twice...
# when really I want it to only happen in the lowest "subcommand"
# needs to be fixed in hwylterm
preSub:
updateContext(host, flake, debug, resetCache)
subcommands:
[update]
... "build current and updated hosts"
run:
ciUpdate(args)
[gha]
... """
trigger GHA
examples:
[b]oizys gha update[/] --input:hosts:othalan,algiz,mannaz
"""
flags: flags:
input:
T seq[KVString]
? "inputs for dispatch"
`ref`: `ref`:
T string T string
? "git ref/branch/tag to trigger workflow on" ? "git ref/branch/tag to trigger workflow on"
* "main" * "main"
run: run:
# TODO: support file operations like gh
# i.e. @flake.lock means read a file a flake.lock and use it's contents
if args.len == 0: fatalQuit "expected workflow file name" if args.len == 0: fatalQuit "expected workflow file name"
let inputs = createDispatch(args[0], `ref`)
input.mapIt((it.key, it.val)).toTable()
createDispatch(args[0], `ref`, inputs)
[dry] [dry]
... "dry run build" ... "dry run build"

View file

@ -1,7 +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, hwylterm/logging import hwylterm, hwylterm/logging
import ./logging
type type
OizysContext* = object OizysContext* = object
@ -37,8 +36,6 @@ proc updateContext*(
) = ) =
if host.len > 0: oc.hosts = host if host.len > 0: oc.hosts = host
oc.debug = debug oc.debug = debug
if debug:
consoleLogger.levelThreshold = lvlAll
oc.resetCache = resetCache oc.resetCache = resetCache
if flake != "": if flake != "":
oc.flake = oc.flake =
@ -52,3 +49,5 @@ proc getFlake*(): string = return oc.flake
proc isDebug*(): bool = return oc.debug proc isDebug*(): bool = return oc.debug
proc isResetCache*(): bool = return oc.resetCache proc isResetCache*(): bool = return oc.resetCache
proc isCi*(): bool = return oc.ci proc isCi*(): bool = return oc.ci

View file

@ -47,10 +47,7 @@ proc runCmdCapt*(
if errstrm.readLine(line): if errstrm.readLine(line):
result.stderr.add line & '\n' result.stderr.add line & '\n'
result.exitCode = peekExitCode(p) result.exitCode = peekExitCode(p)
if result.exitCode != -1: if result.exitCode != -1: break
result.stdout.add outstrm.readAll()
result.stderr.add errstrm.readAll()
break
close p close p

View file

@ -100,14 +100,13 @@ proc getInProgressRun(
warn "timeout reached waiting for workflow to start" warn "timeout reached waiting for workflow to start"
proc createDispatch*(workflowFileName: string, `ref`: string, inputs: Table[string, string]) = proc createDispatch*(workflowFileName: string, `ref`: string) =
## https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event ## https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event
let workflow = let workflow =
if workflowFileName.endsWith(".yml") or workflowFileName.endsWith(".yaml"): workflowFileName if workflowFileName.endsWith(".yml") or workflowFileName.endsWith(".yaml"): workflowFileName
else: workflowFileName & ".yml" else: workflowFileName & ".yml"
let body = %*{"ref": `ref`, "inputs": inputs} let body = %*{"ref": `ref`}
info fmt"creating dispatch event for {workflow}" info fmt"creating dispatch event for {workflow}"
debug "with body: " & $body
postGhApi( postGhApi(
fmt"https://api.github.com/repos/daylinmorgan/oizys/actions/workflows/{workflow}/dispatches", fmt"https://api.github.com/repos/daylinmorgan/oizys/actions/workflows/{workflow}/dispatches",
body body
@ -138,17 +137,17 @@ proc getArtifacts(runId: int): seq[GhArtifact] =
let response = getGhApi(fmt"https://api.github.com/repos/daylinmorgan/oizys/actions/runs/{runId}/artifacts") let response = getGhApi(fmt"https://api.github.com/repos/daylinmorgan/oizys/actions/runs/{runId}/artifacts")
fromJson(response.body, ListGhArtifactResponse).artifacts fromJson(response.body, ListGhArtifactResponse).artifacts
proc getUpdateSummaryArtifact(runId: int): GhArtifact = proc getUpdateSummaryArtifact(runId: int, host: string): GhArtifact =
let name = "summary" let name = fmt"{host}-summary"
let artifacts = getArtifacts(runId) let artifacts = getArtifacts(runId)
for artifact in artifacts: for artifact in artifacts:
if artifact.name == name: if artifact.name == name:
return artifact return artifact
fatalQuit fmt"failed to find summary for run id: {runID}" fatalQuit fmt"failed to find summary for run id: {runID}"
proc getUpdateSummaryUrl(runID: int): string = proc getUpdateSummaryUrl(runID: int, host: string): string =
## https://api.github.com/repos/OWNER/REPO/actions/artifacts/ARTIFACT_ID/ARCHIVE_FORMAT ## https://api.github.com/repos/OWNER/REPO/actions/artifacts/ARTIFACT_ID/ARCHIVE_FORMAT
let artifact = getUpdateSummaryArtifact(runID) let artifact = getUpdateSummaryArtifact(runID, host)
# httpclient was forwarding the Authorization headers, # httpclient was forwarding the Authorization headers,
# which confused Azure where the archive lives... # which confused Azure where the archive lives...
var response: Response var response: Response
@ -165,20 +164,20 @@ proc getUpdateSummaryUrl(runID: int): string =
if location.len == 0: errorQuit fmt("location header missing url?") if location.len == 0: errorQuit fmt("location header missing url?")
return location[0] return location[0]
proc fetchUpdateSummaryFromUrl(url: string, host: string): string = proc fetchUpdateSummaryFromUrl(url: string): string =
withTmpDir: withTmpDir:
let client = newHttpClient() let client = newHttpClient()
client.downloadFile(url, tmpDir / "summary.zip") client.downloadFile(url, tmpDir / "summary.zip")
let reader = openZipArchive(tmpDir / "summary.zip") let reader = openZipArchive(tmpDir / "summary.zip")
try: try:
result = reader.extractFile(host & "-summary.md") result = reader.extractFile("summary.md")
finally: finally:
reader.close() reader.close()
proc getUpdateSummary*(runId: int, host: string): string = proc getUpdateSummary*(runId: int, host: string): string =
withSpinner("fetching update summary"): withSpinner("fetching update summary"):
let url = getUpdateSummaryUrl(runId) let url = getUpdateSummaryUrl(runId, host)
result = fetchUpdateSummaryFromUrl(url, host) result = fetchUpdateSummaryFromUrl(url)
type type
GitRepo = object GitRepo = object

View file

@ -24,5 +24,3 @@ comma-with-db
nix-index-with-db nix-index-with-db
python python
net.conf net.conf
llm
rofi

View file

@ -23,18 +23,19 @@ proc getOizysLogPath(): string =
createDir(dataDir / "oizys") createDir(dataDir / "oizys")
result = dataDir / "oizys" / "oizys.log" result = dataDir / "oizys" / "oizys.log"
setLogFilter(lvlAll) setLogFilter(lvlAll)
var consoleLogger* = proc setupLoggers*(debug: bool) =
let logLevel =
if not debug: lvlInfo
else: lvlAll
addHandler(
newHwylConsoleLogger( newHwylConsoleLogger(
fmtPrefix = $bb"[b magenta]oizys", fmtPrefix = $bb"[b magenta]oizys",
fmtSuffix = " ", fmtSuffix = " ",
levelThreshold = lvlInfo levelThreshold = logLevel
) )
proc setupLoggers*() =
addHandler(
consoleLogger
) )
addHandler( addHandler(
newRollingFileLogger( newRollingFileLogger(

View file

@ -14,12 +14,9 @@ proc nixCommand(cmd: string): string =
result.addArg "--log-format multiline" result.addArg "--log-format multiline"
result.addArg cmd result.addArg cmd
proc nixosConfigAttr(host: string): string =
getFlake() & "#nixosConfigurations." & host & ".config.system.build.toplevel"
proc nixosConfigAttrs*(): seq[string] = proc nixosConfigAttrs*(): seq[string] =
for host in getHosts(): for host in getHosts():
result.add nixosConfigAttr(host) result.add getFlake() & "#nixosConfigurations." & host & ".config.system.build.toplevel"
const nixosSubcmds* = const nixosSubcmds* =
"""switch boot test build dry-build dry-activate edit """switch boot test build dry-build dry-activate edit
@ -351,78 +348,3 @@ proc nixBuildWithCache*(name: string, rest:seq[string], service: string, jobs: i
if pushErr != 0: if pushErr != 0:
errorQuit "failed to push build to cache" errorQuit "failed to push build to cache"
#[
- name: Build
run: >
nix run .
--
build
"$(nix run . -- output --host,=othalan,algiz,mannaz,naudiz --flake .)"
--flake .
--debug
--
--keep-going
--no-link
- run: git show origin/flake-lock:flake.lock > updated.lock
- name: Pre-build oizys
run: nix build . --reference-lock-file updated.lock
- name: Build Updated
run: >
nix run .
--
build
"$(nix run . -- output --host,=othalan,algiz,mannaz,naudiz --flake .)"
--flake .
--debug
--
--keep-going
--no-link
--reference-lock-file updated.lock
- run: |
for host in othalan algiz mannaz naudiz; do
for rev in current updated; do
args="\"$(nix run . -- output --host $host)\" --out-link \"${host}-${rev}\""
[[ "$rev" == "updated" ]] && args="$args --reference-lock-file updated.lock"
nix build $args
done
done
]#
proc getUpdatedLockFile() =
info "getting updated flake.lock as updated.lock"
let res = runCmdCapt("git --no-pager show origin/flake-lock:flake.lock")
if res.exitCode != 0:
fatalQuit "failed to fetch updated lock file using git"
writeFile("updated.lock", res.stdout)
# probably duplicating logic above ¯\_(ツ)_/¯
proc buildSystem(host: string, rest: seq[string]) =
var cmd = nixCommand("build")
cmd.addArg nixosConfigAttr(host)
cmd.addArgs rest
let code = runCmd cmd
if code != 0:
fatalQuit "build failed"
proc ciUpdate*(rest: seq[string]) =
for host in getHosts():
info "building " & host.bb("bold")
buildSystem(
host,
@["--out-link", host & "-current", "--quiet"] & rest
)
getUpdatedLockFile()
for host in getHosts():
info "building updated " & host.bb("bold")
buildSystem(
host,
@["--out-link", host & "-updated", "--quiet", "--reference-lock-file", "updated.lock"] & rest
)

View file

@ -3,10 +3,10 @@
## oizys ## oizys
- [ ] write a flake template that includes the systems boilerplate - [ ] write a flake template that includes the systems boilerplate
- [ ] get the running action url after `oizys ci {workflow}.yml`
## software ## software
- [ ] why is my update ci always building llm and rofi?
- [ ] include langservers for enabled languages? - [ ] include langservers for enabled languages?
<!--[tracking issue](https://github.com/wez/wezterm/issues/5990)--> <!--[tracking issue](https://github.com/wez/wezterm/issues/5990)-->
- [ ] ~wezterm is broken...something to do with fonts?~ using ghostty - [ ] ~wezterm is broken...something to do with fonts?~ using ghostty