1 { config, lib, pkgs, utils, ... }:
7 cfg = config.services.freefall;
11 options.services.freefall = {
16 description = lib.mdDoc ''
17 Whether to protect HP/Dell laptop hard drives (not SSDs) in free fall.
23 default = pkgs.freefall;
24 defaultText = literalExpression "pkgs.freefall";
25 description = lib.mdDoc ''
26 freefall derivation to use.
31 type = types.listOf types.str;
32 default = [ "/dev/sda" ];
33 description = lib.mdDoc ''
34 Device paths to all internal spinning hard drives.
44 let dev' = utils.escapeSystemdPath dev; in
45 nameValuePair "freefall-${dev'}" {
46 description = "Free-fall protection for ${dev}";
47 after = [ "${dev'}.device" ];
48 wantedBy = [ "${dev'}.device" ];
50 ExecStart = "${cfg.package}/bin/freefall ${dev}";
51 Restart = "on-failure";
58 environment.systemPackages = [ cfg.package ];
60 systemd.services = builtins.listToAttrs (map mkService cfg.devices);