add swapspace module

This commit is contained in:
Sean Buckley 2024-06-16 23:48:06 -04:00
parent aa7c7749ed
commit 0fbf2573cc

20
modules/swapspace.nix Normal file
View file

@ -0,0 +1,20 @@
{ config, lib, pkgs, ... }:
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}'";
};
};
};
}