Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 50 lines 2.2 kB view raw
1diff --git a/plugin/install/install.go b/plugin/install/install.go 2index 60c61550..d7573c2d 100644 3--- a/plugin/install/install.go 4+++ b/plugin/install/install.go 5@@ -151,6 +151,7 @@ func isOSCompatible(zipfile string) bool { 6 7 // InstallPluginFromZipFile installs plugin from given zip file 8 func InstallPluginFromZipFile(zipFile string, pluginName string) InstallResult { 9+ CheckForNixStore(fmt.Sprintf("Tried to install the plugin `%s`.", pluginName)) 10 if !isPlatformIndependent(zipFile) && !isOSCompatible(zipFile) { 11 err := fmt.Errorf("provided plugin is not compatible with OS %s %s", runtime.GOOS, runtime.GOARCH) 12 return installError(err) 13@@ -314,6 +315,7 @@ func runPlatformCommands(commands platformSpecificCommand, workingDir string) er 14 // UninstallPlugin uninstall the given plugin of the given uninstallVersion 15 // If uninstallVersion is not specified, it uninstalls all the versions of given plugin 16 func UninstallPlugin(pluginName string, uninstallVersion string) { 17+ CheckForNixStore(fmt.Sprintf("Tried to uninstall the plugin `%s`.", pluginName)) 18 pluginsHome, err := common.GetPrimaryPluginsInstallDir() 19 if err != nil { 20 logger.Fatalf(true, "Failed to uninstall plugin %s. %s", pluginName, err.Error()) 21@@ -518,6 +520,7 @@ func AllPlugins(silent, languageOnly bool) { 22 23 // UpdatePlugins updates all the currently installed plugins to its latest version 24 func UpdatePlugins(silent bool) { 25+ CheckForNixStore("Tried to update plugins") 26 var failedPlugin []string 27 pluginInfos, err := pluginInfo.GetPluginsInfo() 28 if err != nil { 29@@ -673,3 +676,21 @@ func AddPluginToProject(pluginName string) error { 30 logger.Infof(true, "Plugin %s was successfully added to the project\n", pluginName) 31 return nil 32 } 33+ 34+func CheckForNixStore(message string) error { 35+ installDir, err := common.GetPrimaryPluginsInstallDir() 36+ if err != nil { 37+ return err 38+ } 39+ if strings.HasPrefix(installDir, "/nix/store") { 40+ 41+ // check if we're installing in the sandbox 42+ if os.Getenv("NIX_GAUGE_IN_SANDBOX") == "true" { 43+ return nil 44+ } 45+ logger.Errorf(true, "%s\ngauge is installed with nix.\nPlease install plugins using nix or use the `gauge-unwrapped` package.", message) 46+ os.Exit(1) 47+ 48+ } 49+ return nil 50+}