Files
nix-config/hosts/skycam/default.nix

80 lines
1.8 KiB
Nix

{
pkgs,
...
}:
{
imports = [
./hardware-configuration.nix
../server.nix
];
nixpkgs.hostPlatform = "aarch64-linux";
networking = {
hostId = "731d1660";
firewall = {
enable = true;
allowedTCPPorts = [ 8080 ];
allowedUDPPorts = [ 8080 ];
};
};
services.go2rtc =
let
rpicam-vid = "${pkgs.rpicam-apps}/bin/rpicam-vid";
in
{
enable = true;
settings = {
streams.rpicam = "exec:${rpicam-vid} -v1 -t0 -o- --inline --width=4608 --height=2592 --framerate=14 --codec mjpeg --quality 90 --denoise=cdn_off --sharpness 1.25 --exposure long --gain 3";
};
};
systemd.services.skycam-archiver =
let
snapshotScript = pkgs.writeShellScript "skycam-archiver" ''
${pkgs.lib.getExe pkgs.curl} -s -o "/var/lib/skycam-archiver/snapshot-$(date +%Y%m%d-%H%M%S).jpg" "http://skycam.mesh.vimium.net:1984/api/frame.jpeg?src=rpicam"
'';
in
{
description = "Capture skycam snapshot and save with timestamp";
serviceConfig = {
Type = "oneshot";
StateDirectory = "skycam-archiver";
ExecStart = "${snapshotScript}";
};
requires = [ "go2rtc.service" ];
after = [ "go2rtc.service" ];
};
systemd.timers.skycam-archiver = {
description = "Timer for capturing skycam snapshots every 30 minutes";
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "5min";
OnUnitActiveSec = "30min";
Unit = "skycam-archiver.service";
};
};
modules.services.borgmatic = {
enable = true;
directories = [
"/var/lib/skycam-archiver"
];
repoPath = "ssh://m94ekv2i@m94ekv2i.repo.borgbase.com/./repo";
};
environment.systemPackages = with pkgs; [
git
neovim
libcamera
libraspberrypi
raspberrypi-eeprom
rpicam-apps
];
system.stateVersion = "24.05";
}