Skip to content

Commit 8be0c07

Browse files
committed
nix-flakes.nix: inherit from upstream nix-flakes.nix
1 parent 1685914 commit 8be0c07

File tree

1 file changed

+5
-76
lines changed

1 file changed

+5
-76
lines changed

modules/environment/nix-flakes.nix

+5-76
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# (Copyright (c) 2003-2022 Eelco Dolstra and the Nixpkgs/NixOS contributors,
66
# licensed under MIT License as well)
77

8-
{ config, lib, pkgs, ... }:
8+
{ config, lib, pkgs, nixpkgs, ... }:
99

1010
with lib;
1111

@@ -14,79 +14,8 @@ let
1414
in
1515

1616
{
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+
];
9221
}

0 commit comments

Comments
 (0)