nixos-config/modules/swapspace.nix

26 lines
555 B
Nix
Raw Normal View History

2024-11-08 03:59:57 +00:00
{
config,
lib,
pkgs,
...
}:
2024-06-17 03:48:06 +00:00
let
cfg = config.sconfig.swapspace;
in
{
options.sconfig.swapspace = {
enable = lib.mkEnableOption "swapspace";
swapPath = lib.mkOption { type = lib.types.path; };
};
config = lib.mkIf cfg.enable {
systemd.tmpfiles.rules = [ "d ${cfg.swapPath} 0700 root root" ];
systemd.services.swapspace = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Restart = "always";
ExecStart = "${pkgs.swapspace}/bin/swapspace --swappath='${cfg.swapPath}'";
};
};
};
}