diff options
| author | Quentin Gliech <quentingliech@gmail.com> | 2020-12-22 19:44:21 +0100 |
|---|---|---|
| committer | Quentin Gliech <quentingliech@gmail.com> | 2020-12-22 19:44:21 +0100 |
| commit | 456f17b4d9ecc8c2aa86be07b1829f8b59d331d0 (patch) | |
| tree | 9daad769f0b8d6b824151c4e4d9081c94d1e9ef5 /modules | |
| parent | 8834df431736c3037bbef017b24c62bc4ace4645 (diff) | |
nix.registry option
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/nix/default.nix | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/modules/nix/default.nix b/modules/nix/default.nix index 2f8f001..09b4e63 100644 --- a/modules/nix/default.nix +++ b/modules/nix/default.nix @@ -345,6 +345,58 @@ in ordering will be used. ''; }; + + nix.registry = mkOption { + type = types.attrsOf (types.submodule ( + let + inputAttrs = types.attrsOf (types.oneOf [types.str types.int types.bool types.package]); + in + { config, name, ... }: + { options = { + from = mkOption { + type = inputAttrs; + example = { type = "indirect"; id = "nixpkgs"; }; + description = "The flake reference to be rewritten."; + }; + to = mkOption { + type = inputAttrs; + example = { type = "github"; owner = "my-org"; repo = "my-nixpkgs"; }; + description = "The flake reference to which <option>from></option> is to be rewritten."; + }; + flake = mkOption { + type = types.unspecified; + default = null; + example = literalExample "nixpkgs"; + description = '' + The flake input to which <option>from></option> is to be rewritten. + ''; + }; + 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) + ({ type = "path"; + path = config.flake.outPath; + } // lib.filterAttrs + (n: v: n == "lastModified" || n == "rev" || n == "revCount" || n == "narHash") + config.flake); + }; + } + )); + default = {}; + description = '' + A system-wide flake registry. + ''; + }; }; config = { @@ -385,6 +437,11 @@ in "c4ecc3d541c163c8fcc954ccae6b8cab28c973dc283fea5995c69aaabcdf785f" # nix installer ]; + environment.etc."nix/registry.json".text = builtins.toJSON { + version = 2; + flakes = mapAttrsToList (n: v: { inherit (v) from to exact; }) cfg.registry; + }; + # List of machines for distributed Nix builds in the format # expected by build-remote. environment.etc."nix/machines" = |
