2023-01-12 13:22:55 +00:00
|
|
|
# A nice little sync server for my supercharged shell history done by Atuin.
|
|
|
|
# It's nice to have but not exactly what I need. It's just here because I want
|
|
|
|
# to give it a try.
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2023-02-08 11:05:23 +00:00
|
|
|
inherit (import ../hardware/networks.nix) interfaces;
|
2023-01-21 01:03:10 +00:00
|
|
|
|
2023-02-08 11:05:23 +00:00
|
|
|
atuinInternalDomain = "atuin.${config.networking.fqdn}";
|
2023-01-25 03:38:45 +00:00
|
|
|
host = interfaces.internal.IPv4.address;
|
2023-01-18 03:41:12 +00:00
|
|
|
in
|
|
|
|
{
|
2023-01-12 13:22:55 +00:00
|
|
|
# Atuin sync server because why not.
|
|
|
|
services.atuin = {
|
|
|
|
enable = true;
|
2023-06-22 03:12:58 +00:00
|
|
|
openRegistration = true;
|
2023-01-21 01:03:10 +00:00
|
|
|
|
2023-01-23 09:46:32 +00:00
|
|
|
inherit host;
|
2023-01-12 13:22:55 +00:00
|
|
|
port = 8965;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Putting a neat little script to create the appropriate schema since we're
|
|
|
|
# using secure schema usage pattern as encouraged from PostgreSQL
|
|
|
|
# documentation.
|
|
|
|
systemd.services.atuin = {
|
|
|
|
path = [ config.services.postgresql.package ];
|
|
|
|
preStart = ''
|
|
|
|
psql -tAc "SELECT 1 FROM information_schema.schemata WHERE schema_name='atuin';" \
|
|
|
|
grep -q 1 || psql -tAc "CREATE SCHEMA IF NOT EXISTS atuin;"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
# Putting it altogether in the reverse proxy of choice.
|
2023-02-06 08:00:56 +00:00
|
|
|
services.nginx.virtualHosts."${atuinInternalDomain}" = {
|
2023-01-12 13:22:55 +00:00
|
|
|
locations."/" = {
|
2023-01-23 09:46:32 +00:00
|
|
|
proxyPass = "http://${host}:${toString config.services.atuin.port}";
|
2023-01-12 13:22:55 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|