From 0fbf2573ccb5d64f628adb3a1f693fb6ce00dfb5 Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Sun, 16 Jun 2024 23:48:06 -0400 Subject: [PATCH] add swapspace module --- modules/swapspace.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 modules/swapspace.nix diff --git a/modules/swapspace.nix b/modules/swapspace.nix new file mode 100644 index 0000000..2272547 --- /dev/null +++ b/modules/swapspace.nix @@ -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}'"; + }; + }; + }; +}