nixbuild/format.go

28 lines
798 B
Go

package nixbuild
import (
"context"
"os/exec"
)
const (
nixExtraExperimentalFeatures = "--extra-experimental-features"
nixExperimentalFeaturesFlakes = "nix-command flakes"
)
// since flakes are supposedly experimental
var nixEnableFlakes = []string{nixExtraExperimentalFeatures, nixExperimentalFeaturesFlakes}
// Nix returns the [exec.Cmd] struct to execute a nix command.
func Nix(ctx context.Context, arg ...string) *exec.Cmd {
return exec.CommandContext(ctx, "nix", append(nixEnableFlakes, arg...)...)
}
const (
nixosSuffix0 = "#nixosConfigurations."
nixosSuffix1 = ".config.system.build.toplevel"
)
// NixOSInstallable returns the nixos installable for a given flake and host.
func NixOSInstallable(flake, host string) string { return flake + nixosSuffix0 + host + nixosSuffix1 }