mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 01:50:44 -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
|
||||
}
|
||||
|
||||
const tableTmpl = `# Building Derivations
|
||||
| derivation | hash |
|
||||
|---|---|
|
||||
%s
|
||||
`
|
||||
|
||||
func writeDervationsToStepSummary(drvs []string) {
|
||||
tableRows := make([]string, len(drvs))
|
||||
for i, drv := range drvs {
|
||||
|
@ -264,16 +270,7 @@ func writeDervationsToStepSummary(drvs []string) {
|
|||
name, hash,
|
||||
)
|
||||
}
|
||||
|
||||
o.writeToGithubStepSummary(
|
||||
fmt.Sprintf(`# Building Derivations
|
||||
| derivation | hash |
|
||||
|---|---|
|
||||
%s
|
||||
`,
|
||||
strings.Join(tableRows, "\n"),
|
||||
),
|
||||
)
|
||||
o.writeToGithubStepSummary(fmt.Sprintf(tableTmpl, strings.Join(tableRows, "\n")))
|
||||
}
|
||||
|
||||
func NixBuild(minimal bool, rest ...string) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package oizys
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -12,22 +13,21 @@ import (
|
|||
"github.com/charmbracelet/log"
|
||||
)
|
||||
|
||||
var ignoredMap = stringSliceToMap(
|
||||
[]string{
|
||||
// nix
|
||||
"ld-library-path", "builder.pl", "profile", "system-path",
|
||||
// nixos
|
||||
"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",
|
||||
// trivial packages
|
||||
"restic-gdrive", "gitea", "lock", "code",
|
||||
},
|
||||
)
|
||||
//go:embed ignored.txt
|
||||
var ignoredList string
|
||||
var ignoredMap = stringToMap(ignoredList)
|
||||
|
||||
func stringToMap(s string) map[string]struct{} {
|
||||
return stringSliceToMap(strings.Split(s, "\n"))
|
||||
}
|
||||
|
||||
func stringSliceToMap(slice []string) map[string]struct{} {
|
||||
hashMap := make(map[string]struct{}, len(slice))
|
||||
for _, s := range slice {
|
||||
hashMap[s] = struct{}{}
|
||||
}
|
||||
return hashMap
|
||||
}
|
||||
|
||||
type Derivation struct {
|
||||
InputDrvs map[string]interface{}
|
||||
|
@ -72,13 +72,7 @@ func drvNotIgnored(drv string) bool {
|
|||
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 {
|
||||
var drvs []string
|
||||
|
|
Loading…
Reference in a new issue