Documentation ¶
Index ¶
- Variables
- func CombineChannelRegistries(registries []ChannelRegistry) (map[string]ChannelInput, error)
- func WithVerbose(ctx context.Context) context.Context
- type ChannelInput
- func (in ChannelInput) CanResolve() bool
- func (in ChannelInput) MarshalJSON() ([]byte, error)
- func (in ChannelInput) MarshalText() ([]byte, error)
- func (in ChannelInput) Resolve(ctx context.Context) (string, error)
- func (in ChannelInput) String() string
- func (in *ChannelInput) UnmarshalJSON(b []byte) error
- func (in *ChannelInput) UnmarshalText(text []byte) error
- type ChannelLock
- type ChannelRegistry
- type ChannelResolver
- type ChannelURL
- type Config
- type LockFile
- type State
- type UserConfig
- type Username
Constants ¶
This section is empty.
Variables ¶
var ChannelResolvers = map[string]ChannelResolver{
"git": resolveGit,
"github": resolveGit,
"gitlab": resolveGit,
"gitsrht": resolveGit,
}
ChannelResolvers maps URL schemes to resolvers.
Functions ¶
func CombineChannelRegistries ¶
func CombineChannelRegistries(registries []ChannelRegistry) (map[string]ChannelInput, error)
CombineChannelRegistries combines the given ChannelRegistries into a single channel input map. It also resolves the aliases. Channels defined later in the list will override the ones defined earlier.
Types ¶
type ChannelInput ¶
type ChannelInput struct { // URL is the source URL of the channel. URL ChannelURL // Version is the respective version string corresponding to the VCS defined // in the channel URL. For example, if the VCS is Git, then the URL's scheme // might be git+https, and the version string would imply a branch name, // tag, or commit hash. // // If the Version string is empty, then it is not included in the marshaled // text at all. Version string }
ChannelInput is the input declaration of a channel. It is marshaled to TOML as a string of two parts, the URL and the version, separated by a space.
func ParseChannelInput ¶
func ParseChannelInput(chInput string) (ChannelInput, error)
ParseChannelInput parses the channel input string into ChannelInput.
func (ChannelInput) CanResolve ¶
func (in ChannelInput) CanResolve() bool
CanResolve returns true if the channel input's URL scheme is recognized.
func (ChannelInput) MarshalJSON ¶
func (in ChannelInput) MarshalJSON() ([]byte, error)
func (ChannelInput) MarshalText ¶
func (in ChannelInput) MarshalText() ([]byte, error)
func (ChannelInput) Resolve ¶
func (in ChannelInput) Resolve(ctx context.Context) (string, error)
Resolve resolves the channel input using one of the ChannelResolvers.
func (ChannelInput) String ¶
func (in ChannelInput) String() string
String returns the ChannelInput formatted as a string.
func (*ChannelInput) UnmarshalJSON ¶
func (in *ChannelInput) UnmarshalJSON(b []byte) error
func (*ChannelInput) UnmarshalText ¶
func (in *ChannelInput) UnmarshalText(text []byte) error
type ChannelLock ¶
type ChannelLock struct { // URL is the resolved channel URL that's used for Nix. This URL must always // point to the same file, and the store hash guarantees that. URL string `json:"url"` // StoreHash is the hash part of the /nix/store output path of the channel. StoreHash nixutil.StoreHash `json:"store_hash"` // StorePath is the path of the /nix/store output path of the channel. StorePath string `json:"store_path,omitempty"` }
ChannelLock describes the locking checksums for a single channel.
func (ChannelLock) HashChanged ¶
func (l ChannelLock) HashChanged(newer ChannelLock) bool
HashChanged returns true if the channel URL is the same, but the store hash is different.
type ChannelRegistry ¶
type ChannelRegistry struct { // Channels maps the channel names to its respective input strings. Channels map[string]ChannelInput `toml:"channels"` // Aliases maps a channel name to another channel name as aliases. The // aliasing channel will have the same channel input as the aliased. Aliases map[string]string `toml:"aliases"` }
ChannelRegistry is a common structure holding configured channels and its aliases.
func (ChannelRegistry) FilterChannels ¶
func (r ChannelRegistry) FilterChannels(names []string) ChannelRegistry
FilterChannels returns a new ChannelRegistry with only the channels that are present in the given names.
type ChannelResolver ¶
type ChannelResolver func(context.Context, ChannelInput) (string, error)
ChannelResolver is a function type that resolves a channel URL to the URL that's actually used for adding into nix-channel.
type ChannelURL ¶
type ChannelURL string
ChannelURL is the URL to the source of a channel.
func (ChannelURL) Parse ¶
func (u ChannelURL) Parse() (*url.URL, error)
Parse parses the channel URL string. An invalid URL will cause an error.
func (ChannelURL) Validate ¶
func (u ChannelURL) Validate() error
Validate validates the ChannelURL string.
type Config ¶
type Config struct { // Global is the global channels. Global struct { // PreferredUser is the preferred user to use for nix-channel invocations. // If this is empty, then it will be picked automatically. PreferredUser string `toml:"preferred_user,omitempty"` ChannelRegistry } `toml:"global"` // Flakes is the flakes channels. Flakes struct { Enable bool `toml:"enable"` Output string `toml:"output"` // ("nix") or "flakes" ChannelRegistry } `toml:"flakes"` // Users maps the usernames to their respective UserConfig. Users map[Username]UserConfig `toml:"users"` }
Config is the root structure of the host configuration file. It maps the usernames to their corresponding config.
func NewConfigFromReader ¶
NewConfigFromReader creates a new Config by decoding the given reader as a TOML file.
func (Config) ChannelInputs ¶
func (cfg Config) ChannelInputs() map[ChannelInput]struct{}
ChannelInputs returns all channel inputs within the current config.
func (Config) FilterChannels ¶
FilterChannels returns a new Config with only the channels that are present in the given names.
func (Config) UserChannels ¶
func (cfg Config) UserChannels(user string) (map[string]ChannelInput, error)
UserChannels returns the ChannelRegistry for the given user combined with the global channels.
type LockFile ¶
type LockFile struct { // Channels maps channel URLs to its lock. Channels map[ChannelInput]ChannelLock `json:"channels"` }
LockFile describes a file containing hashes (or checksums) of the channels fetched.
func NewLockFileFromReader ¶
NewLockFileFromReader creates a new LockFile containing data from the given reader parsed as JSON.
type State ¶
State encapsulates the current configuration and the locks of it. A State can be applied onto the current system.
func (*State) GenerateNixRegistry ¶
func (s *State) GenerateNixRegistry() (json.RawMessage, error)
GenerateNixRegistry generates the nix.registry attributes as JSON for the current configuration.
type UserConfig ¶
type UserConfig struct { // UseSudo, if true, will use sudo if the current user is not the user that // this config belongs to. If it's false and the current user is not this // user, then an error will be thrown. UseSudo bool `toml:"use-sudo"` // OverrideChannels, if true, will cause all channels not defined in the // configuration file to be deleted. OverrideChannels bool `toml:"override-channels"` ChannelRegistry }
UserConfig is the structure of the user configuration.