Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions buildtools/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
conancommand "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/conan"
nixcommand "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/nix"
"io/fs"
"os"
"os/exec"
Expand Down Expand Up @@ -67,6 +68,7 @@ import (
huggingfaceuploaddocs "github.com/jfrog/jfrog-cli/docs/buildtools/huggingfaceupload"
mvndoc "github.com/jfrog/jfrog-cli/docs/buildtools/mvn"
"github.com/jfrog/jfrog-cli/docs/buildtools/mvnconfig"
"github.com/jfrog/jfrog-cli/docs/buildtools/nix"
"github.com/jfrog/jfrog-cli/docs/buildtools/npmcommand"
"github.com/jfrog/jfrog-cli/docs/buildtools/npmconfig"
nugetdocs "github.com/jfrog/jfrog-cli/docs/buildtools/nuget"
Expand Down Expand Up @@ -410,6 +412,19 @@ func GetCommands() []cli.Command {
Category: buildToolsCategory,
Action: ConanCmd,
},
{
Name: "nix",
Hidden: false,
Flags: cliutils.GetCommandFlags(cliutils.Nix),
Usage: nix.GetDescription(),
HelpName: corecommon.CreateUsage("nix", nix.GetDescription(), nix.Usage),
UsageText: nix.GetArguments(),
ArgsUsage: common.CreateEnvVars(),
SkipFlagParsing: true,
BashComplete: corecommon.CreateBashCompletionFunc(),
Category: buildToolsCategory,
Action: NixCmd,
},
{
Name: "ruby-config",
Flags: cliutils.GetCommandFlags(cliutils.RubyConfig),
Expand Down Expand Up @@ -2007,6 +2022,53 @@ func ConanCmd(c *cli.Context) error {
return commands.Exec(conanCommand)
}

func NixCmd(c *cli.Context) error {
if show, err := cliutils.ShowCmdHelpIfNeeded(c, c.Args()); show || err != nil {
return err
}
if c.NArg() < 1 {
return cliutils.WrongNumberOfArgumentsHandler(c)
}

args := cliutils.ExtractCommand(c)

// The first arg determines which native tool to run:
// jf nix nix-channel --add ... → nativeTool="nix-channel", args=["--add", ...]
// jf nix nix-env -iA ... → nativeTool="nix-env", args=["-iA", ...]
// jf nix nix-build '<nixpkgs>' → nativeTool="nix-build", args=["'<nixpkgs>'", ...]
// jf nix copy --to ... → nativeTool="copy" (runs as "nix copy"), args=["--to", ...]
nativeTool, remainingArgs := getCommandName(args)

// Extract --server-id flag before passing to native tool
var serverID string
var err error
remainingArgs, serverID, err = coreutils.ExtractServerIdFromCommand(remainingArgs)
if err != nil {
return fmt.Errorf("failed to extract server ID: %w", err)
}

// Extract build flags (--build-name, --build-number, --module, --project)
filteredArgs, buildConfiguration, err := build.ExtractBuildDetailsFromArgs(remainingArgs)
if err != nil {
return err
}

cmd := nixcommand.NewNixCommand().SetNativeTool(nativeTool).SetArgs(filteredArgs).SetBuildConfiguration(buildConfiguration)

// Pass server details — use --server-id if provided, otherwise default
var serverDetails *coreConfig.ServerDetails
if serverID != "" {
serverDetails, err = coreConfig.GetSpecificConfig(serverID, false, false)
} else {
serverDetails, err = coreConfig.GetDefaultServerConf()
}
if err == nil && serverDetails != nil {
cmd.SetServerDetails(serverDetails)
}

return commands.Exec(cmd)
}

func pythonCmd(c *cli.Context, projectType project.ProjectType) error {
if show, err := cliutils.ShowCmdHelpIfNeeded(c, c.Args()); show || err != nil {
return err
Expand Down
20 changes: 20 additions & 0 deletions docs/buildtools/nix/help.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package nix

var Usage = []string{"nix <native-command> <args> [command options]"}

func GetDescription() string {
return "Run native nix commands with build-info support."
}

func GetArguments() string {
return ` nix native-command
Wraps native Nix commands (nix-channel, nix-env, nix-build, nix copy)
with build-info collection. All args are passed through to the native tool.

Examples:
- jf nix nix-channel --add https://server/artifactory/api/nix/repo/channels/nixos-25.11 nixpkgs
- jf nix nix-channel --update
- jf nix nix-env -iA nixpkgs.hello --build-name=my-build --build-number=1
- jf nix nix-build '<nixpkgs>' -A hello --build-name=my-build --build-number=1
- jf nix copy --to "http://user:pass@server/artifactory/api/nix/repo/" ./result --build-name=my-build --build-number=1`
}
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ require (

//replace github.com/ktrysmt/go-bitbucket => github.com/ktrysmt/go-bitbucket v0.9.80

replace github.com/jfrog/jfrog-cli-artifactory => github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260518061858-57c1e4dd169f

replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.13.1-0.20260518035826-fddb561e51ce

// replace github.com/jfrog/jfrog-cli-artifactory => github.com/agrasth/jfrog-cli-artifactory v0.2.2-0.20260428100316-aa702370ec20

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.13.1-0.20260428071432-1e9d9a1991ad
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ github.com/jellydator/ttlcache/v3 v3.4.0 h1:YS4P125qQS0tNhtL6aeYkheEaB/m8HCqdMMP
github.com/jellydator/ttlcache/v3 v3.4.0/go.mod h1:Hw9EgjymziQD3yGsQdf1FqFdpp7YjFMd4Srg5EJlgD4=
github.com/jfrog/archiver/v3 v3.6.3 h1:hkAmPjBw393tPmQ07JknLNWFNZjXdy2xFEnOW9wwOxI=
github.com/jfrog/archiver/v3 v3.6.3/go.mod h1:5V9l+Fte30Y4qe9dUOAd3yNTf8lmtVNuhKNrvI8PMhg=
github.com/jfrog/build-info-go v1.13.1-0.20260514141440-b2463b51dc3a h1:+TOYHOux+EIkmJUcZvcpWcMjhwkEo0EyIkepEcAxJX8=
github.com/jfrog/build-info-go v1.13.1-0.20260514141440-b2463b51dc3a/go.mod h1:CYRUCvLKfyARjoJXLWAxce1qNUxTEtbRKAARkV42vpE=
github.com/jfrog/build-info-go v1.13.1-0.20260518035826-fddb561e51ce h1:ZjA4apQGSHzvc4frb+euhMCqLRVHKrtkCt4izy12MwM=
github.com/jfrog/build-info-go v1.13.1-0.20260518035826-fddb561e51ce/go.mod h1:+OCtMb22/D+u7Wne5lzkjJjaWr0LRZcHlDwTH86Mpwo=
github.com/jfrog/froggit-go v1.22.0 h1:eeN5F8sOUo+h2cXkzArAu4nvSdjkDTAZtgqwrct70qg=
github.com/jfrog/froggit-go v1.22.0/go.mod h1:wRDryqyp3oe+eHgME2mpnEQmO8XBECIPagFwj0nHmdI=
github.com/jfrog/go-mockhttp v0.3.1 h1:/wac8v4GMZx62viZmv4wazB5GNKs+GxawuS1u3maJH8=
Expand All @@ -418,8 +418,8 @@ github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYL
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
github.com/jfrog/jfrog-cli-application v1.0.2-0.20260511133105-55a0ab56fd64 h1:bxcy1v1LXQV4T0kVU1duWQr3h7vKfHyMD1B+IuFLWUw=
github.com/jfrog/jfrog-cli-application v1.0.2-0.20260511133105-55a0ab56fd64/go.mod h1:cKqb/JgN+XuD4RhOxvSZnyGyXw3cJsTZfQT3rk9MCho=
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260515045427-eb0cec44a4e2 h1:1nCyNPDxH2EXUz0zx2bFBViYrW/KoqGcQDH9Jm8HHs8=
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260515045427-eb0cec44a4e2/go.mod h1:XESHQN9MEeje13fJaXtbljidwTqlJO+qhhUHHDxwntQ=
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260518061858-57c1e4dd169f h1:z+84O9yTDLjoOlPteEuPR2GtlXQmIgk5c/wt8TUbjMc=
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260518061858-57c1e4dd169f/go.mod h1:A21UGxEDMfjVLNjyx5j1fmdpVd9cakKSQu10LFdFy+s=
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260515092054-cca97077293d h1:6IRzTppsSWOMIRVXmFVlnOHi0QLs5+4Mfd3sHATsRTw=
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260515092054-cca97077293d/go.mod h1:bh1ptuSLGZT4l51hl+xgUlS7sAd8K77tKn0wa5n7TQo=
github.com/jfrog/jfrog-cli-evidence v0.9.4 h1:RAqZYaH2RrzmhW+bGA7dx/yTqa4X1fZ4/5V7VVMSJtc=
Expand Down
4 changes: 2 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func setupIntegrationTests() {
InitArtifactoryTests()
}

if *tests.TestNpm || *tests.TestPnpm || *tests.TestGradle || *tests.TestMaven || *tests.TestGo || *tests.TestNuget || *tests.TestPip || *tests.TestPipenv || *tests.TestPoetry || *tests.TestConan || *tests.TestHelm || *tests.TestUv || (*tests.TestArtifactory && !*tests.TestArtifactoryProxy) || *tests.TestArtifactoryProject {
if *tests.TestNpm || *tests.TestPnpm || *tests.TestGradle || *tests.TestMaven || *tests.TestGo || *tests.TestNuget || *tests.TestPip || *tests.TestPipenv || *tests.TestPoetry || *tests.TestConan || *tests.TestHelm || *tests.TestUv || *tests.TestNix || (*tests.TestArtifactory && !*tests.TestArtifactoryProxy) || *tests.TestArtifactoryProject {
InitBuildToolsTests()
}
if *tests.TestDocker || *tests.TestPodman || *tests.TestDockerScan {
Expand Down Expand Up @@ -109,7 +109,7 @@ func tearDownIntegrationTests() {
if (*tests.TestArtifactory && !*tests.TestArtifactoryProxy) || *tests.TestArtifactoryProject {
CleanArtifactoryTests()
}
if *tests.TestNpm || *tests.TestPnpm || *tests.TestGradle || *tests.TestMaven || *tests.TestGo || *tests.TestNuget || *tests.TestPip || *tests.TestPipenv || *tests.TestPoetry || *tests.TestConan || *tests.TestHelm || *tests.TestDocker || *tests.TestPodman || *tests.TestDockerScan || (*tests.TestArtifactory && !*tests.TestArtifactoryProxy) || *tests.TestArtifactoryProject {
if *tests.TestNpm || *tests.TestPnpm || *tests.TestGradle || *tests.TestMaven || *tests.TestGo || *tests.TestNuget || *tests.TestPip || *tests.TestPipenv || *tests.TestPoetry || *tests.TestConan || *tests.TestHelm || *tests.TestNix || *tests.TestDocker || *tests.TestPodman || *tests.TestDockerScan || (*tests.TestArtifactory && !*tests.TestArtifactoryProxy) || *tests.TestArtifactoryProject {
CleanBuildToolsTests()
}
if *tests.TestDistribution {
Expand Down
Loading
Loading