mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-24 06:33:42 +00:00
32 lines
792 B
Nix
32 lines
792 B
Nix
|
{ config, lib, pkgs, ... }:
|
||
|
|
||
|
with lib;
|
||
|
|
||
|
let
|
||
|
cfg = config.services.preload;
|
||
|
in {
|
||
|
meta = { maintainers = pkgs.preload.meta.maintainers; };
|
||
|
|
||
|
options.services.preload = {
|
||
|
enable = mkEnableOption "preload";
|
||
|
package = mkPackageOption pkgs "preload" { };
|
||
|
};
|
||
|
|
||
|
config = mkIf cfg.enable {
|
||
|
systemd.services.preload = {
|
||
|
description = "Loads data into ram during idle time of CPU.";
|
||
|
wantedBy = [ "multi-user.target" ];
|
||
|
|
||
|
serviceConfig = {
|
||
|
EnvironmentFile = "${cfg.package}/etc/conf.d/preload";
|
||
|
ExecStart = "${getExe cfg.package} --foreground $PRELOAD_OPTS";
|
||
|
Type = "simple";
|
||
|
# Only preload data during CPU idle time
|
||
|
IOSchedulingClass = 3;
|
||
|
DynamicUser = true;
|
||
|
StateDirectory = "preload";
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
}
|