diff --git a/StabilityMatrix.Avalonia/ViewModels/Settings/MainSettingsViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Settings/MainSettingsViewModel.cs index 0da8ab4c..c02c396b 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Settings/MainSettingsViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Settings/MainSettingsViewModel.cs @@ -365,7 +365,7 @@ public partial class MainSettingsViewModel : PageViewModelBase var viewModel = dialogFactory.Get(); // Load current settings - var current = settingsManager.Settings.EnvironmentVariables ?? new Dictionary(); + var current = settingsManager.Settings.UserEnvironmentVariables ?? new Dictionary(); viewModel.EnvVars = new ObservableCollection( current.Select(kvp => new EnvVarKeyPair(kvp.Key, kvp.Value)) ); @@ -385,7 +385,7 @@ public partial class MainSettingsViewModel : PageViewModelBase .EnvVars.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Key)) .GroupBy(kvp => kvp.Key, StringComparer.Ordinal) .ToDictionary(g => g.Key, g => g.First().Value, StringComparer.Ordinal); - settingsManager.Transaction(s => s.EnvironmentVariables = newEnvVars); + settingsManager.Transaction(s => s.UserEnvironmentVariables = newEnvVars); } } diff --git a/StabilityMatrix.Core/Models/Settings/Settings.cs b/StabilityMatrix.Core/Models/Settings/Settings.cs index bf5e080f..01e22fd2 100644 --- a/StabilityMatrix.Core/Models/Settings/Settings.cs +++ b/StabilityMatrix.Core/Models/Settings/Settings.cs @@ -110,7 +110,18 @@ public class Settings public bool IsDiscordRichPresenceEnabled { get; set; } - public Dictionary? EnvironmentVariables { get; set; } + [JsonIgnore] + public Dictionary DefaultEnvironmentVariables { get; } = + new() { ["SETUPTOOLS_USE_DISTUTILS"] = "stdlib" }; + + [JsonPropertyName("EnvironmentVariables")] + public Dictionary? UserEnvironmentVariables { get; set; } + + [JsonIgnore] + public IReadOnlyDictionary EnvironmentVariables => + DefaultEnvironmentVariables + .Concat(UserEnvironmentVariables ?? []) + .ToDictionary(x => x.Key, x => x.Value); public HashSet? InstalledModelHashes { get; set; } = new();