mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-11-05 01:53:15 -06:00
add support for attic
This commit is contained in:
parent
718b2d6f75
commit
6a42bc97aa
5 changed files with 49 additions and 25 deletions
|
@ -49,12 +49,14 @@
|
||||||
|
|
||||||
nixConfig = {
|
nixConfig = {
|
||||||
extra-substituters = [
|
extra-substituters = [
|
||||||
|
"https://attic.dayl.in/oizys"
|
||||||
"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.lix.systems"
|
# "https://cache.lix.systems"
|
||||||
];
|
];
|
||||||
extra-trusted-public-keys = [
|
extra-trusted-public-keys = [
|
||||||
|
"oizys:DSw3mwVMM/Y+PXSVpkDlU5dLwlORuiJRGPkwr5INSMc="
|
||||||
"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="
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
graphviz
|
graphviz
|
||||||
typst
|
typst
|
||||||
charm-freeze
|
charm-freeze
|
||||||
|
attic-client
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
## nix begat oizys
|
## nix begat oizys
|
||||||
import std/[os, tables, sequtils, strformat, strutils]
|
import std/[os, osproc, tables, sequtils, strformat, strutils]
|
||||||
import hwylterm, hwylterm/[cligen, logging]
|
import hwylterm, hwylterm/[cligen, logging]
|
||||||
import oizys/[context, github, nix, overlay, logging]
|
import oizys/[context, github, nix, overlay, logging]
|
||||||
|
|
||||||
|
@ -53,9 +53,9 @@ overlay:
|
||||||
## nix build
|
## nix build
|
||||||
nixBuild(minimal, rest)
|
nixBuild(minimal, rest)
|
||||||
|
|
||||||
proc cache(minimal: bool = false, name: string = "daylin") =
|
proc cache(name: string = "oizys", service: string = "attic", jobs: int = countProcessors()) =
|
||||||
## build and push to cachix
|
## build and push store paths
|
||||||
nixBuildWithCache(minimal, name, rest)
|
nixBuildWithCache(name, rest, service, jobs)
|
||||||
|
|
||||||
proc osCmd() =
|
proc osCmd() =
|
||||||
## nixos-rebuild
|
## nixos-rebuild
|
||||||
|
@ -97,7 +97,8 @@ when isMainModule:
|
||||||
"ref" : "git ref/branch/tag to trigger workflow on"
|
"ref" : "git ref/branch/tag to trigger workflow on"
|
||||||
}
|
}
|
||||||
cacheHelp = //{
|
cacheHelp = //{
|
||||||
"name" : "name of cachix binary cache"
|
"name" : "name of cachix binary cache",
|
||||||
|
"jobs" : "jobs when pushing paths"
|
||||||
} // sharedHelp
|
} // sharedHelp
|
||||||
let
|
let
|
||||||
osUsage = $bb("$command [[subcmd] $args\n$doc[bold]Options[/]:\n$options")
|
osUsage = $bb("$command [[subcmd] $args\n$doc[bold]Options[/]:\n$options")
|
||||||
|
|
|
@ -9,7 +9,7 @@ import hwylterm
|
||||||
func addArgs*(cmd: var string, args: openArray[string]) =
|
func addArgs*(cmd: var string, args: openArray[string]) =
|
||||||
cmd &= " " & args.join(" ")
|
cmd &= " " & args.join(" ")
|
||||||
|
|
||||||
func addArg*(cmd: var string, arg: string) =
|
func addArg*(cmd: var string, arg: string ) =
|
||||||
cmd &= " " & arg
|
cmd &= " " & arg
|
||||||
|
|
||||||
proc runCmd*(cmd: string): int =
|
proc runCmd*(cmd: string): int =
|
||||||
|
|
|
@ -193,6 +193,7 @@ proc writeDervationsToStepSummary(drvs: seq[string]) =
|
||||||
let output = open(summaryFilePath,fmAppend)
|
let output = open(summaryFilePath,fmAppend)
|
||||||
output.writeLine("| derivation | hash |\n|---|---|")
|
output.writeLine("| derivation | hash |\n|---|---|")
|
||||||
output.writeLine(rows.join("\n"))
|
output.writeLine(rows.join("\n"))
|
||||||
|
close output
|
||||||
|
|
||||||
proc nixBuild*(minimal: bool, rest: seq[string]) =
|
proc nixBuild*(minimal: bool, rest: seq[string]) =
|
||||||
var cmd = nixCommand("build")
|
var cmd = nixCommand("build")
|
||||||
|
@ -233,23 +234,42 @@ proc nixBuildHostDry*(minimal: bool, rest: seq[string]) =
|
||||||
let output = parseDryRunOutput err
|
let output = parseDryRunOutput err
|
||||||
display output
|
display output
|
||||||
|
|
||||||
proc nixBuildWithCache*(minimal: bool, name: string, rest:seq[string]) =
|
|
||||||
if findExe("cachix") == "": fatalQuit "is cachix installed?"
|
proc nixBuildWithCache*(name: string, rest:seq[string], service: string, jobs: int) =
|
||||||
info bbfmt"building and pushing to cache: [b]{name}"
|
## build individual derivations not cached and push to cache
|
||||||
var cmd = "cachix"
|
if findExe(service) == "": fatalQuit fmt"is {service} installed?"
|
||||||
cmd.addArgs ["watch-exec","--"]
|
info bbfmt"building and pushing to cache: [b]{name}"
|
||||||
cmd.addArg "nix build"
|
debug "determining missing cache hits"
|
||||||
if minimal:
|
let drvs = systemPathDrvsToBuild()
|
||||||
debug "populating args with derivations not built/cached"
|
if drvs.len == 0:
|
||||||
let drvs = systemPathDrvsToBuild()
|
info "nothing to build"
|
||||||
if drvs.len == 0:
|
quit "exiting...", QuitSuccess
|
||||||
info "nothing to build"
|
|
||||||
quit "exiting...", QuitSuccess
|
for drv in drvs:
|
||||||
cmd.addArgs drvs
|
var cmd = "nix build"
|
||||||
cmd.addArg "--no-link"
|
cmd.addArg drv
|
||||||
else:
|
cmd.addArgs rest
|
||||||
cmd.addArgs nixosConfigAttrs()
|
let buildErr = runCmd(cmd)
|
||||||
cmd.addArgs rest
|
if buildErr != 0:
|
||||||
let err = runCmd(cmd)
|
error "failed to build: " & drv
|
||||||
quit err
|
continue
|
||||||
|
|
||||||
|
let results = collect(
|
||||||
|
for k, p in walkDir(".", relative = true):
|
||||||
|
if k in { pcLinkToDir, pcLinkToFile} and p.startsWith("result"):
|
||||||
|
p
|
||||||
|
)
|
||||||
|
|
||||||
|
cmd = service
|
||||||
|
cmd.addArg "push"
|
||||||
|
cmd.addArg name
|
||||||
|
cmd.addArg "--jobs"
|
||||||
|
cmd.addArg $jobs
|
||||||
|
cmd.addArgs results
|
||||||
|
let pushErr = runCmd(cmd)
|
||||||
|
if pushErr != 0:
|
||||||
|
errorQuit "failed to push build to cache"
|
||||||
|
|
||||||
|
for p in results:
|
||||||
|
removeFile p
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue