nix

package
v1.2.7-master Latest Latest
Warning

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

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

Documentation

Index

Constants

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

Variables

View Source
var (
	ProfileSandboxMountPath        string = "/profile"
	WorkspaceDirSandboxMountPath   string = "/workspace"
	WorkspaceFlakeSandboxMountPath string = "/workspace-flake"
)

Functions

func InitNixyFile

func InitNixyFile(parent 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 {
	context.Context

	NixyProfile    string
	NixyMode       Mode
	NixyUseProfile bool
	NixyBinPath    string
	InNixyShell    bool

	PWD string

	NixyDataDir string
}

func NewContext added in v1.2.6

func NewContext(parent context.Context, workspaceDir string) (*Context, error)

func (*Context) IsLocalMode added in v1.2.6

func (ctx *Context) IsLocalMode() bool

type ExecutorArgs added in v1.2.1

type ExecutorArgs struct {
	NixBinaryMountedPath  string
	ProfileDirMountedPath string
	FakeHomeMountedPath   string
	NixDirMountedPath     string

	WorkspaceFlakeDirHostPath    string
	WorkspaceFlakeDirMountedPath string

	EnvVars executorEnvVars
}

func UseBubbleWrap

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

func UseDocker

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

func UseLocal added in v1.2.1

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

type ExecutorMountPath added in v1.2.1

type ExecutorMountPath struct {
	HostPath  string
	MountPath string
	ReadOnly  bool
}

type InShellNixy added in v1.2.6

type InShellNixy struct {
	PWD    string `yaml:"-"`
	Logger *slog.Logger
	NixyConfig
}

func LoadInNixyShell added in v1.2.6

func LoadInNixyShell(parent context.Context) (*InShellNixy, error)

func (*InShellNixy) Build added in v1.2.6

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

type Mode added in v1.2.6

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

func (Mode) String added in v1.2.6

func (m Mode) String() string

type NixPackage added in v1.1.0

type NixPackage struct {
	Name   string
	Commit string
}

type Nixy added in v1.2.6

type Nixy struct {
	Context *Context

	ConfigFile *string

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

	PWD string

	NixyConfig
	// contains filtered or unexported fields
}

func LoadFromFile

func LoadFromFile(parent context.Context, f string) (*Nixy, error)

func (*Nixy) Build added in v1.2.6

func (nixy *Nixy) Build(ctx *Context, target string) error

func (*Nixy) PrepareShellCommand added in v1.2.6

func (nixy *Nixy) PrepareShellCommand(ctx *Context, command string, args ...string) (*exec.Cmd, error)

func (*Nixy) Shell added in v1.2.6

func (n *Nixy) Shell(ctx *Context, program string) error

func (*Nixy) SyncToDisk added in v1.2.6

func (nixy *Nixy) SyncToDisk() error

type NixyConfig added in v1.2.6

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

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

	OnShellEnter string `yaml:"onShellEnter,omitempty"`

	// OnShellExit is not used as of now, will try to use it in future
	OnShellExit string `yaml:"onShellExit,omitempty"`

	Builds map[string]Build `yaml:"builds,omitempty"`
}

type NixyHostDataStore added in v1.2.6

type NixyHostDataStore struct {
	// contains filtered or unexported fields
}

func (NixyHostDataStore) ProfilePath added in v1.2.6

func (n NixyHostDataStore) ProfilePath(profile string) 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(ctx *Context, name string) (*Profile, error)

func NewProfile

func NewProfile(ctx *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