mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 10:10:45 -06:00
make use of go embed
This commit is contained in:
parent
8f8c551503
commit
a03cbee7ac
3 changed files with 45 additions and 33 deletions
21
pkgs/oizys/internal/oizys/ignored.txt
Normal file
21
pkgs/oizys/internal/oizys/ignored.txt
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
ld-library-path
|
||||||
|
builder.pl
|
||||||
|
profile
|
||||||
|
system-path
|
||||||
|
nixos-help
|
||||||
|
nixos-install
|
||||||
|
nixos-version
|
||||||
|
nixos-manual-html
|
||||||
|
nixos-rebuild
|
||||||
|
nixos-configuration-reference-manpage
|
||||||
|
nixos-generate-config
|
||||||
|
nixos-enter
|
||||||
|
nixos-container
|
||||||
|
nixos-build-vms
|
||||||
|
nixos-wsl-version
|
||||||
|
nixos-wsl-welcome-message
|
||||||
|
nixos-wsl-welcome
|
||||||
|
restic-gdrive
|
||||||
|
gitea
|
||||||
|
lock
|
||||||
|
code
|
|
@ -255,6 +255,12 @@ func splitDrv(drv string) (string, string) {
|
||||||
return drvName, hash
|
return drvName, hash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const tableTmpl = `# Building Derivations
|
||||||
|
| derivation | hash |
|
||||||
|
|---|---|
|
||||||
|
%s
|
||||||
|
`
|
||||||
|
|
||||||
func writeDervationsToStepSummary(drvs []string) {
|
func writeDervationsToStepSummary(drvs []string) {
|
||||||
tableRows := make([]string, len(drvs))
|
tableRows := make([]string, len(drvs))
|
||||||
for i, drv := range drvs {
|
for i, drv := range drvs {
|
||||||
|
@ -264,16 +270,7 @@ func writeDervationsToStepSummary(drvs []string) {
|
||||||
name, hash,
|
name, hash,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
o.writeToGithubStepSummary(fmt.Sprintf(tableTmpl, strings.Join(tableRows, "\n")))
|
||||||
o.writeToGithubStepSummary(
|
|
||||||
fmt.Sprintf(`# Building Derivations
|
|
||||||
| derivation | hash |
|
|
||||||
|---|---|
|
|
||||||
%s
|
|
||||||
`,
|
|
||||||
strings.Join(tableRows, "\n"),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NixBuild(minimal bool, rest ...string) {
|
func NixBuild(minimal bool, rest ...string) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package oizys
|
package oizys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -12,22 +13,21 @@ import (
|
||||||
"github.com/charmbracelet/log"
|
"github.com/charmbracelet/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ignoredMap = stringSliceToMap(
|
//go:embed ignored.txt
|
||||||
[]string{
|
var ignoredList string
|
||||||
// nix
|
var ignoredMap = stringToMap(ignoredList)
|
||||||
"ld-library-path", "builder.pl", "profile", "system-path",
|
|
||||||
// nixos
|
func stringToMap(s string) map[string]struct{} {
|
||||||
"nixos-help",
|
return stringSliceToMap(strings.Split(s, "\n"))
|
||||||
"nixos-install", "nixos-version",
|
}
|
||||||
"nixos-manual-html", "nixos-rebuild",
|
|
||||||
"nixos-configuration-reference-manpage",
|
func stringSliceToMap(slice []string) map[string]struct{} {
|
||||||
"nixos-generate-config", "nixos-enter",
|
hashMap := make(map[string]struct{}, len(slice))
|
||||||
"nixos-container", "nixos-build-vms",
|
for _, s := range slice {
|
||||||
"nixos-wsl-version", "nixos-wsl-welcome-message", "nixos-wsl-welcome",
|
hashMap[s] = struct{}{}
|
||||||
// trivial packages
|
}
|
||||||
"restic-gdrive", "gitea", "lock", "code",
|
return hashMap
|
||||||
},
|
}
|
||||||
)
|
|
||||||
|
|
||||||
type Derivation struct {
|
type Derivation struct {
|
||||||
InputDrvs map[string]interface{}
|
InputDrvs map[string]interface{}
|
||||||
|
@ -72,13 +72,7 @@ func drvNotIgnored(drv string) bool {
|
||||||
return !ok
|
return !ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func stringSliceToMap(slice []string) map[string]struct{} {
|
|
||||||
hashMap := make(map[string]struct{}, len(slice))
|
|
||||||
for _, s := range slice {
|
|
||||||
hashMap[s] = struct{}{}
|
|
||||||
}
|
|
||||||
return hashMap
|
|
||||||
}
|
|
||||||
|
|
||||||
func drvsToInputs(derivation map[string]Derivation) []string {
|
func drvsToInputs(derivation map[string]Derivation) []string {
|
||||||
var drvs []string
|
var drvs []string
|
||||||
|
|
Loading…
Reference in a new issue