-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlib.nix
More file actions
56 lines (49 loc) · 1.32 KB
/
Copy pathlib.nix
File metadata and controls
56 lines (49 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# SPDX-FileCopyrightText: 2026 Kirill Elagin <https://kir.elagin.me/>
#
# SPDX-License-Identifier: MPL-2.0 OR MIT
{ lib }:
rec {
# Helper module that provides common options for spec-based kernel types.
specKernel = { config, ... }: {
imports = [
./module.nix
];
options = {
extraPath = lib.mkOption {
type = lib.types.listOf lib.types.path;
description = "Extra directories to add to PATH in the kernel";
default = [ ];
example = lib.literalExpression ''[ "''${lib.getBin pkgs.hello}/bin" ]'';
};
};
config = {
spec.env = lib.mkIf (config.extraPath != []) {
PATH = lib.concatStringsSep ":" (config.extraPath ++ [ "\${PATH}" ]);
};
};
};
# Utility that evaluates a kernel spec (e.g. for testing).
evalKernelSpec = pkgs: name: spec:
lib.evalModules {
modules = [
./module.nix
{
options = {
outDir = lib.mkOption {
type = lib.types.package;
internal = true;
readOnly = true;
};
};
config = {
_module.args = {
inherit name pkgs;
};
inherit spec;
};
}
];
};
buildKernelSpec = pkgs: name: spec:
(evalKernelSpec pkgs name spec).config.outDir;
}