forked from anduril/jetpack-nixos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnvpmodel.nix
49 lines (42 loc) · 1.45 KB
/
nvpmodel.nix
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
{ config, lib, pkgs, ... }:
let
inherit (lib)
mkEnableOption
mkIf
mkOption
types;
cfg = config.services.nvpmodel;
in
{
options = {
services.nvpmodel = {
enable = mkEnableOption "NVPModel";
configFile = mkOption {
description = "config file name from l4t-nvpmodel package to use";
type = types.path;
};
profileNumber = mkOption {
description = "ID integer of POWER_MODEL to use from nvpmodel config file. If null, nvpmodel will use the PM_CONFIG DEFAULT setting from the configFile";
default = null;
type = types.nullOr types.int;
};
};
};
config = mkIf cfg.enable {
# https://developer.ridgerun.com/wiki/index.php/Xavier/JetPack_5.0.2/Performance_Tuning
systemd.services.nvpmodel = mkIf cfg.enable {
enable = true;
description = "Set NVPModel power profile";
serviceConfig = {
Type = "oneshot";
Restart = "on-failure";
RestartSec = "2s";
ExecStart = "${pkgs.nvidia-jetpack.l4t-nvpmodel}/bin/nvpmodel -f ${cfg.configFile}" + lib.optionalString (cfg.profileNumber != null) " -m ${builtins.toString cfg.profileNumber}";
};
wantedBy = [ "multi-user.target" ];
};
environment.etc."nvpmodel.conf".source = cfg.configFile;
environment.etc."nvpmodel".source = "${pkgs.nvidia-jetpack.l4t-nvpmodel}/etc/nvpmodel";
environment.systemPackages = with pkgs.nvidia-jetpack; [ l4t-nvpmodel ];
};
}