mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 08:23:09 +00:00
29027fd1e1
Using pkgs.lib on the spine of module evaluation is problematic because the pkgs argument depends on the result of module evaluation. To prevent an infinite recursion, pkgs and some of the modules are evaluated twice, which is inefficient. Using ‘with lib’ prevents this problem.
43 lines
1.0 KiB
Nix
43 lines
1.0 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.prey;
|
|
myPrey = pkgs."prey-bash-client".override {
|
|
apiKey = cfg.apiKey;
|
|
deviceKey = cfg.deviceKey;
|
|
};
|
|
in {
|
|
options = {
|
|
|
|
services.prey = {
|
|
enable = mkOption {
|
|
default = false;
|
|
type = types.bool;
|
|
description = ''
|
|
Enables http://preyproject.com/ bash client. Be sure to specify api and device keys.
|
|
Once setup, cronjob will run evert 15 minutes and report status.
|
|
'';
|
|
};
|
|
|
|
deviceKey = mkOption {
|
|
type = types.string;
|
|
description = "Device Key obtained from https://panel.preyproject.com/devices (and clicking on the device)";
|
|
};
|
|
|
|
apiKey = mkOption {
|
|
type = types.string;
|
|
description = "API key obtained from https://panel.preyproject.com/profile";
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
environment.systemPackages = [ myPrey ];
|
|
services.cron.systemCronJobs = [ "*/15 * * * * root ${myPrey}/prey.sh" ];
|
|
};
|
|
|
|
}
|