|
5 | 5 | # (Copyright (c) 2003-2022 Eelco Dolstra and the Nixpkgs/NixOS contributors,
|
6 | 6 | # licensed under MIT License as well)
|
7 | 7 |
|
8 |
| -{ config, lib, pkgs, ... }: |
| 8 | +{ config, lib, pkgs, nixpkgs, ... }: |
9 | 9 |
|
10 | 10 | with lib;
|
11 | 11 |
|
|
14 | 14 | in
|
15 | 15 |
|
16 | 16 | {
|
17 |
| - ###### interface |
18 |
| - |
19 |
| - options = { |
20 |
| - nix = { |
21 |
| - registry = mkOption { |
22 |
| - type = types.attrsOf (types.submodule ( |
23 |
| - let |
24 |
| - referenceAttrs = with types; attrsOf (oneOf [ |
25 |
| - str |
26 |
| - int |
27 |
| - bool |
28 |
| - package |
29 |
| - ]); |
30 |
| - in |
31 |
| - { config, name, ... }: |
32 |
| - { |
33 |
| - options = { |
34 |
| - from = mkOption { |
35 |
| - type = referenceAttrs; |
36 |
| - example = { type = "indirect"; id = "nixpkgs"; }; |
37 |
| - description = "The flake reference to be rewritten."; |
38 |
| - }; |
39 |
| - to = mkOption { |
40 |
| - type = referenceAttrs; |
41 |
| - example = { type = "github"; owner = "my-org"; repo = "my-nixpkgs"; }; |
42 |
| - description = "The flake reference <option>from</option> is rewritten to."; |
43 |
| - }; |
44 |
| - flake = mkOption { |
45 |
| - type = types.nullOr types.attrs; |
46 |
| - default = null; |
47 |
| - example = literalExpression "nixpkgs"; |
48 |
| - description = '' |
49 |
| - The flake input <option>from</option> is rewritten to. |
50 |
| - ''; |
51 |
| - }; |
52 |
| - exact = mkOption { |
53 |
| - type = types.bool; |
54 |
| - default = true; |
55 |
| - description = '' |
56 |
| - Whether the <option>from</option> reference needs to match exactly. If set, |
57 |
| - a <option>from</option> reference like <literal>nixpkgs</literal> does not |
58 |
| - match with a reference like <literal>nixpkgs/nixos-20.03</literal>. |
59 |
| - ''; |
60 |
| - }; |
61 |
| - }; |
62 |
| - config = { |
63 |
| - from = mkDefault { type = "indirect"; id = name; }; |
64 |
| - to = mkIf (config.flake != null) (mkDefault |
65 |
| - { |
66 |
| - type = "path"; |
67 |
| - path = config.flake.outPath; |
68 |
| - } // filterAttrs |
69 |
| - (n: _: n == "lastModified" || n == "rev" || n == "revCount" || n == "narHash") |
70 |
| - config.flake); |
71 |
| - }; |
72 |
| - } |
73 |
| - )); |
74 |
| - default = { }; |
75 |
| - description = "A system-wide flake registry."; |
76 |
| - }; |
77 |
| - }; |
78 |
| - }; |
79 |
| - |
80 |
| - |
81 |
| - ###### implementation |
82 |
| - |
83 |
| - config = { |
84 |
| - environment.etc = { |
85 |
| - "nix/registry.json".text = builtins.toJSON { |
86 |
| - version = 2; |
87 |
| - flakes = mapAttrsToList (_n: v: { inherit (v) from to exact; }) cfg.registry; |
88 |
| - }; |
89 |
| - }; |
90 |
| - }; |
91 |
| - |
| 17 | + imports = [ |
| 18 | + # Use options and config from upstream nix-flakes.nix |
| 19 | + "${nixpkgs}nixos/modules/config/nix-flakes.nix" |
| 20 | + ]; |
92 | 21 | }
|
0 commit comments