Compare commits

...

3 commits

Author SHA1 Message Date
github-actions[bot]
d8c067a48f flake.lock: Update
Flake lock file updates:

• Updated input 'hyprland':
    'git+https://github.com/hyprwm/Hyprland/?ref=refs/heads/main&rev=e728e56cbc6af0a9be1276b2cf8e019a894016e7&submodules=1' (2024-07-11)
  → 'git+https://github.com/hyprwm/Hyprland/?ref=refs/heads/main&rev=bc6b0880dda2607a80f000c134f573c970452a0f&submodules=1' (2024-07-13)
• Updated input 'lix':
    '4b109ec1a8.tar.gz?narHash=sha256-vq9CLDvqSSvH4L7YhDa0ihTOrAry4jntKiuoNb5n98M%3D' (2024-07-11)
  → 'a8f443d960.tar.gz?narHash=sha256-YZ7043PFS6LalHAyGeO7qRLeZIevwjHRbbMkpixjwhM%3D' (2024-07-12)
• Updated input 'nix-index-database':
    'github:nix-community/nix-index-database/685e40e1348007d2cf76747a201bab43d86b38cb?narHash=sha256-X9pEvvHTVWJphhbUYqXvlLedOndNqGB7rvhSvL2CIgU%3D' (2024-07-07)
  → 'github:nix-community/nix-index-database/5fe5b0cdf1268112dc96319388819b46dc051ef4?narHash=sha256-fW6e27L6qY6s%2BTxInwrS2EXZZfhMAlaNqT0sWS49qMA%3D' (2024-07-14)
• Updated input 'nixos-wsl':
    'github:nix-community/NixOS-WSL/30ebd0beb2ed26e09bcd245d757504029f807cce?narHash=sha256-0vHxVNWTql555MZLb2kngrcjfNtsJKoYdyUivTibgnc%3D' (2024-07-08)
  → 'github:nix-community/NixOS-WSL/371b5076d718f7f637d3959d0203061f06af1263?narHash=sha256-U3IqoGmIzBKEJ0ihRQ10GRRtdoDBI6Oxl6aiGbUA59A%3D' (2024-07-12)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/212defe037698e18fc9521dfe451779a8979844c?narHash=sha256-nPhbeFdyN8yn%2BEXmnPcBWisoypndtQbNIhSKmAinv3E%3D' (2024-07-11)
  → 'github:nixos/nixpkgs/b729601a9e6c459fd8884dea513af143111bed54?narHash=sha256-1Al1qDC8Q/s4viPq4ln8jfHWZxYl%2BNb49dNFISFpqBY%3D' (2024-07-13)
• Updated input 'nixpkgs-wayland':
    'github:nix-community/nixpkgs-wayland/8f132445454c6b9f0b21952953885007b961310a?narHash=sha256-r0a7rtlx5GzJ57izpq58B30sAzSIH2V/ctwIsMV51rY%3D' (2024-07-11)
  → 'github:nix-community/nixpkgs-wayland/09a28c6e377ae40c67d79f0a98c5bff3c59457b8?narHash=sha256-7tz2witA6mIxX3250WyhD8rvXQxlSzQFEDdVLYvzEU8%3D' (2024-07-14)
• Updated input 'nixpkgs-wayland/nix-eval-jobs':
    'github:nix-community/nix-eval-jobs/9bed665aa71907dcacc8ae6dba1a3055a9ff2de7?narHash=sha256-qbtex5uSOUQnK4797JztyTQWlnlhEsE8x5g5qs5DgvQ%3D' (2024-06-24)
  → 'github:nix-community/nix-eval-jobs/c132534bc68eb48479a59a3116ee7ce0f16ce12b?narHash=sha256-QHajV5BjfaMWbiOAJ/MGH%2BexXo%2BCjzUpkxxEtz0ZZ2k%3D' (2024-07-14)
