Skip to content

Commit 3596eec

Browse files
committed
add method to generate a correct apx configuration
1 parent 9dc9baa commit 3596eec

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

settings/config.go

+18-4
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,25 @@ func GetApxDefaultConfig() (*Config, error) {
6464
// fmt.Printf("Using config file: %s\n\n", viper.ConfigFileUsed())
6565
// }
6666

67+
Cnf := NewApxConfig(
68+
viper.GetString("apxPath"),
69+
viper.GetString("distroboxPath"),
70+
viper.GetString("storageDriver"),
71+
)
72+
return Cnf, nil
73+
}
74+
75+
func NewApxConfig(apxPath, distroboxPath, storageDriver string) *Config {
76+
userHome, err := os.UserHomeDir()
77+
if err != nil {
78+
panic(err)
79+
}
80+
6781
Cnf := &Config{
6882
// Common
69-
ApxPath: viper.GetString("apxPath"),
70-
DistroboxPath: viper.GetString("distroboxPath"),
71-
StorageDriver: viper.GetString("storageDriver"),
83+
ApxPath: apxPath,
84+
DistroboxPath: distroboxPath,
85+
StorageDriver: storageDriver,
7286

7387
// Virtual
7488
ApxStoragePath: "",
@@ -86,5 +100,5 @@ func GetApxDefaultConfig() (*Config, error) {
86100
Cnf.PkgManagersPath = filepath.Join(Cnf.ApxPath, "package-managers")
87101
Cnf.UserPkgManagersPath = filepath.Join(Cnf.UserApxPath, "package-managers")
88102

89-
return Cnf, nil
103+
return Cnf
90104
}

0 commit comments

Comments
 (0)