diff --git a/src/libfetchers/registry.cc b/src/libfetchers/registry.cc index 34e63180c..08dbe797e 100644 --- a/src/libfetchers/registry.cc +++ b/src/libfetchers/registry.cc @@ -96,6 +96,18 @@ void Registry::remove(const std::shared_ptr & input) ++i; } +static Path getSystemRegistryPath() +{ + return settings.nixConfDir + "/registry.json"; +} + +static std::shared_ptr getSystemRegistry() +{ + static auto systemRegistry = + Registry::read(getSystemRegistryPath(), Registry::System); + return systemRegistry; +} + Path getUserRegistryPath() { return getHome() + "/.config/nix/registry.json"; @@ -103,7 +115,9 @@ Path getUserRegistryPath() std::shared_ptr getUserRegistry() { - return Registry::read(getUserRegistryPath(), Registry::User); + static auto userRegistry = + Registry::read(getUserRegistryPath(), Registry::User); + return userRegistry; } static std::shared_ptr flagRegistry = @@ -145,6 +159,7 @@ Registries getRegistries(ref store) Registries registries; registries.push_back(getFlagRegistry()); registries.push_back(getUserRegistry()); + registries.push_back(getSystemRegistry()); registries.push_back(getGlobalRegistry(store)); return registries; } diff --git a/src/libfetchers/registry.hh b/src/libfetchers/registry.hh index d2eb7749b..5e8857850 100644 --- a/src/libfetchers/registry.hh +++ b/src/libfetchers/registry.hh @@ -12,7 +12,8 @@ struct Registry enum RegistryType { Flag = 0, User = 1, - Global = 2, + System = 2, + Global = 3, }; RegistryType type; diff --git a/src/nix/flake.cc b/src/nix/flake.cc index 2cc61932d..16b797de8 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -67,8 +67,9 @@ struct CmdFlakeList : EvalCommand for (auto & entry : registry->entries) { // FIXME: format nicely std::cout << fmt("%s %s %s\n", - registry->type == Registry::Flag ? "flags " : - registry->type == Registry::User ? "user " : + registry->type == Registry::Flag ? "flags " : + registry->type == Registry::User ? "user " : + registry->type == Registry::System ? "system" : "global", std::get<0>(entry)->to_string(), std::get<1>(entry)->to_string());