diff --git a/docs/advanced/global_configuration.md b/docs/advanced/global_configuration.md index 0919e425f..10c74e97c 100644 --- a/docs/advanced/global_configuration.md +++ b/docs/advanced/global_configuration.md @@ -21,28 +21,41 @@ loaded in the following order: ## Reference +??? info "Casing In Configuration" + In versions of pixi `0.20.1` and older the global configuration used snake_case + we've changed to `kebab-case` for consistency with the rest of the configuration. + But we still support the old `snake_case` configuration, for older configuration options. + These are: + + - `default_channels` + - `change_ps1` + - `tls_no_verify` + - `authentication_override_file` + - `mirrors` and sub-options + - `repodata-config` and sub-options + The following reference describes all available configuration options. ```toml # The default channels to select when running `pixi init` or `pixi global install`. # This defaults to only conda-forge. -default_channels = ["conda-forge"] +default-channels = ["conda-forge"] # When set to false, the `(pixi)` prefix in the shell prompt is removed. # This applies to the `pixi shell` subcommand. # You can override this from the CLI with `--change-ps1`. -change_ps1 = true +change-ps1 = true # When set to true, the TLS certificates are not verified. Note that this is a # security risk and should only be used for testing purposes or internal networks. # You can override this from the CLI with `--tls-no-verify`. -tls_no_verify = false +tls-no-verify = false # Override from where the authentication information is loaded. # Usually we try to use the keyring to load authentication data from, and only use a JSON # file as fallback. This option allows you to force the use of a JSON file. # Read more in the authentication section. -authentication_override_file = "/path/to/your/override.json" +authentication-override-file = "/path/to/your/override.json" # configuration for conda channel-mirrors [mirrors] @@ -60,13 +73,13 @@ authentication_override_file = "/path/to/your/override.json" "https://prefix.dev/bioconda", ] -[repodata_options] +[repodata-config] # disable fetching of jlap, bz2 or zstd repodata files. # This should only be used for specific old versions of artifactory and other non-compliant # servers. -disable_jlap = true # don't try to download repodata.jlap -disable_bzip2 = true # don't try to download repodata.json.bz2 -disable_zstd = true # don't try to download repodata.json.zst +disable-jlap = true # don't try to download repodata.jlap +disable-bzip2 = true # don't try to download repodata.json.bz2 +disable-zstd = true # don't try to download repodata.json.zst ``` ## Mirror configuration diff --git a/src/config.rs b/src/config.rs index 888ed624c..466cac7a4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -106,40 +106,50 @@ pub struct ConfigCliPrompt { #[derive(Clone, Default, Debug, Deserialize)] pub struct RepodataConfig { /// Disable JLAP compression for repodata. + #[serde(alias = "disable-jlap")] // BREAK: rename instead of alias pub disable_jlap: Option, /// Disable bzip2 compression for repodata. + #[serde(alias = "disable-bzip2")] // BREAK: rename instead of alias pub disable_bzip2: Option, /// Disable zstd compression for repodata. + #[serde(alias = "disable-zstd")] // BREAK: rename instead of alias pub disable_zstd: Option, } #[derive(Clone, Debug, Deserialize)] pub struct Config { #[serde(default)] + #[serde(alias = "default-channels")] // BREAK: rename instead of alias pub default_channels: Vec, /// If set to true, pixi will set the PS1 environment variable to a custom value. #[serde(default)] + #[serde(alias = "change-ps1")] // BREAK: rename instead of alias change_ps1: Option, /// Path to the file containing the authentication token. #[serde(default)] + #[serde(alias = "authentication-override-file")] // BREAK: rename instead of alias authentication_override_file: Option, /// If set to true, pixi will not verify the TLS certificate of the server. #[serde(default)] + #[serde(alias = "tls-no-verify")] // BREAK: rename instead of alias tls_no_verify: Option, #[serde(default)] mirrors: HashMap>, #[serde(skip)] + #[serde(alias = "loaded-from")] // BREAK: rename instead of alias pub loaded_from: Vec, #[serde(skip, default = "default_channel_config")] + #[serde(alias = "channel-config")] // BREAK: rename instead of alias pub channel_config: ChannelConfig, /// Configuration for repodata fetching. + #[serde(alias = "repodata-config")] // BREAK: rename instead of alias pub repodata_config: Option, } @@ -397,4 +407,56 @@ mod tests { let debug = debug.replace(&d.to_str().unwrap().replace('\\', "/"), "path"); insta::assert_snapshot!(debug); } + + #[test] + fn test_parse_kebab_and_snake_case() { + let toml = r#" + default_channels = ["conda-forge"] + change_ps1 = true + tls_no_verify = false + authentication_override_file = "/path/to/your/override.json" + [mirrors] + "https://conda.anaconda.org/conda-forge" = [ + "https://prefix.dev/conda-forge" + ] + [repodata_config] + disable_jlap = true + disable_bzip2 = true + disable_zstd = true + "#; + let config = Config::from_toml(toml, &PathBuf::from("")).unwrap(); + assert_eq!(config.default_channels, vec!["conda-forge"]); + assert_eq!(config.tls_no_verify, Some(false)); + assert_eq!( + config.authentication_override_file, + Some(PathBuf::from("/path/to/your/override.json")) + ); + assert_eq!(config.change_ps1, Some(true)); + assert_eq!( + config + .mirrors + .get(&Url::parse("https://conda.anaconda.org/conda-forge").unwrap()), + Some(&vec![Url::parse("https://prefix.dev/conda-forge").unwrap()]) + ); + let repodata_config = config.repodata_config.unwrap(); + assert_eq!(repodata_config.disable_jlap, Some(true)); + assert_eq!(repodata_config.disable_bzip2, Some(true)); + assert_eq!(repodata_config.disable_zstd, Some(true)); + // See if the toml parses in kebab-case + let toml = r#" + default-channels = ["conda-forge"] + change-ps1 = true + tls-no-verify = false + authentication-override-file = "/path/to/your/override.json" + [mirrors] + "https://conda.anaconda.org/conda-forge" = [ + "https://prefix.dev/conda-forge" + ] + [repodata-config] + disable-jlap = true + disable-bzip2 = true + disable-zstd = true + "#; + Config::from_toml(toml, &PathBuf::from("")).unwrap(); + } }