nix

package
v1.2.5-master Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShellHookFileName = "shell-hook.sh"
	BuildHookFileName = "build-hook.sh"
)

Variables

This section is empty.

Functions

func InitNixyFile

func InitNixyFile(ctx context.Context, dest string) error

func ProfileCreate

func ProfileCreate(ctx context.Context, name string) error

ProfileCreate creates a new profile with the given name

func ProfileEdit

func ProfileEdit(ctx context.Context, name string) error

ProfileEdit opens the profile's flake.nix in the user's editor

func ProfileList

func ProfileList(ctx context.Context) ([]string, error)

ProfileList returns all available profiles

func XDGDataDir

func XDGDataDir() string

Types

type Build added in v1.2.1

type Build struct {
	Packages []*NormalizedPackage `yaml:"packages"`
	Paths    []string             `yaml:"paths"`
}

type Context

type Context struct {
	Executor Executor
	Profile  string
}

type Executor

type Executor string
const (
	LocalExecutor      Executor = "local"
	DockerExecutor     Executor = "docker"
	BubbleWrapExecutor Executor = "bubblewrap"
)

type ExecutorArgs added in v1.2.1

type ExecutorArgs struct {
	PWD string

	NixBinaryMountedPath  string
	ProfileDirMountedPath string
	FakeHomeMountedPath   string
	NixDirMountedPath     string

	WorkspaceFlakeDirHostPath    string
	WorkspaceFlakeDirMountedPath string

	EnvVars ExecutorEnvVars
}

func UseBubbleWrap

func UseBubbleWrap(profile *Profile) (*ExecutorArgs, error)

func UseDocker

func UseDocker(profile *Profile) (*ExecutorArgs, error)

func UseLocal added in v1.2.1

func UseLocal(profile *Profile) (*ExecutorArgs, error)

type ExecutorEnvVars added in v1.2.1

type ExecutorEnvVars struct {
	User     string `json:"USER"`
	Home     string `json:"HOME"`
	Term     string `json:"TERM"`
	TermInfo string `json:"TERMINFO"`

	Path           []string `json:"PATH"`
	XDGSessionType string   `json:"XDG_SESSION_TYPE"`
	XDGCacheHome   string   `json:"XDG_CACHE_HOME"`
	XDGDataHome    string   `json:"XDG_DATA_HOME"`

	NixyOS string `json:"NIXY_OS"`

	// NIXY_ARCH has value like "amd64" or "arm64"
	NixyArch string `json:"NIXY_ARCH"`

	// NIXY_ARCH_FULL has value like "x86_64"
	NixyArchFull string `json:"NIXY_ARCH_FULL"`

	NixyShell             string `json:"NIXY_SHELL"`
	NixyWorkspaceDir      string `json:"NIXY_WORKSPACE_DIR"`
	NixyWorkspaceFlakeDir string `json:"NIXY_WORKSPACE_FLAKE_DIR"`
	NixyBuildHook         string `json:"NIXY_BUILD_HOOK"`
	NixConfDir            string `json:"NIX_CONF_DIR"`
}

func (*ExecutorEnvVars) ToEnviron added in v1.2.1

func (e *ExecutorEnvVars) ToEnviron() []string

type ExecutorMountPath added in v1.2.1

type ExecutorMountPath struct {
	HostPath  string
	MountPath string
	ReadOnly  bool
}

type Nix

type Nix struct {
	NixyVersion string `yaml:"-"`

	ConfigFile *string `yaml:"-"`

	sync.Mutex `yaml:"-"`
	Logger     *slog.Logger `yaml:"-"`

	NixPkgs   string               `yaml:"nixpkgs"`
	Packages  []*NormalizedPackage `yaml:"packages"`
	Libraries []string             `yaml:"libraries,omitempty"`

	Env map[string]string `yaml:"env,omitempty"`

	ShellHook string `yaml:"shellHook,omitempty"`

	Builds map[string]Build `yaml:"builds,omitempty"`
	// contains filtered or unexported fields
}

func LoadFromFile

func LoadFromFile(ctx context.Context, f string) (*Nix, error)

func (*Nix) Build added in v1.2.1

func (n *Nix) Build(ctx context.Context, target string) error

func (*Nix) PrepareShellCommand

func (nix *Nix) PrepareShellCommand(ctx context.Context, command string, args ...string) (*exec.Cmd, error)

func (*Nix) Shell

func (n *Nix) Shell(ctx context.Context, program string) error

func (*Nix) SyncToDisk

func (n *Nix) SyncToDisk() error

type NixPackage added in v1.1.0

type NixPackage struct {
	Name   string
	Commit string
}

type NormalizedPackage added in v1.1.0

type NormalizedPackage struct {
	*NixPackage
	*URLPackage
}

func (*NormalizedPackage) MarshalYAML added in v1.1.0

func (p *NormalizedPackage) MarshalYAML() (any, error)

func (*NormalizedPackage) UnmarshalYAML added in v1.1.0

func (p *NormalizedPackage) UnmarshalYAML(value *yaml.Node) error

type Profile

type Profile struct {
	Name                string
	NixPkgsCommitHash   string `json:"nixpkgs,omitempty"`
	ProfilePath         string // ~/.local/share/nixy/profiles/<name>
	FakeHomeDir         string
	WorkspacesDir       string
	NixDir              string
	StaticNixBinPath    string // Path for static nix binary
	ProfileNixyYAMLPath string
}

Profile represents a general profile that all executors can use

func GetProfile

func GetProfile(name string) (*Profile, error)

func NewProfile

func NewProfile(ctx context.Context, name string) (*Profile, error)

NewProfile creates a new profile instance

func (*Profile) CreateDirs

func (p *Profile) CreateDirs() error

CreateDirs creates the necessary directories for the profile

func (*Profile) Save

func (p *Profile) Save() error

type ShellContext

type ShellContext struct {
	context.Context
	EnvVars map[string]string
}

type URLPackage added in v1.1.0

type URLPackage struct {
	Name        string `yaml:"name"`
	URL         string `yaml:"url"`
	RenderedURL string `yaml:"-"`

	// Sha256 is a map of $OS/$ARCH to sha256 corresponding to the binary
	Sha256 map[string]string `yaml:"sha256,omitempty"`
}

type WorkspaceFlakeGenParams added in v1.2.4

type WorkspaceFlakeGenParams struct {
	NixPkgsDefaultCommit string
	WorkspaceDirPath     string
	Packages             []*NormalizedPackage
	Libraries            []string
	Builds               map[string]Build
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL