-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed nix completer `builders` and `substituters` flags not being StringArray
- Loading branch information
Showing
13 changed files
with
298 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var bootCmd = &cobra.Command{ | ||
Use: "boot", | ||
Short: "Build the new configuration and make it the boot default, but do not activate it", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(bootCmd).Standalone() | ||
rootCmd.AddCommand(bootCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var buildCmd = &cobra.Command{ | ||
Use: "build", | ||
Short: "build the new configuration without activating it or adding it to the boot menu", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(buildCmd).Standalone() | ||
rootCmd.AddCommand(buildCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var build_vmCmd = &cobra.Command{ | ||
Use: "build-vm", | ||
Short: "Build a script that starts a NixOS virtual machine with the configuration", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(build_vmCmd).Standalone() | ||
rootCmd.AddCommand(build_vmCmd) | ||
} |
17 changes: 17 additions & 0 deletions
17
completers/nixos-rebuild_completer/cmd/build_vm_with_bootloader.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var build_vm_with_bootloaderCmd = &cobra.Command{ | ||
Use: "build-vm-with-bootloader", | ||
Short: "Like build-vm, but boots with the regular bootloader of your configuration", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(build_vm_with_bootloaderCmd).Standalone() | ||
rootCmd.AddCommand(build_vm_with_bootloaderCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var dry_activateCmd = &cobra.Command{ | ||
Use: "dry-activate", | ||
Short: "Build the new configuration, but show what changes would occur on activation instead of activating the configuration", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(dry_activateCmd).Standalone() | ||
rootCmd.AddCommand(dry_activateCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var dry_buildCmd = &cobra.Command{ | ||
Use: "dry-build", | ||
Short: "Show what store paths would be built or downloaded, but otherwise do nothing", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(dry_buildCmd).Standalone() | ||
rootCmd.AddCommand(dry_buildCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var editCmd = &cobra.Command{ | ||
Use: "edit", | ||
Short: "Opens configuration.nix in the default editor", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(editCmd).Standalone() | ||
rootCmd.AddCommand(editCmd) | ||
} |
20 changes: 20 additions & 0 deletions
20
completers/nixos-rebuild_completer/cmd/list_generations.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var list_generationsCmd = &cobra.Command{ | ||
Use: "list-generations", | ||
Short: "List the available generations", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(list_generationsCmd).Standalone() | ||
|
||
list_generationsCmd.Flags().Bool("json", false, "Output in JSON") | ||
|
||
rootCmd.AddCommand(list_generationsCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var replCmd = &cobra.Command{ | ||
Use: "repl", | ||
Short: "Open the configuration in `nix repl`", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(replCmd).Standalone() | ||
rootCmd.AddCommand(replCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace-bin/pkg/actions/net" | ||
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/nix" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "nixos-rebuild", | ||
Short: "reconfigure a NixOS machine", | ||
Long: "https://nixos.org", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func Execute() error { | ||
return rootCmd.Execute() | ||
} | ||
|
||
func init() { | ||
carapace.Gen(rootCmd).Standalone() | ||
|
||
rootCmd.PersistentFlags().String("build-host", "localhost", "Specify host to perform the rebuild with") | ||
rootCmd.PersistentFlags().StringArray("builders", nil, "Specify ad-hoc remote builders") | ||
rootCmd.PersistentFlags().String("commit-lockfile-summary", "", "Set the commit-lockfile-summary setting") | ||
rootCmd.PersistentFlags().Bool("fallback", false, "Enable the fallback setting") | ||
rootCmd.PersistentFlags().Bool("fast", false, "Do not rebuild the 'nixUnstable' nixpkgs attribute before rebuilding") | ||
rootCmd.PersistentFlags().String("flake", "", "Build the NixOS system from specified flake") | ||
rootCmd.PersistentFlags().Bool("help", false, "Show usage information") | ||
rootCmd.PersistentFlags().Bool("install-bootloader", false, "Causes the bootloader to be (re)installed") | ||
rootCmd.PersistentFlags().Bool("keep-failed", false, "Enable the keep-failed setting") | ||
rootCmd.PersistentFlags().Bool("keep-going", false, "Enable the keep-going setting") | ||
rootCmd.PersistentFlags().String("log-format", "", "Set the format of log output") | ||
rootCmd.PersistentFlags().String("max-jobs", "", "Set the max-jobs setting") | ||
rootCmd.PersistentFlags().Bool("no-build-nix", false, "Do not rebuild the 'nixUnstable' nixpkgs attribute before rebuilding") | ||
rootCmd.PersistentFlags().BoolP("no-build-output", "-Q", false, "Do not output on stdout or stderr") | ||
rootCmd.PersistentFlags().Bool("offline", false, "Disable substituters and consider all previously downloaded files up-to-date") | ||
rootCmd.PersistentFlags().StringSlice("option", []string{}, "Set the Nix configuration setting name to value") | ||
rootCmd.PersistentFlags().BoolP("print-build-logs", "L", false, "Print full build logs on standard error") | ||
rootCmd.PersistentFlags().StringP("profile-name", "p", "", "Specify Nix profile to place the new configuration in") | ||
rootCmd.PersistentFlags().Bool("quiet", false, "Decrease the logging verbosity level") | ||
rootCmd.PersistentFlags().Bool("refresh", false, "Consider all previously downloaded files out-of-date") | ||
rootCmd.PersistentFlags().Bool("rollback", false, "Rollback to previous configuration instead of rebuilding") | ||
rootCmd.PersistentFlags().Bool("show-trace", false, "Enable the show-trace setting") | ||
rootCmd.PersistentFlags().StringP("specialisation", "c", "", "Activates given specialisation") | ||
rootCmd.PersistentFlags().String("target-host", "localhost", "Specify host to apply rebuilt configuration to") | ||
rootCmd.PersistentFlags().Bool("upgrade", false, "Update the root user's channel named 'nixos' before rebuilding") | ||
rootCmd.PersistentFlags().Bool("upgrade-all", false, "Update all of the root user's channels before rebuilding") | ||
rootCmd.PersistentFlags().Bool("use-remote-sudo", false, "Prefix activation commands on the target host with `sudo`") | ||
rootCmd.PersistentFlags().Bool("use-substitutes", false, "Use substitue caches when running `nix-copy-closure`") | ||
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "Increase the logging verbosity level") | ||
|
||
rootCmd.MarkFlagsMutuallyExclusive("fast", "no-build-nix") // aliases | ||
rootCmd.MarkFlagsMutuallyExclusive("no-build-output", "verbose", "quiet") | ||
|
||
rootCmd.Flag("option").Nargs = 2 | ||
|
||
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ | ||
"build-host": net.ActionHosts(), | ||
"flake": nix.ActionFlakes(), | ||
"log-format": carapace.ActionValues("raw", "internal-json", "bar", "bar-with-logs"), | ||
"option": carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
switch len(c.Parts) { | ||
case 0: | ||
return nix.ActionConfigKeys() | ||
case 1: | ||
return nix.ActionConfigValues(c.Parts[0]) | ||
default: | ||
return carapace.ActionValues() | ||
} | ||
}), | ||
"target-host": net.ActionHosts(), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var switchCmd = &cobra.Command{ | ||
Use: "switch", | ||
Short: "Build and activate the new configuration, making it the boot default", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(switchCmd).Standalone() | ||
rootCmd.AddCommand(switchCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "github.com/carapace-sh/carapace-bin/completers/nixos-rebuild_completer/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |