depot/go/nix/nixstore/nixstore.go

27 lines
446 B
Go
Raw Normal View History

2022-10-09 23:49:44 +00:00
package nixstore
import (
"fmt"
2024-11-16 15:30:41 +00:00
"git.lukegb.com/lukegb/depot/go/nix/nar/narinfo"
2022-10-09 23:49:44 +00:00
)
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)
}