• Updated input 'nixpkgs-wayland/nix-eval-jobs/flake-parts':
    'github:hercules-ci/flake-parts/9126214d0a59633752a136528f5f3b9aa8565b7d?narHash=sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm%2BGpZNw%3D' (2024-04-01)
  → 'github:hercules-ci/flake-parts/9227223f6d922fee3c7b190b2cc238a99527bbb7?narHash=sha256-pQMhCCHyQGRzdfAkdJ4cIWiw%2BJNuWsTX7f0ZYSyz0VY%3D' (2024-07-03)
• Updated input 'nixpkgs-wayland/nix-eval-jobs/nix-github-actions':
    'github:nix-community/nix-github-actions/5163432afc817cf8bd1f031418d1869e4c9d5547?narHash=sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y%3D' (2023-12-29)
  → 'github:nix-community/nix-github-actions/622f829f5fe69310a866c8a6cd07e747c44ef820?narHash=sha256-uPlLYH2S0ACj0IcgaK9Lsf4spmJoGejR9DotXiXSBZQ%3D' (2024-07-04)
• Updated input 'nixpkgs-wayland/nix-eval-jobs/nixpkgs':
    'github:NixOS/nixpkgs/9693852a2070b398ee123a329e68f0dab5526681?narHash=sha256-jHJSUH619zBQ6WdC21fFAlDxHErKVDJ5fpN0Hgx4sjs%3D' (2024-06-22)
  → 'github:NixOS/nixpkgs/8b5a3d5a1d951344d683b442c0739010b80039db?narHash=sha256-po3TZO9kcZwzvkyMJKb0WCzzDtiHWD34XeRaX1lWXp0%3D' (2024-07-12)
• Updated input 'nixpkgs-wayland/nix-eval-jobs/treefmt-nix':
    'github:numtide/treefmt-nix/49dc4a92b02b8e68798abd99184f228243b6e3ac?narHash=sha256-N3QDhoaX%2BpaWXHbEXZapqd1r95mdshxToGowtjtYkGI%3D' (2024-04-01)
  → 'github:numtide/treefmt-nix/b92afa1501ac73f1d745526adc4f89b527595f14?narHash=sha256-VZK73b5hG5bSeAn97TTcnPjXUXtV7j/AtS4KN8ggCS0%3D' (2024-07-14)
• Updated input 'nixpkgs-wayland/nixpkgs':
    'github:nixos/nixpkgs/feb2849fdeb70028c70d73b848214b00d324a497?narHash=sha256-ZgnNHuKV6h2%2BfQ5LuqnUaqZey1Lqqt5dTUAiAnqH0QQ%3D' (2024-07-09)
  → 'github:nixos/nixpkgs/7e7c39ea35c5cdd002cd4588b03a3fb9ece6fad9?narHash=sha256-EYekUHJE2gxeo2pM/zM9Wlqw1Uw2XTJXOSAO79ksc4Y%3D' (2024-07-12)
• Updated input 'roc':
    'github:roc-lang/roc/b65e65f0a416e40ef4112535b82b38f2e2455834?narHash=sha256-HRwuZ9o0E6UwCkIVeFHdHI0/5pmsNqbwtqTIj9bJNWo%3D' (2024-07-10)
  → 'github:roc-lang/roc/0284248320e1a72bb5823bd7005c6521c1c70857?narHash=sha256-P9yElKsIEk6rp2AK3wf2vQQIlPh%2BBQQkvE%2B9BKg5BWs%3D' (2024-07-14)
• Updated input 'stable':
    'github:nixos/nixpkgs/7144d6241f02d171d25fba3edeaf15e0f2592105?narHash=sha256-gvFhEf5nszouwLAkT9nWsDzocUTqLWHuL%2B%2BdvNjMp9I%3D' (2024-07-02)
  → 'github:nixos/nixpkgs/205fd4226592cc83fd4c0885a3e4c9c400efabb5?narHash=sha256-zwVvxrdIzralnSbcpghA92tWu2DV2lwv89xZc8MTrbg%3D' (2024-07-09)
