install

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package install writes service-manager unit files (systemd, launchd) for pyry. Used by the `pyry install-service` subcommand.

The package never enables, starts, or otherwise activates the unit — it only writes the file and returns the path. The user runs the platform's own enable/start commands afterward, with the next-step instructions printed by the caller.

Index

Constants

This section is empty.

Variables

View Source
var ErrFileExists = errors.New("unit file already exists; pass --force to overwrite")

ErrFileExists is returned when the unit file already exists and Force is false.

Functions

func ResolveWorkDir added in v0.9.1

func ResolveWorkDir(flag, cwd, homeDir string) (string, error)

ResolveWorkDir returns the absolute, canonicalised WorkingDirectory to bake into the unit file, given the user-supplied --workdir flag value (possibly empty), the install-time cwd, and the user's home directory.

If flag is empty, cwd is used. A leading "~" or "~/" is expanded against homeDir. The result is always absolute (via filepath.Abs).

Types

type Options

type Options struct {
	// Platform picks the service manager. PlatformAuto detects from GOOS.
	Platform Platform

	// Name is the instance name. Defaults to "pyry". Used in the unit's
	// filename, label, and (when non-default) baked into ExecStart as
	// -pyry-name <name> so the supervisor binds to ~/.pyry/<name>.sock.
	Name string

	// WorkDir is what gets baked into WorkingDirectory. The CLI resolves
	// this via [ResolveWorkDir] before calling [Install]; passing an empty
	// string is a programming error and will leave the unit's WorkingDirectory
	// blank.
	WorkDir string

	// Binary is the absolute path to the pyry binary. Defaults to
	// os.Executable() — the binary currently running.
	Binary string

	// PathEnv is the PATH environment variable baked into the unit. Defaults
	// to the value of $PATH at install time (with $HOME/ rewritten to %h/
	// for systemd portability). Users typically don't set this — the
	// inherited PATH already covers nvm, pyenv, brew, and other shimmed
	// tools their interactive shell sees. Falls back to a conservative
	// system PATH if $PATH is unset.
	PathEnv string

	// ClaudeArgs, if non-empty, are baked into ExecStart after the pyry
	// flags. If empty, the unit is written with commented suggestions and
	// the user is expected to edit it before starting the service.
	ClaudeArgs []string

	// Force allows overwriting an existing file. Without it, [Install]
	// returns [ErrFileExists] if the destination is already a file.
	Force bool

	// HomeDir is the user's home directory. Defaults to os.UserHomeDir().
	// Exposed for testing.
	HomeDir string

	// EnvPath is the value of $PATH inherited from the install-time shell.
	// Defaults to os.Getenv("PATH"). Exposed for testing.
	EnvPath string
}

Options for Install.

type Platform

type Platform int

Platform identifies which service manager the unit is for.

const (
	PlatformAuto Platform = iota
	PlatformSystemd
	PlatformLaunchd
)

func Install

func Install(opt Options) (path string, plat Platform, err error)

Install writes the unit file and returns the absolute path it was written to plus the resolved Platform. If the destination already exists and Options.Force is false, returns ErrFileExists without touching it.

func (Platform) Detect

func (p Platform) Detect() Platform

Detect resolves PlatformAuto to the right platform for the running OS. PlatformSystemd and PlatformLaunchd are returned unchanged.

func (Platform) String

func (p Platform) String() string

Jump to

Keyboard shortcuts

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