This repository has been archived on 2026-03-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
oubliette/nixos-module.nix
Torjus Håkestad 75bac814d4 feat: add NixOS module for declarative deployment
Adds nixos-module.nix with services.oubliette options (enable, package,
settings, configFile) and a hardened systemd service. Exposes the module
as nixosModules.default in flake.nix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 17:01:31 +01:00

65 lines
1.7 KiB
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.services.oubliette;
tomlFormat = pkgs.formats.toml { };
configFile =
if cfg.configFile != null
then cfg.configFile
else tomlFormat.generate "oubliette.toml" cfg.settings;
in
{
options.services.oubliette = {
enable = lib.mkEnableOption "Oubliette SSH honeypot";
package = lib.mkPackageOption pkgs "oubliette" { };
configFile = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
Path to a pre-written TOML configuration file.
Mutually exclusive with {option}`settings`.
'';
};
settings = lib.mkOption {
type = tomlFormat.type;
default = { };
description = ''
Configuration for Oubliette as a Nix attribute set.
Will be converted to TOML. Mutually exclusive with {option}`configFile`.
See oubliette.toml.example for available options.
'';
};
};
config = lib.mkIf cfg.enable {
assertions = [
{
assertion = !(cfg.configFile != null && cfg.settings != { });
message = "services.oubliette: `configFile` and `settings` are mutually exclusive.";
}
];
services.oubliette.settings.ssh.host_key_path = lib.mkDefault "/var/lib/oubliette/host_key";
systemd.services.oubliette = {
description = "Oubliette SSH Honeypot";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${lib.getExe cfg.package} -config ${configFile}";
DynamicUser = true;
StateDirectory = "oubliette";
NoNewPrivileges = true;
ProtectSystem = "strict";
ProtectHome = true;
ReadWritePaths = [ "/var/lib/oubliette" ];
};
};
};
}