mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
nix: Add registry option
This commit is contained in:
parent
1a8ae407f5
commit
5c5c44b5b7
1 changed files with 64 additions and 0 deletions
|
|
@ -46,6 +46,65 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
registry = mkOption {
|
||||
type = types.attrsOf (types.submodule (
|
||||
let
|
||||
referenceAttrs = with types; attrsOf (oneOf [
|
||||
str
|
||||
int
|
||||
bool
|
||||
package
|
||||
]);
|
||||
in
|
||||
{ config, name, ... }:
|
||||
{
|
||||
options = {
|
||||
from = mkOption {
|
||||
type = referenceAttrs;
|
||||
example = { type = "indirect"; id = "nixpkgs"; };
|
||||
description = "The flake reference to be rewritten.";
|
||||
};
|
||||
to = mkOption {
|
||||
type = referenceAttrs;
|
||||
example = { type = "github"; owner = "my-org"; repo = "my-nixpkgs"; };
|
||||
description = "The flake reference <option>from</option> is rewritten to.";
|
||||
};
|
||||
flake = mkOption {
|
||||
type = types.nullOr types.attrs;
|
||||
default = null;
|
||||
example = literalExpression "nixpkgs";
|
||||
description = ''
|
||||
The flake input <option>from</option> is rewritten to.
|
||||
'';
|
||||
};
|
||||
exact = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether the <option>from</option> reference needs to match exactly. If set,
|
||||
a <option>from</option> reference like <literal>nixpkgs</literal> does not
|
||||
match with a reference like <literal>nixpkgs/nixos-20.03</literal>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
config = {
|
||||
from = mkDefault { type = "indirect"; id = name; };
|
||||
to = mkIf (config.flake != null) (mkDefault
|
||||
{
|
||||
type = "path";
|
||||
path = config.flake.outPath;
|
||||
} // filterAttrs
|
||||
(n: _: n == "lastModified" || n == "rev" || n == "revCount" || n == "narHash")
|
||||
config.flake);
|
||||
};
|
||||
}
|
||||
));
|
||||
default = { };
|
||||
description = ''
|
||||
A system-wide flake registry.
|
||||
'';
|
||||
};
|
||||
|
||||
substituters = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
|
|
@ -86,6 +145,11 @@ in
|
|||
trusted-public-keys = ${concatStringsSep " " cfg.trustedPublicKeys}
|
||||
${cfg.extraConfig}
|
||||
'';
|
||||
|
||||
"nix/registry.json".text = builtins.toJSON {
|
||||
version = 2;
|
||||
flakes = mapAttrsToList (n: v: { inherit (v) from to exact; }) cfg.registry;
|
||||
};
|
||||
};
|
||||
|
||||
nix = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue