Compare commits

..

No commits in common. "2865ec8264f841b9480cf35533fbc36dac6983ad" and "95281a775329b6f36be0b641d252508fef7615c7" have entirely different histories.

6 changed files with 26 additions and 73 deletions

View file

@ -101,7 +101,7 @@ jobs:
- run: | - run: |
echo "# System Diff" >> $GITHUB_STEP_SUMMARY echo "# System Diff" >> $GITHUB_STEP_SUMMARY
diff=$(nix run "nixpkgs#nvd" ./current ./updated) diff=$(nix store diff-closures ./current ./updated)
echo "$diff" echo "$diff"
echo "$diff" >> summary.md echo "$diff" >> summary.md
echo "$diff" | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' >> $GITHUB_STEP_SUMMARY echo "$diff" | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' >> $GITHUB_STEP_SUMMARY

View file

@ -15,30 +15,22 @@ See below for the currently maintained hosts.
<th>system</th> <th>system</th>
</tr> </tr>
<tr> <tr>
<td> <td><img src="https://upload.wikimedia.org/wikipedia/commons/7/70/Runic_letter_othalan.svg"></td>
<img src="https://upload.wikimedia.org/wikipedia/commons/1/16/Runic_letter_othalan.png" height="100">
</td>
<td>othalan</td> <td>othalan</td>
<td>Thinkpad Carbon X1 Gen 9</td> <td>Thinkpad Carbon X1 Gen 9</td>
</tr> </tr>
<tr> <tr>
<td> <td><img src="https://upload.wikimedia.org/wikipedia/commons/d/df/Runic_letter_algiz.svg"></td>
<img src="https://upload.wikimedia.org/wikipedia/commons/1/14/Runic_letter_algiz.png" height="100">
</td>
<td>algiz</td> <td>algiz</td>
<td>Hetzner VPS hosting forgejo, soft-serve & gts</td> <td>Hetzner VPS hosting forgejo, soft-serve & gts</td>
</tr> </tr>
<tr> <tr>
<td> <td><img src="https://upload.wikimedia.org/wikipedia/commons/5/57/Runic_letter_mannaz.svg"></td>
<img src="https://upload.wikimedia.org/wikipedia/commons/0/0c/Runic_letter_mannaz.png" height="100">
</td>
<td>mannaz</td> <td>mannaz</td>
<td>Custom AMD Tower with Nvidia 1050ti</td> <td>Custom AMD Tower with Nvidia 1050ti</td>
</tr> </tr>
<tr> <tr>
<td> <td><img src="https://upload.wikimedia.org/wikipedia/commons/3/3f/Runic_letter_naudiz.svg"></td>
<img src="https://upload.wikimedia.org/wikipedia/commons/b/b9/Runic_letter_naudiz.png" height="100">
</td>
<td>naudiz</td> <td>naudiz</td>
<td>Nixos-WSL for those times I'm trapped on windows</td> <td>Nixos-WSL for those times I'm trapped on windows</td>
</tr> </tr>

View file

@ -1,10 +1,8 @@
package cmd package cmd
import ( import (
"oizys/internal/github" "oizys/internal/oizys"
"os"
"github.com/charmbracelet/log"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -14,28 +12,11 @@ var ciCmd = &cobra.Command{
Use: "ci", Use: "ci",
Short: "offload build to GHA", Short: "offload build to GHA",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
inputs := make(map[string]interface{}) oizys.CI(args...)
if includeLock {
log.Debug("including lock file in inputs")
inputs["lockFile"] = readLockFile()
}
github.CreateDispatch("build.yml", ref, inputs)
}, },
} }
var includeLock bool
var ref string
func init() { func init() {
rootCmd.AddCommand(ciCmd) rootCmd.AddCommand(ciCmd)
ciCmd.Flags().BoolVar(&includeLock, "lockfile", false, "include lock file in inputs")
ciCmd.Flags().StringVar(&ref, "ref", "main", "git ref to trigger workflow on")
}
func readLockFile() string {
dat, err := os.ReadFile("flake.lock")
if err != nil {
log.Fatal("failed to read flake.lock", "err", err)
}
return string(dat)
} }

View file

@ -16,29 +16,24 @@ var updateCmd = &cobra.Command{
Short: "update and run nixos rebuild", Short: "update and run nixos rebuild",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
run := github.GetLastUpdateRun() run := github.GetLastUpdateRun()
if preview {
md, err := github.GetUpateSummary(run.GetID()) md, err := github.GetUpateSummary(run.GetID())
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
fmt.Println(md) fmt.Println(md)
if preview { if !ui.Confirm("proceed with system update?") {
os.Exit(0) os.Exit(0)
} }
if !yes && !ui.Confirm("proceed with system update?") {
os.Exit(0)
} }
oizys.UpdateRepo() oizys.UpdateRepo()
oizys.NixosRebuild("switch") oizys.NixosRebuild("switch")
}, },
} }
var ( var preview bool
preview bool
yes bool
)
func init() { func init() {
rootCmd.AddCommand(updateCmd) rootCmd.AddCommand(updateCmd)
updateCmd.Flags().BoolVar(&preview, "preview", false, "confirm nix store diff") updateCmd.Flags().BoolVar(&preview, "preview", false, "confirm nix store diff")
updateCmd.Flags().BoolVar(&yes, "yes", false, "reply yes to all confirm prompts")
} }

View file

@ -152,27 +152,3 @@ func ReadMarkdownFromZip(zipData []byte, fileName string) (string, error) {
// Return the markdown content as string // Return the markdown content as string
return string(content), nil return string(content), nil
} }
// func CI(rest ...string) {
// args := []string{
// "workflow", "run", "build.yml",
// "-F", fmt.Sprintf("hosts=%s", o.host),
// }
// args = append(args, rest...)
// cmd := exec.Command("gh", args...)
// e.ExitWithCommand(cmd)
// }
func CreateDispatch(workflowFileName string, ref string, inputs map[string]interface{}) {
event := github.CreateWorkflowDispatchEventRequest{Ref: ref, Inputs: inputs}
_, err := client.Actions.CreateWorkflowDispatchEventByFileName(
context.Background(),
"daylinmorgan",
"oizys",
workflowFileName,
event,
)
if err != nil {
log.Fatal("failed to dispatch event", "filename", workflowFileName, "err", err)
}
}

View file

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"io/fs" "io/fs"
"oizys/internal/git" "oizys/internal/git"
// "oizys/internal/github"
"oizys/internal/ui" "oizys/internal/ui"
"os" "os"
"os/exec" "os/exec"
@ -317,6 +316,16 @@ func CacheBuild(rest ...string) {
e.ExitWithCommand(cmd) e.ExitWithCommand(cmd)
} }
func CI(rest ...string) {
args := []string{
"workflow", "run", "build.yml",
"-F", fmt.Sprintf("hosts=%s", o.host),
}
args = append(args, rest...)
cmd := exec.Command("gh", args...)
e.ExitWithCommand(cmd)
}
func UpdateRepo() { func UpdateRepo() {
log.Info("rebasing HEAD on origin/flake-lock") log.Info("rebasing HEAD on origin/flake-lock")
o.repo.Fetch() o.repo.Fetch()