• Updated input 'zig2nix':
    'github:Cloudef/zig2nix/141b1b633b585e52388620b84c4d2f438b92a45a?narHash=sha256-zhxs/o9oNkB9ZszRsseG6qYqfKz29314FE7mdqcAGrc%3D' (2024-07-12)
  → 'github:Cloudef/zig2nix/b6655dcc31af1b20d4e112306c46c110ce5d967d?narHash=sha256-L6y1TI4caiJwKQBiBhU748F5Cv6563el0QOh6Zapk3s%3D' (2024-07-14)
• Updated input 'zls':
    'github:zigtools/zls/b8dd9cbbcc7591159f28eb41c21315f5ef5ca995?narHash=sha256-uPe4sqNB661tIi4U6YvHR9BpN8ozIcmxUJxcxI9tD1o%3D' (2024-07-11)
  → 'github:zigtools/zls/ef50085f7b7136c1e1b26438141bb005743f38c1?narHash=sha256-JeQuI0LLjCdI1zgHQu9n0tA3CEz8EZ0qHUFAYqWURA0%3D' (2024-07-12)
2024-07-14 04:59:43 +00:00
23f8ca311c
actually force push 2024-07-13 23:58:01 -05:00
13876be966
oizys refactoring 2024-07-12 10:23:25 -05:00
7 changed files with 134 additions and 89 deletions

View file

@ -56,7 +56,7 @@ jobs:
--print-build-logs
- name: Commit Updates
run: git push --set-upstream --force-with-lease origin flake-lock
run: git push --set-upstream --force origin flake-lock
build-full:
needs: build-minimal

View file

