1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-06 00:51:00 +01:00

Add a system-wide flake registry /etc/nix/registry.json

One application for this is pinning the 'nixpkgs' flake to the exact
revision used to build the NixOS system, e.g.

  {
      "flakes": [
          {
              "from": {
                  "id": "nixpkgs",
                  "type": "indirect"
              },
              "to": {
                  "owner": "NixOS",
                  "repo": "nixpkgs",
                  "type": "github",
                  "rev": "b0c285807d6a9f1b7562ec417c24fa1a30ecc31a"
              }
          }
      ],
      "version": 2
  }
This commit is contained in:
Eelco Dolstra 2020-04-01 22:56:50 +02:00
parent 36c34c3b1f
commit 77ffaea4fa
3 changed files with 21 additions and 4 deletions

View file

@ -96,6 +96,18 @@ void Registry::remove(const std::shared_ptr<const Input> & input)
++i;
}
static Path getSystemRegistryPath()
{
return settings.nixConfDir + "/registry.json";
}
static std::shared_ptr<Registry> 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<Registry> getUserRegistry()
{
return Registry::read(getUserRegistryPath(), Registry::User);
static auto userRegistry =
Registry::read(getUserRegistryPath(), Registry::User);
return userRegistry;
}
static std::shared_ptr<Registry> flagRegistry =
@ -145,6 +159,7 @@ Registries getRegistries(ref<Store> store)
Registries registries;
registries.push_back(getFlagRegistry());
registries.push_back(getUserRegistry());
registries.push_back(getSystemRegistry());
registries.push_back(getGlobalRegistry(store));
return registries;
}