trivionomicon/modules/nix-registry: initial commit

This commit is contained in:
Alejandro Soto 2025-08-24 18:49:47 -06:00
parent 7daa3d91b3
commit 111d3dabf2
3 changed files with 58 additions and 0 deletions

View file

@ -0,0 +1,16 @@
{
config,
lib,
pkgs,
doctrine,
flakes,
...
}:
doctrine.lib.mkModule {
inherit config;
name = "nix-registry";
hm = ./hm.nix;
options = ./options.nix;
passthru = {inherit flakes;};
}

View file

@ -0,0 +1,23 @@
{
pkgs,
lib,
cfg,
flakes,
...
}: let
registryName = name:
if name == "self"
then cfg.renameSelf
else name;
registryFilter = {
nixpkgs = true;
unstable = true;
self = cfg.renameSelf != null;
};
in {
nix.registry =
lib.mapAttrs'
(name: value: lib.nameValuePair (registryName name) {flake = value;})
(lib.filterAttrs (name: _: registryFilter.${name} or cfg.allInputs) flakes);
}

View file

@ -0,0 +1,19 @@
{lib, ...}:
with lib.types; {
hm = {
allInputs = mkOption {
type = bool;
default = default;
description = ''
Include all flake inputs. If false, only 'nixpkgs' and 'unstable'
(if available) will be added to the flake registry by default.
'';
};
renameSelf = mkOption {
type = nullOr str;
default = "self";
description = "Registry name to use for the 'self' input";
};
};
}