Skip to content

Commit

Permalink
flake: add nixosModules
Browse files Browse the repository at this point in the history
  • Loading branch information
moni-dz committed Jan 21, 2025
1 parent 6593654 commit c93b3eb
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
imports = [
inputs.parts.flakeModules.partitions
./modules/parts
./modules/nixos
./hosts
./users
];
Expand Down
10 changes: 10 additions & 0 deletions modules/nixos/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ lib, ... }:

{
flake.nixosModules = lib.pipe ./. [
lib.filesystem.listFilesRecursive
(__filter (f: lib.hasSuffix "nix" f && !(lib.hasSuffix "default.nix" f)))
(map (f: lib.nameValuePair (lib.removeSuffix ".nix" (baseNameOf f)) (import f)))
__listToAttrs
];
}
46 changes: 46 additions & 0 deletions modules/nixos/shpool.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
config,
lib,
pkgs,
...
}:

let
cfg = config.services.shpool;
in
{
options.services.shpool = {
enable = lib.mkEnableOption "shpool, a service that enables session persistence";
package = lib.mkPackageOption pkgs "shpool" { };
};

config = lib.mkIf cfg.enable {
systemd = {
services.shpool = {
description = "Shpool - Shell Session Pool";
requires = [ "shpool.socket" ];

serviceConfig = {
Type = "simple";
ExecStart = "${cfg.package}/bin/shpool daemon";
KillMode = "mixed";
TimeoutStopSec = "2s";
SendSIGHUP = "yes";
};

wantedBy = [ "default.target" ];
};

sockets.shpool = {
description = "Shpool Shell Session Pooler";

socketConfig = {
ListenStream = "%t/shpool/shpool.socket";
SocketMode = "0600";
};

wantedBy = [ "sockets.target" ];
};
};
};
}

0 comments on commit c93b3eb

Please sign in to comment.