format: nix command constants
This commit is contained in:
parent
7312efa1fc
commit
f052e0b98a
56
format.go
56
format.go
@ -6,6 +6,60 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// CommandBuild build a derivation or fetch a store path
|
||||||
|
CommandBuild = "build"
|
||||||
|
|
||||||
|
// FlagDryRun show what this command would do without doing it.
|
||||||
|
FlagDryRun = "--dry-run"
|
||||||
|
// FlagJson produce output in JSON format, suitable for consumption by another program.
|
||||||
|
FlagJson = "--json"
|
||||||
|
// FlagNoLink do not create symlinks to the build results.
|
||||||
|
FlagNoLink = "--no-link"
|
||||||
|
// FlagOutLink use path as prefix for the symlinks to the build results. It defaults to result.
|
||||||
|
FlagOutLink = "--out-link"
|
||||||
|
// FlagPrintOutPaths print the resulting output paths
|
||||||
|
FlagPrintOutPaths = "--print-out-paths"
|
||||||
|
// FlagProfile the profile to operate on.
|
||||||
|
FlagProfile = "--profile"
|
||||||
|
// FlagRebuild rebuild an already built package and compare the result to the existing store paths.
|
||||||
|
FlagRebuild = "--rebuild"
|
||||||
|
// FlagStdin read installables from the standard input. No default installable applied.
|
||||||
|
FlagStdin = "--stdin"
|
||||||
|
|
||||||
|
// FlagDebug set the logging verbosity level to 'debug'.
|
||||||
|
FlagDebug = "--debug"
|
||||||
|
// FlagLogFormat set the format of log output; one of raw, internal-json, bar or bar-with-logs.
|
||||||
|
FlagLogFormat = "--log-format"
|
||||||
|
// FlagPrintBuildLogs print full build logs on standard error.
|
||||||
|
FlagPrintBuildLogs = "--print-build-logs"
|
||||||
|
// FlagQuiet decrease the logging verbosity level.
|
||||||
|
FlagQuiet = "--quiet"
|
||||||
|
// FlagVerbose increase the logging verbosity level.
|
||||||
|
FlagVerbose = "--verbose"
|
||||||
|
|
||||||
|
// FlagOffline disable substituters and consider all previously downloaded files up-to-date.
|
||||||
|
FlagOffline = "--offline"
|
||||||
|
// FlagOption set the Nix configuration setting name to value (overriding nix.conf).
|
||||||
|
FlagOption = "--option"
|
||||||
|
// FlagRefresh consider all previously downloaded files out-of-date.
|
||||||
|
FlagRefresh = "--refresh"
|
||||||
|
// FlagRepair during evaluation, rewrite missing or corrupted files in the Nix store. During building, rebuild missing or corrupted store paths.
|
||||||
|
FlagRepair = "--repair"
|
||||||
|
// FlagVersion show version information.
|
||||||
|
FlagVersion = "--version"
|
||||||
|
|
||||||
|
// OptionEvalCache whether to use the flake evaluation cache.
|
||||||
|
// Certain commands won’t have to evaluate when invoked for the second time with a particular version of a flake.
|
||||||
|
// Intermediate results are not cached.
|
||||||
|
OptionEvalCache = "eval-cache"
|
||||||
|
|
||||||
|
ValueTrue = "true"
|
||||||
|
ValueFalse = "false"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
nix = "nix"
|
||||||
|
|
||||||
nixExtraExperimentalFeatures = "--extra-experimental-features"
|
nixExtraExperimentalFeatures = "--extra-experimental-features"
|
||||||
nixExperimentalFeaturesFlakes = "nix-command flakes"
|
nixExperimentalFeaturesFlakes = "nix-command flakes"
|
||||||
)
|
)
|
||||||
@ -15,7 +69,7 @@ var nixEnableFlakes = []string{nixExtraExperimentalFeatures, nixExperimentalFeat
|
|||||||
|
|
||||||
// Nix returns the [exec.Cmd] struct to execute a nix command.
|
// Nix returns the [exec.Cmd] struct to execute a nix command.
|
||||||
func Nix(ctx context.Context, arg ...string) *exec.Cmd {
|
func Nix(ctx context.Context, arg ...string) *exec.Cmd {
|
||||||
return exec.CommandContext(ctx, "nix", append(nixEnableFlakes, arg...)...)
|
return exec.CommandContext(ctx, nix, append(nixEnableFlakes, arg...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -149,13 +149,13 @@ func (e *InstantiatedEvaluator) Err() error {
|
|||||||
func NewInstantiatedEvaluator(ctx context.Context, installable string) (*InstantiatedEvaluator, error) {
|
func NewInstantiatedEvaluator(ctx context.Context, installable string) (*InstantiatedEvaluator, error) {
|
||||||
c, cancel := context.WithCancel(ctx)
|
c, cancel := context.WithCancel(ctx)
|
||||||
e := &InstantiatedEvaluator{
|
e := &InstantiatedEvaluator{
|
||||||
cmd: Nix(c, "build", installable,
|
cmd: Nix(c, CommandBuild, installable,
|
||||||
// 'instantiated' messages are only emitted when actually evaluating something
|
// 'instantiated' messages are only emitted when actually evaluating something
|
||||||
"--option", "eval-cache", "false",
|
FlagOption, OptionEvalCache, ValueFalse,
|
||||||
// do not actually build anything
|
// do not actually build anything
|
||||||
"--dry-run",
|
FlagDryRun,
|
||||||
// increase verbosity so nix outputs 'instantiated' messages
|
// increase verbosity so nix outputs 'instantiated' messages
|
||||||
"-Lvvv",
|
FlagPrintBuildLogs, FlagDebug,
|
||||||
),
|
),
|
||||||
cancel: cancel,
|
cancel: cancel,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user