@ -90,11 +90,11 @@
]
},
"locked": {
"lastModified": 1712014858,
"narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=",
"lastModified": 1719994518,
"narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "9126214d0a59633752a136528f5f3b9aa8565b7d",
"rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7",
"type": "github"
},
"original": {
@ -305,11 +305,11 @@
"xdph": "xdph"
},
"locked": {
"lastModified": 1720731503,
"narHash": "sha256-Qlm0IRnOrI64RW/SEvW9rA1ytVvPS1CsVvRataNvStI=",
"lastModified": 1720896272,
"narHash": "sha256-zo1lDMsxjEyko/P+KfCLNYZrCAWQOrX90/J31nqzpy4=",
"ref": "refs/heads/main",
"rev": "e728e56cbc6af0a9be1276b2cf8e019a894016e7",
"revCount": 4917,
"rev": "bc6b0880dda2607a80f000c134f573c970452a0f",
"revCount": 4925,
"submodules": true,
"type": "git",
"url": "https://github.com/hyprwm/Hyprland/"
@ -498,11 +498,11 @@
"lix": {
"flake": false,
"locked": {
"lastModified": 1720733512,
"narHash": "sha256-vq9CLDvqSSvH4L7YhDa0ihTOrAry4jntKiuoNb5n98M=",
"rev": "4b109ec1a8fc4550150f56f0f46f2f41d844bda8",
"lastModified": 1720825173,
"narHash": "sha256-YZ7043PFS6LalHAyGeO7qRLeZIevwjHRbbMkpixjwhM=",
"rev": "a8f443d96011c11ad726c2a28a37752bd56c12cc",
"type": "tarball",
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/4b109ec1a8fc4550150f56f0f46f2f41d844bda8.tar.gz"
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/a8f443d96011c11ad726c2a28a37752bd56c12cc.tar.gz"
},
"original": {
"type": "tarball",
@ -540,11 +540,11 @@
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1719247822,
"narHash": "sha256-qbtex5uSOUQnK4797JztyTQWlnlhEsE8x5g5qs5DgvQ=",
"lastModified": 1720931326,
"narHash": "sha256-QHajV5BjfaMWbiOAJ/MGH+exXo+CjzUpkxxEtz0ZZ2k=",
"owner": "nix-community",
"repo": "nix-eval-jobs",
"rev": "9bed665aa71907dcacc8ae6dba1a3055a9ff2de7",
"rev": "c132534bc68eb48479a59a3116ee7ce0f16ce12b",
"type": "github"
},
"original": {
@ -562,11 +562,11 @@
]
},
"locked": {
"lastModified": 1703863825,
"narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=",
"lastModified": 1720066371,
"narHash": "sha256-uPlLYH2S0ACj0IcgaK9Lsf4spmJoGejR9DotXiXSBZQ=",
"owner": "nix-community",
"repo": "nix-github-actions",
"rev": "5163432afc817cf8bd1f031418d1869e4c9d5547",
"rev": "622f829f5fe69310a866c8a6cd07e747c44ef820",
"type": "github"
},
"original": {
@ -582,11 +582,11 @@
]
},
"locked": {
"lastModified": 1720334033,
"narHash": "sha256-X9pEvvHTVWJphhbUYqXvlLedOndNqGB7rvhSvL2CIgU=",
"lastModified": 1720926593,
"narHash": "sha256-fW6e27L6qY6s+TxInwrS2EXZZfhMAlaNqT0sWS49qMA=",
"owner": "nix-community",
"repo": "nix-index-database",
"rev": "685e40e1348007d2cf76747a201bab43d86b38cb",
"rev": "5fe5b0cdf1268112dc96319388819b46dc051ef4",
"type": "github"
},
"original": {
@ -627,11 +627,11 @@
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1720428387,
"narHash": "sha256-0vHxVNWTql555MZLb2kngrcjfNtsJKoYdyUivTibgnc=",
"lastModified": 1720787015,
"narHash": "sha256-U3IqoGmIzBKEJ0ihRQ10GRRtdoDBI6Oxl6aiGbUA59A=",
"owner": "nix-community",
"repo": "NixOS-WSL",
"rev": "30ebd0beb2ed26e09bcd245d757504029f807cce",
"rev": "371b5076d718f7f637d3959d0203061f06af1263",
"type": "github"
},
"original": {
@ -679,11 +679,11 @@
"nixpkgs": "nixpkgs_7"
},
"locked": {
"lastModified": 1720662315,
"narHash": "sha256-r0a7rtlx5GzJ57izpq58B30sAzSIH2V/ctwIsMV51rY=",
"lastModified": 1720932034,
"narHash": "sha256-7tz2witA6mIxX3250WyhD8rvXQxlSzQFEDdVLYvzEU8=",
"owner": "nix-community",
"repo": "nixpkgs-wayland",
"rev": "8f132445454c6b9f0b21952953885007b961310a",
"rev": "09a28c6e377ae40c67d79f0a98c5bff3c59457b8",
"type": "github"
},
"original": {
@ -742,11 +742,11 @@
},
"nixpkgs_5": {
"locked": {
"lastModified": 1720657034,
"narHash": "sha256-nPhbeFdyN8yn+EXmnPcBWisoypndtQbNIhSKmAinv3E=",
"lastModified": 1720875497,
"narHash": "sha256-1Al1qDC8Q/s4viPq4ln8jfHWZxYl+Nb49dNFISFpqBY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "212defe037698e18fc9521dfe451779a8979844c",
"rev": "b729601a9e6c459fd8884dea513af143111bed54",
"type": "github"
},
"original": {
@ -758,11 +758,11 @@
},
"nixpkgs_6": {
"locked": {
"lastModified": 1719082008,
"narHash": "sha256-jHJSUH619zBQ6WdC21fFAlDxHErKVDJ5fpN0Hgx4sjs=",
"lastModified": 1720781449,
"narHash": "sha256-po3TZO9kcZwzvkyMJKb0WCzzDtiHWD34XeRaX1lWXp0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9693852a2070b398ee123a329e68f0dab5526681",
"rev": "8b5a3d5a1d951344d683b442c0739010b80039db",
"type": "github"
},
"original": {
@ -774,11 +774,11 @@
},
"nixpkgs_7": {
"locked": {
"lastModified": 1720542800,
"narHash": "sha256-ZgnNHuKV6h2+fQ5LuqnUaqZey1Lqqt5dTUAiAnqH0QQ=",
"lastModified": 1720768451,
"narHash": "sha256-EYekUHJE2gxeo2pM/zM9Wlqw1Uw2XTJXOSAO79ksc4Y=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "feb2849fdeb70028c70d73b848214b00d324a497",
"rev": "7e7c39ea35c5cdd002cd4588b03a3fb9ece6fad9",
"type": "github"
},
"original": {
@ -851,11 +851,11 @@
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1720600679,
"narHash": "sha256-HRwuZ9o0E6UwCkIVeFHdHI0/5pmsNqbwtqTIj9bJNWo=",
"lastModified": 1720924256,
"narHash": "sha256-P9yElKsIEk6rp2AK3wf2vQQIlPh+BQQkvE+9BKg5BWs=",
"owner": "roc-lang",
"repo": "roc",
"rev": "b65e65f0a416e40ef4112535b82b38f2e2455834",
"rev": "0284248320e1a72bb5823bd7005c6521c1c70857",
"type": "github"
},
"original": {
@ -911,11 +911,11 @@
},
"stable": {
"locked": {
"lastModified": 1719957072,
"narHash": "sha256-gvFhEf5nszouwLAkT9nWsDzocUTqLWHuL++dvNjMp9I=",
"lastModified": 1720535198,
"narHash": "sha256-zwVvxrdIzralnSbcpghA92tWu2DV2lwv89xZc8MTrbg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "7144d6241f02d171d25fba3edeaf15e0f2592105",
"rev": "205fd4226592cc83fd4c0885a3e4c9c400efabb5",
"type": "github"
},
"original": {
@ -1054,11 +1054,11 @@
]
},
"locked": {
"lastModified": 1711963903,
"narHash": "sha256-N3QDhoaX+paWXHbEXZapqd1r95mdshxToGowtjtYkGI=",
"lastModified": 1720930114,
"narHash": "sha256-VZK73b5hG5bSeAn97TTcnPjXUXtV7j/AtS4KN8ggCS0=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "49dc4a92b02b8e68798abd99184f228243b6e3ac",
"rev": "b92afa1501ac73f1d745526adc4f89b527595f14",
"type": "github"
},
"original": {
@ -1150,11 +1150,11 @@
]
},
"locked": {
"lastModified": 1720747212,
"narHash": "sha256-zhxs/o9oNkB9ZszRsseG6qYqfKz29314FE7mdqcAGrc=",
"lastModified": 1720920089,
"narHash": "sha256-L6y1TI4caiJwKQBiBhU748F5Cv6563el0QOh6Zapk3s=",
"owner": "Cloudef",
"repo": "zig2nix",
"rev": "141b1b633b585e52388620b84c4d2f438b92a45a",
"rev": "b6655dcc31af1b20d4e112306c46c110ce5d967d",
"type": "github"
},
"original": {
@ -1174,11 +1174,11 @@
"zig-overlay": "zig-overlay"
},
"locked": {
"lastModified": 1720719728,
"narHash": "sha256-uPe4sqNB661tIi4U6YvHR9BpN8ozIcmxUJxcxI9tD1o=",
"lastModified": 1720799773,
"narHash": "sha256-JeQuI0LLjCdI1zgHQu9n0tA3CEz8EZ0qHUFAYqWURA0=",
"owner": "zigtools",
"repo": "zls",
"rev": "b8dd9cbbcc7591159f28eb41c21315f5ef5ca995",
"rev": "ef50085f7b7136c1e1b26438141bb005743f38c1",
"type": "github"
},
"original": {

View file

@ -11,12 +11,12 @@ import (
"github.com/charmbracelet/log"
)
func logCmd(cmd *exec.Cmd) {
func LogCmd(cmd *exec.Cmd) {
log.Debugf("CMD: %s", strings.Join(cmd.Args, " "))
}
func cmdOutputWithSpinner(cmd *exec.Cmd, msg string, stderr bool) (output []byte, err error) {
logCmd(cmd)
func CmdOutputWithSpinner(cmd *exec.Cmd, msg string, stderr bool) (output []byte, err error) {
LogCmd(cmd)
s := startSpinner(msg)
if stderr {
output, err = cmd.CombinedOutput()
@ -38,8 +38,8 @@ func startSpinner(msg string) *spinner.Spinner {
return s
}
func exitWithCommand(cmd *exec.Cmd) {
logCmd(cmd)
func ExitWithCommand(cmd *exec.Cmd) {
LogCmd(cmd)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {

View file

@ -0,0 +1,42 @@
package oizys
import (
"fmt"
"os"
"os/exec"
"github.com/charmbracelet/log"
"oizys/internal/ui"
)
type GitRepo struct {
path string
}
func (g *GitRepo) git(rest ...string) *exec.Cmd {
args := []string{"-C", g.path}
args = append(args, rest...)
cmd := exec.Command("git", args...)
// logCmd(cmd)
return cmd
}
func GitPull(workDir string) {
g := GitRepo{workDir}
cmdOutput, err := g.git("status", "--porcelain").Output()
if err != nil {
log.Fatal(err)
}
if len(cmdOutput) > 0 {
fmt.Println("unstaged commits, cowardly exiting...")
ui.ShowFailedOutput(cmdOutput)
os.Exit(1)
}
cmdOutput, err = g.git("pull").CombinedOutput()
if err != nil {
ui.ShowFailedOutput(cmdOutput)
log.Fatal(err)
}
}

View file

@ -10,8 +10,10 @@ import (
"strings"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/log"
e "oizys/internal/exec"
"oizys/internal/ui"
)
var o *Oizys
@ -129,7 +131,7 @@ func git(rest ...string) *exec.Cmd {
args := []string{"-C", o.flake}
args = append(args, rest...)
cmd := exec.Command("git", args...)
logCmd(cmd)
e.LogCmd(cmd)
return cmd
}
@ -141,18 +143,18 @@ func GitPull() {
if len(cmdOutput) > 0 {
fmt.Println("unstaged commits, cowardly exiting...")
showFailedOutput(cmdOutput)
ui.ShowFailedOutput(cmdOutput)
os.Exit(1)
}
cmdOutput, err = git("pull").CombinedOutput()
if err != nil {
showFailedOutput(cmdOutput)
ui.ShowFailedOutput(cmdOutput)
log.Fatal(err)
}
}
func parseDryRun(buf string) (*packages, *packages) {
func parseDryRun(buf string) (*ui.Packages, *ui.Packages) {
lines := strings.Split(strings.TrimSpace(buf), "\n")
var parts [2][]string
i := 0
@ -173,8 +175,8 @@ func parseDryRun(buf string) (*packages, *packages) {
os.Exit(0)
}
return parsePackages(parts[0], "packages to build"),
parsePackages(parts[1], "packages to fetch")
return ui.ParsePackages(parts[0], "packages to build"),
ui.ParsePackages(parts[1], "packages to fetch")
}
// TODO: Refactor this and above
@ -203,8 +205,8 @@ func parseDryRun2(buf string) ([]string, []string) {
// TODO: refactor to account for --debug and not --verbose?
func showDryRunResult(nixOutput string, verbose bool) {
toBuild, toFetch := parseDryRun(nixOutput)
toFetch.show(o.debug)
toBuild.show(true)
toFetch.Show(o.debug)
toBuild.Show(true)
}
func Dry(verbose bool, minimal bool, rest ...string) {
@ -229,7 +231,7 @@ func Dry(verbose bool, minimal bool, rest ...string) {
lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("6")).Render(o.host),
)
}
result, err := cmdOutputWithSpinner(cmd, spinnerMsg, true)
result, err := e.CmdOutputWithSpinner(cmd, spinnerMsg, true)
if err != nil {
log.Fatal("failed to dry-run nix build", "err", err, "output", string(result))
}
@ -255,7 +257,7 @@ func NixosRebuild(subcmd string, rest ...string) {
cmd.Args = append(cmd.Args, "--print-build-logs")
}
cmd.Args = append(cmd.Args, rest...)
exitWithCommand(cmd)
e.ExitWithCommand(cmd)
}
func NixBuild(nom bool, minimal bool, rest ...string) {
@ -282,7 +284,7 @@ func NixBuild(nom bool, minimal bool, rest ...string) {
cmd.Args = append(cmd.Args, "--log-format", "multiline")
}
cmd.Args = append(cmd.Args, rest...)
exitWithCommand(cmd)
e.ExitWithCommand(cmd)
}
func (o *Oizys) writeToGithubStepSummary(txt string) {
@ -332,12 +334,12 @@ func CacheBuild(rest ...string) {
args = append(args, NixosConfigAttrs()...)
args = append(args, rest...)
cmd := exec.Command("cachix", args...)
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...)
exitWithCommand(cmd)
e.ExitWithCommand(cmd)
}

View file

@ -8,6 +8,7 @@ import (
"strings"
"github.com/charmbracelet/log"
e "oizys/internal/exec"
)
var ignoredMap = stringSliceToMap(
@ -128,7 +129,7 @@ func toBuildNixosConfiguration() []string {
if o.resetCache {
systemCmd.Args = append(systemCmd.Args, "--narinfo-cache-negative-ttl", "0")
}
result, err := cmdOutputWithSpinner(
result, err := e.CmdOutputWithSpinner(
systemCmd,
fmt.Sprintf("running dry build for: %s", strings.Join(NixosConfigAttrs(), " ")),
true,
@ -143,7 +144,7 @@ func toBuildNixosConfiguration() []string {
func evaluateDerivations(drvs ...string) map[string]Derivation {
cmd := exec.Command("nix", "derivation", "show", "-r")
cmd.Args = append(cmd.Args, drvs...)
out, err := cmdOutputWithSpinner(cmd,
out, err := e.CmdOutputWithSpinner(cmd,
fmt.Sprintf("evaluating derivations %s", strings.Join(drvs, " ")),
false)
if err != nil {

View file

@ -1,4 +1,4 @@
package oizys
package ui
import (
"fmt"
@ -11,6 +11,17 @@ import (
"golang.org/x/term"
)
func ShowFailedOutput(buf []byte) {
arrow := lipgloss.
NewStyle().
Bold(true).
Foreground(lipgloss.Color("9")).
Render("->")
for _, line := range strings.Split(strings.TrimSpace(string(buf)), "\n") {
fmt.Println(arrow, line)
}
}
// TODO: seperate parsing and displaying of packages
func terminalSize() (int, int) {
fd := os.Stdout.Fd()
@ -25,13 +36,13 @@ func terminalSize() (int, int) {
return w, h
}
type packages struct {
type Packages struct {
desc string
names []string
pad int
}
func parsePackages(lines []string, desc string) *packages {
func ParsePackages(lines []string, desc string) *Packages {
w, _ := terminalSize()
maxAcceptable := (w / 4) - 1
maxLen := 0
@ -48,7 +59,7 @@ func parsePackages(lines []string, desc string) *packages {
names[i] = name
}
sort.Strings(names)
return &packages{names: names, pad: maxLen + 1, desc: desc}
return &Packages{names: names, pad: maxLen + 1, desc: desc}
}
func ellipsis(s string, maxLen int) string {
@ -62,7 +73,7 @@ func ellipsis(s string, maxLen int) string {
return string(runes[0:maxLen-3]) + "..."
}
func (p *packages) show(verbose bool) {
func (p *Packages) Show(verbose bool) {
p.summary()
if !verbose || (len(p.names) == 0) {
return
@ -81,7 +92,7 @@ func (p *packages) show(verbose bool) {
fmt.Println()
}
func (p *packages) summary() {
func (p *Packages) summary() {
fmt.Printf("%s: %s\n",
p.desc,
lipgloss.NewStyle().
@ -90,14 +101,3 @@ func (p *packages) summary() {
Render(fmt.Sprint(len(p.names))),
)
}
func showFailedOutput(buf []byte) {
arrow := lipgloss.
NewStyle().
Bold(true).
Foreground(lipgloss.Color("9")).
Render("->")
for _, line := range strings.Split(strings.TrimSpace(string(buf)), "\n") {
fmt.Println(arrow, line)
}
}