nix

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentNixyProfile

func GetCurrentNixyProfile() string

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 BubbleWrap

type BubbleWrap struct {
	ProfileFlakeDirMountedPath string
	FakeHomeMountedPath        string
	NixDirMountedPath          string
	WorkspacesDirMountedPath   string
	StaticNixBinMountedPath    string
	// contains filtered or unexported fields
}

func UseBubbleWrap

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

type Context

type Context struct {
	Executor Executor
	Profile  string
}

type Docker

type Docker struct {
	ProfileFlakeDirMountedPath string
	FakeHomeMountedPath        string
	NixDirMountedPath          string
	WorkspaceDirMountedPath    string
	StaticNixBinMountedPath    string
	// contains filtered or unexported fields
}

func UseDocker

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

type Executor

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

func GetCurrentNixyExecutor

func GetCurrentNixyExecutor() Executor

type Nix

type Nix struct {
	ConfigFile *string `json:"-"`

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

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

	ShellHook string `json:"shellHook,omitempty"`
	// contains filtered or unexported fields
}

func LoadFromFile

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

func (*Nix) GenerateWorkspaceFlakeParams added in v1.1.0

func (n *Nix) GenerateWorkspaceFlakeParams() (*WorkspaceFlakeParams, error)

func (*Nix) PrepareShellCommand

func (nix *Nix) PrepareShellCommand(ctx ShellContext, program string) (*exec.Cmd, error)

func (*Nix) ProfileFlakeDir

func (n *Nix) ProfileFlakeDir() (host, mounted string)

func (*Nix) Shell

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

func (*Nix) SyncToDisk

func (n *Nix) SyncToDisk() error

func (*Nix) WorkspaceFlakeDir

func (n *Nix) WorkspaceFlakeDir() (host, mounted string)

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>
	ProfileFlakeDir   string
	FakeHomeDir       string
	WorkspacesDir     string
	NixDir            string
	StaticNixBinPath  string // Path for static nix binary
}

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 ProfileFlakeParams added in v1.1.0

type ProfileFlakeParams struct {
	NixPkgsCommit string
}

type ShellContext

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

type URLPackage added in v1.1.0

type URLPackage struct {
	Name   string `json:"name"`
	URL    string `json:"url"`
	Sha256 string `json:"sha256,omitempty"`
}

type WorkspaceFlakeParams added in v1.1.0

type WorkspaceFlakeParams struct {
	NixPkgsDefaultCommit string
	NixPkgsCommits       []string

	PackagesMap  map[string][]string
	LibrariesMap map[string][]string
	URLPackages  []URLPackage

	ProfileFlakeDir string
	WorkspaceDir    string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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