|
4 | 4 | "errors" |
5 | 5 | "fmt" |
6 | 6 | conancommand "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/conan" |
| 7 | + nixcommand "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/nix" |
7 | 8 | "io/fs" |
8 | 9 | "os" |
9 | 10 | "os/exec" |
@@ -67,6 +68,7 @@ import ( |
67 | 68 | huggingfaceuploaddocs "github.com/jfrog/jfrog-cli/docs/buildtools/huggingfaceupload" |
68 | 69 | mvndoc "github.com/jfrog/jfrog-cli/docs/buildtools/mvn" |
69 | 70 | "github.com/jfrog/jfrog-cli/docs/buildtools/mvnconfig" |
| 71 | + "github.com/jfrog/jfrog-cli/docs/buildtools/nix" |
70 | 72 | "github.com/jfrog/jfrog-cli/docs/buildtools/npmcommand" |
71 | 73 | "github.com/jfrog/jfrog-cli/docs/buildtools/npmconfig" |
72 | 74 | nugetdocs "github.com/jfrog/jfrog-cli/docs/buildtools/nuget" |
@@ -409,6 +411,19 @@ func GetCommands() []cli.Command { |
409 | 411 | Category: buildToolsCategory, |
410 | 412 | Action: ConanCmd, |
411 | 413 | }, |
| 414 | + { |
| 415 | + Name: "nix", |
| 416 | + Hidden: true, |
| 417 | + Flags: cliutils.GetCommandFlags(cliutils.Nix), |
| 418 | + Usage: nix.GetDescription(), |
| 419 | + HelpName: corecommon.CreateUsage("nix", nix.GetDescription(), nix.Usage), |
| 420 | + UsageText: nix.GetArguments(), |
| 421 | + ArgsUsage: common.CreateEnvVars(), |
| 422 | + SkipFlagParsing: true, |
| 423 | + BashComplete: corecommon.CreateBashCompletionFunc(), |
| 424 | + Category: buildToolsCategory, |
| 425 | + Action: NixCmd, |
| 426 | + }, |
412 | 427 | { |
413 | 428 | Name: "ruby-config", |
414 | 429 | Flags: cliutils.GetCommandFlags(cliutils.RubyConfig), |
@@ -2010,6 +2025,53 @@ func ConanCmd(c *cli.Context) error { |
2010 | 2025 | return commands.Exec(conanCommand) |
2011 | 2026 | } |
2012 | 2027 |
|
| 2028 | +func NixCmd(c *cli.Context) error { |
| 2029 | + if show, err := cliutils.ShowCmdHelpIfNeeded(c, c.Args()); show || err != nil { |
| 2030 | + return err |
| 2031 | + } |
| 2032 | + if c.NArg() < 1 { |
| 2033 | + return cliutils.WrongNumberOfArgumentsHandler(c) |
| 2034 | + } |
| 2035 | + |
| 2036 | + args := cliutils.ExtractCommand(c) |
| 2037 | + |
| 2038 | + // The first arg determines which native tool to run: |
| 2039 | + // jf nix nix-channel --add ... → nativeTool="nix-channel", args=["--add", ...] |
| 2040 | + // jf nix nix-env -iA ... → nativeTool="nix-env", args=["-iA", ...] |
| 2041 | + // jf nix nix-build '<nixpkgs>' → nativeTool="nix-build", args=["'<nixpkgs>'", ...] |
| 2042 | + // jf nix copy --to ... → nativeTool="copy" (runs as "nix copy"), args=["--to", ...] |
| 2043 | + nativeTool, remainingArgs := getCommandName(args) |
| 2044 | + |
| 2045 | + // Extract --server-id flag before passing to native tool |
| 2046 | + var serverID string |
| 2047 | + var err error |
| 2048 | + remainingArgs, serverID, err = coreutils.ExtractServerIdFromCommand(remainingArgs) |
| 2049 | + if err != nil { |
| 2050 | + return fmt.Errorf("failed to extract server ID: %w", err) |
| 2051 | + } |
| 2052 | + |
| 2053 | + // Extract build flags (--build-name, --build-number, --module, --project) |
| 2054 | + filteredArgs, buildConfiguration, err := build.ExtractBuildDetailsFromArgs(remainingArgs) |
| 2055 | + if err != nil { |
| 2056 | + return err |
| 2057 | + } |
| 2058 | + |
| 2059 | + cmd := nixcommand.NewNixCommand().SetNativeTool(nativeTool).SetArgs(filteredArgs).SetBuildConfiguration(buildConfiguration) |
| 2060 | + |
| 2061 | + // Pass server details — use --server-id if provided, otherwise default |
| 2062 | + var serverDetails *coreConfig.ServerDetails |
| 2063 | + if serverID != "" { |
| 2064 | + serverDetails, err = coreConfig.GetSpecificConfig(serverID, false, false) |
| 2065 | + } else { |
| 2066 | + serverDetails, err = coreConfig.GetDefaultServerConf() |
| 2067 | + } |
| 2068 | + if err == nil && serverDetails != nil { |
| 2069 | + cmd.SetServerDetails(serverDetails) |
| 2070 | + } |
| 2071 | + |
| 2072 | + return commands.Exec(cmd) |
| 2073 | +} |
| 2074 | + |
2013 | 2075 | func pythonCmd(c *cli.Context, projectType project.ProjectType) error { |
2014 | 2076 | if show, err := cliutils.ShowCmdHelpIfNeeded(c, c.Args()); show || err != nil { |
2015 | 2077 | return err |
|
0 commit comments