diff --git a/cmd/nvidia-container-runtime-hook/main.go b/cmd/nvidia-container-runtime-hook/main.go index cbaf9e23..05390396 100644 --- a/cmd/nvidia-container-runtime-hook/main.go +++ b/cmd/nvidia-container-runtime-hook/main.go @@ -174,6 +174,7 @@ func main() { Name: "config", Destination: &a.configFile, Usage: "The path to the configuration file to use", + EnvVars: []string{config.FilePathOverrideEnvVar}, }, } diff --git a/internal/config/config.go b/internal/config/config.go index 33b8ba4d..3cb7541d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -30,6 +30,8 @@ import ( ) const ( + FilePathOverrideEnvVar = "NVCTK_CONFIG_FILE_PATH" + configOverride = "XDG_CONFIG_HOME" configFilePath = "nvidia-container-runtime/config.toml" @@ -71,6 +73,9 @@ type Config struct { // GetConfigFilePath returns the path to the config file for the configured system func GetConfigFilePath() string { + if configFilePathOverride := os.Getenv(FilePathOverrideEnvVar); configFilePathOverride != "" { + return configFilePathOverride + } if XDGConfigDir := os.Getenv(configOverride); len(XDGConfigDir) != 0 { return filepath.Join(XDGConfigDir, configFilePath) }