depot/go/nix/nixstore/nixstore.go

26 lines
446 B
Go

package nixstore
import (
"fmt"
"git.lukegb.com/lukegb/depot/go/nix/nar/narinfo"
)
type Store interface {
NARInfo(storePath string) (*narinfo.NarInfo, error)
Close() error
}
func Open() (Store, error) {
s, errDmn := OpenDaemon(DaemonSock)
if errDmn == nil {
return s, nil
}
s2, errDB := OpenDB(DefaultStoreDB)
if errDB == nil {
return s2, nil
}
return nil, fmt.Errorf("failed to open daemon or DB: %v / %v", errDmn, errDB)
}