Skip to content

Commit e19f799

Browse files
committed
fix(rust): replace deprecated types.function with types.functionTo
The rust kernel module was using types.function which doesn't exist in current nixpkgs versions. This causes the error: error: attribute 'function' missing Changed to use types.functionTo (types.functionTo types.attrs) which is the correct type for overlay functions that have the signature: final: prev: { ... } This aligns with how other kernels in the codebase handle function types.
1 parent 4d5f37c commit e19f799

File tree

1 file changed

+63
-59
lines changed

1 file changed

+63
-59
lines changed

modules/kernels/rust/default.nix

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@
99
inherit (lib) types;
1010

1111
kernelName = "rust";
12-
12+
1313
# Helper function to coerce overlays into a list with validation
14-
mkOverlays = overlays:
15-
let
16-
validateOverlay = overlay:
17-
if builtins.isFunction overlay then overlay
18-
else throw "Expected function, got ${builtins.typeOf overlay}";
19-
in
20-
if builtins.isFunction overlays then [ overlays ]
21-
else if builtins.isList overlays then map validateOverlay overlays
22-
else throw "Expected a function or list of functions for overlays";
14+
mkOverlays = overlays: let
15+
validateOverlay = overlay:
16+
if builtins.isFunction overlay
17+
then overlay
18+
else throw "Expected function, got ${builtins.typeOf overlay}";
19+
in
20+
if builtins.isFunction overlays
21+
then [overlays]
22+
else if builtins.isList overlays
23+
then map validateOverlay overlays
24+
else throw "Expected a function or list of functions for overlays";
2325

2426
kernelOptions = {
2527
config,
@@ -86,56 +88,57 @@
8688
}
8789
// extraKernelSpc;
8890
in {
89-
options = {
90-
evcxr = lib.mkOption {
91-
type = types.package;
92-
default = config.nixpkgs.evcxr;
93-
example = lib.literalExpression "pkgs.evcxr";
94-
description = ''
95-
An evaluation context for Rust.
96-
'';
97-
};
91+
options =
92+
{
93+
evcxr = lib.mkOption {
94+
type = types.package;
95+
default = config.nixpkgs.evcxr;
96+
example = lib.literalExpression "pkgs.evcxr";
97+
description = ''
98+
An evaluation context for Rust.
99+
'';
100+
};
98101

99-
# Allow users to pass one or more overlay functions directly
100-
overlays = lib.mkOption {
101-
type = types.listOf types.function;
102-
default = [ self.inputs.rust-overlay.overlays.default ];
103-
defaultText = lib.literalExpression "[ self.inputs.rust-overlay.overlays.default ]";
104-
example = lib.literalExpression "[ myCustomOverlay ]";
105-
description = ''
106-
A list of nixpkgs overlay functions to apply when building the Rust kernel.
107-
Each overlay should have the form: `final: prev: { … }`.
108-
'';
109-
};
102+
# Allow users to pass one or more overlay functions directly
103+
overlays = lib.mkOption {
104+
type = types.listOf (types.functionTo (types.functionTo types.attrs));
105+
default = [self.inputs.rust-overlay.overlays.default];
106+
defaultText = lib.literalExpression "[ self.inputs.rust-overlay.overlays.default ]";
107+
example = lib.literalExpression "[ myCustomOverlay ]";
108+
description = ''
109+
A list of nixpkgs overlay functions to apply when building the Rust kernel.
110+
Each overlay should have the form: `final: prev: { … }`.
111+
'';
112+
};
110113

111-
# Allow users to pin or replace the nixpkgs they want
112-
nixpkgs = lib.mkOption {
113-
type = types.submodule {
114-
options = {
115-
path = lib.mkOption {
116-
type = types.path;
117-
default = self.inputs.nixpkgs;
118-
defaultText = lib.literalExpression "self.inputs.nixpkgs";
119-
example = lib.literalExpression "self.inputs.nixpkgs";
120-
description = "Path (or flake URL) of the nixpkgs to use for Rust.";
121-
};
122-
extraOverlays = lib.mkOption {
123-
type = types.listOf types.function;
124-
default = [];
125-
example = lib.literalExpression "[ (import ./my-overlay.nix) ]";
126-
description = "Additional overlay functions to merge with `overlays`.";
114+
# Allow users to pin or replace the nixpkgs they want
115+
nixpkgs = lib.mkOption {
116+
type = types.submodule {
117+
options = {
118+
path = lib.mkOption {
119+
type = types.path;
120+
default = self.inputs.nixpkgs;
121+
defaultText = lib.literalExpression "self.inputs.nixpkgs";
122+
example = lib.literalExpression "self.inputs.nixpkgs";
123+
description = "Path (or flake URL) of the nixpkgs to use for Rust.";
124+
};
125+
extraOverlays = lib.mkOption {
126+
type = types.listOf (types.functionTo (types.functionTo types.attrs));
127+
default = [];
128+
example = lib.literalExpression "[ (import ./my-overlay.nix) ]";
129+
description = "Additional overlay functions to merge with `overlays`.";
130+
};
127131
};
128132
};
133+
default = {
134+
path = self.inputs.nixpkgs;
135+
extraOverlays = [];
136+
};
137+
description = "Configuration for the nixpkgs instance used by the Rust kernel.";
129138
};
130-
default = {
131-
path = self.inputs.nixpkgs;
132-
extraOverlays = [];
133-
};
134-
description = "Configuration for the nixpkgs instance used by the Rust kernel.";
135-
};
136-
}
137-
// kernelModule.options;
138-
139+
}
140+
// kernelModule.options;
141+
139142
config = lib.mkIf config.enable {
140143
build = mkKernel (kernelFunc config.kernelArgs);
141144
kernelArgs =
@@ -145,10 +148,11 @@
145148
# Import nixpkgs with all overlays applied
146149
pkgs = let
147150
allOverlays = config.overlays ++ config.nixpkgs.extraOverlays;
148-
in import config.nixpkgs.path {
149-
inherit system;
150-
overlays = allOverlays;
151-
};
151+
in
152+
import config.nixpkgs.path {
153+
inherit system;
154+
overlays = allOverlays;
155+
};
152156
};
153157
};
154158
};

0 commit comments

Comments
 (0)