nix

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const EnvVarQuitshNixNoPureEval = "QUITSH_NIX_NO_PURE_EVAL"

Enable `--no-pure-eval` on Nix DevShells, to forexample pass env. values which are evaluated in Nix.

View Source
const EnvVarQuitshToolchain = "QUITSH_TOOLCHAINS"

The toolchain env. variable as a comma separated list of toolchain names in the current shell.

Variables

This section is empty.

Functions

func CurrentSystem

func CurrentSystem() (currentSystem string, err error)

CurrentSystem reports the current system.

func EvalTemplate

func EvalTemplate(
	nixx *exec.CmdContext,
	temp string,
	data any,
	opts ...EvalOption) (string, error)

EvalTemplate evaluates a Nix expression and returns the result.

func FlakeInstallable

func FlakeInstallable(flakePath string, attrPath string) string

FlakeInstallable returns the attribute path `<flakePath>#<attrPath>`.

func GetFlakePackages

func GetFlakePackages(
	rootDir string,
	flakePath string,
) (packages map[string]Package, err error)

GetFlakePackages gets all packages from the flake for the current system. This uses `nix eval <flakeOutputAttr>` Note: We cannot use `nix flake show` (sadly) because we use IFD (import from derivation inside `yaml.nix`) which is unfortunate (maybe we can later somehow convert the `.component.yaml`s to JSON) See also: https://github.com/NixOS/nix/issues/4265

func HardeningOptions

func HardeningOptions() []string

HardeningOptions returns the set hardening options.

func HaveToolchain

func HaveToolchain(toolchain string) bool

HaveToolchain tests if we are running inside a Nix shell/Nix build which has the toolchain `toolchain` available. A toolchain is just a set of tools we define. The Nix shells need to have a `QUITSH_TOOLCHAINS = "a,b,c"` set.

func InBuild

func InBuild() bool

InBuild returns `true` if we are inside a Nix build.

func InShell

func InShell() bool

InShell returns `true` if we are inside a Nix shell.

func NewCtxBuilder

func NewCtxBuilder() exec.CmdContextBuilder

NewCtxBuilder returns a new Nix command context builder.

func NewDevShellCtxBuilder

func NewDevShellCtxBuilder(
	rootDir string,
	flakePath string,
	attrPath string,
) exec.CmdContextBuilder

NewDevShellCtxBuilder returns a new command context builder which runs all commands over a Nix development shell.

func NewDevShellCtxBuilderI

func NewDevShellCtxBuilderI(rootDir string, installable string) exec.CmdContextBuilder

NewDevShellCtxBuilderI, see `NewDevShellCtxBuilder`.

func ReplaceSystem

func ReplaceSystem(attrPath string) (string, error)

ReplaceSystem replaces placeholder "${system}" in string `attrPath` with the current system.

func ToolchainInstallable

func ToolchainInstallable(flakePath string, toolchain string) string

ToolchainInstallable returns the `nix develop <toolchainref>` string for the given toolchain.

func WrapOverDevShell

func WrapOverDevShell(
	ctxBuilder exec.CmdContextBuilder,
	rootDir string,
	flakePath string,
	attrPath string,
) exec.CmdContextBuilder

WrapOverDevShell wraps a command context builder over a dev shell with `NewDevShellCtxBuilder`.

func WrapOverDevShellI

func WrapOverDevShellI(
	ctxBuilder exec.CmdContextBuilder,
	rootDir string,
	installable string,
) exec.CmdContextBuilder

WrapOverDevShellI, see `WrapOverDevShellI`.

Types

type BuildCtx

type BuildCtx struct {
	*exec.CmdContext
}

func NewBuildCtx

func NewBuildCtx(
	rootDir string,
	applyOpts ...func(b exec.CmdContextBuilder) exec.CmdContextBuilder) BuildCtx

NewBuildCtxBuilder returns a new `nix build` command context for flake builds.

type EvalOption

type EvalOption func(cmd *[]string) error

func WithEvalImpure

func WithEvalImpure() EvalOption

WithEvalImpure uses `impure` evaluation on `Eval`.

func WithEvalOutputJSON

func WithEvalOutputJSON() EvalOption

WithEvalOutputRaw uses JSON output on `Eval`.

func WithEvalOutputRaw

func WithEvalOutputRaw() EvalOption

WithEvalOutputRaw uses `raw` output on `Eval`.

type NixEvalCtx

type NixEvalCtx struct {
	*exec.CmdContext
}

func NewEvalCtx

func NewEvalCtx(
	rootDir string,
	applyOpts ...func(b exec.CmdContextBuilder) exec.CmdContextBuilder,
) NixEvalCtx

NewEvalCtxBuilder returns a new `nix eval` command context for flake evaluations.

type NixRunCtx

type NixRunCtx struct {
	*exec.CmdContext
}

func NewRunCtx

func NewRunCtx(
	rootDir string,
	applyOpts ...func(b exec.CmdContextBuilder) exec.CmdContextBuilder,
) NixRunCtx

NewEvalCtxBuilder returns a new `nix run` command context builder.

type Package

type Package struct {
	// The package name as usable in `nix build ./dir-to-flake#<name>`.
	Name string

	// The full package attribute path, e.g. `packages.<system>.<name>`.
	// with the current system.
	AttrPath string

	// The package store path.
	StorePath string
}

Jump to

Keyboard shortcuts

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