cmd/nixbuild: instantiated deduplicate stat
Use case for this came up while writing tests.
This commit is contained in:
parent
69c6128ff5
commit
8f799c8d95
@ -118,6 +118,32 @@ func main() {
|
||||
}).
|
||||
Flag(&resolveFlagOut, "o", command.StringFlag("store-paths"), "Path to write collected store paths")
|
||||
|
||||
c.Command("stat", "Compute the instantiated deduplication stat of an installable", func(args []string) error {
|
||||
var installable string
|
||||
if err := formatInstallable("instantiated", &installable, flagNixOS, args); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Println("initialising evaluator")
|
||||
var collective []string
|
||||
if eval, err := nixbuild.NewInstantiatedEvaluator(ctx, installable); err != nil {
|
||||
return commandHandlerError(fmt.Sprintf("cannot initialise evaluator: %v", err))
|
||||
} else {
|
||||
log.Println("collecting paths")
|
||||
collective = slices.Collect(eval.Instantiated())
|
||||
if err := eval.Err(); err != nil {
|
||||
return commandHandlerError(fmt.Sprintf("cannot collect: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
l := len(collective)
|
||||
slices.Sort(collective)
|
||||
collective = slices.Compact(collective)
|
||||
log.Printf("`%s`: %d paths instantiated, %d duplicate, dedup %.1f%%",
|
||||
installable, l, l-len(collective), float64(l-len(collective))/float64(l)*100)
|
||||
return nil
|
||||
})
|
||||
|
||||
c.Command("instantiated", "Evaluate an installable and output all derivations instantiated during evaluation", func(args []string) error {
|
||||
var installable string
|
||||
if err := formatInstallable("instantiated", &installable, flagNixOS, args); err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user