Compare commits
No commits in common. "44583f670fe31c26ad396826a81f01419b0fae17" and "48f36f5d9ee6f8ffe8579b83dd7c6024437184be" have entirely different histories.
44583f670f
...
48f36f5d9e
|
@ -11,12 +11,11 @@
|
|||
#./amanuensis.nix
|
||||
./catacomb.nix
|
||||
./gitea.nix
|
||||
./sync-pipeline.nix
|
||||
];
|
||||
|
||||
beatific.hostName = "empyrean";
|
||||
beatific.isLighthouse = true;
|
||||
beatific.defaults.tvbSync = true;
|
||||
beatific.defaults.tvbSync = false;
|
||||
|
||||
# Use the GRUB 2 boot loader.
|
||||
boot.loader.grub = {
|
||||
|
@ -40,7 +39,6 @@
|
|||
networking.interfaces.eth0.useDHCP = true;
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
exiftool
|
||||
tinc_pre
|
||||
gitea
|
||||
];
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
# exiftool config and script based on that of @numinit
|
||||
|
||||
let
|
||||
# An exiftool config that adds the OriginTimestamp property containing the best guess for file creation time
|
||||
exiftool-config = pkgs.writeText "exiftool.config" ''
|
||||
%Image::ExifTool::UserDefined = (
|
||||
'Image::ExifTool::Composite' => {
|
||||
OriginTimestamp => {
|
||||
Desire => {
|
||||
0 => 'CreateDate',
|
||||
1 => 'DateTimeOriginal',
|
||||
2 => 'FileModifyDate'
|
||||
},
|
||||
ValueConv => '$val[0] || $val[1] || $val[2] || undef',
|
||||
PrintConv => '$self->ConvertDateTime($val)',
|
||||
PrintConvInv => '$self->InverseDateTime($val)'
|
||||
}
|
||||
}
|
||||
)
|
||||
'';
|
||||
|
||||
# A tool to use `find` and `exiftool` to sort images into YMD folders
|
||||
sibd = pkgs.writeShellScriptBin "sort-images-by-date" ''
|
||||
set -euo pipefail
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "Usage: $0 [prefix] [src] [dest] [exiftool args...]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
prefix="$1"
|
||||
src="$2"
|
||||
dest="$3"
|
||||
# Remove $1, $2, $3 from $@ so the remainder can be passed to exiftool
|
||||
shift; shift; shift
|
||||
|
||||
# This find expression matches .jpg/.png modified 14+ days ago.
|
||||
# The -not (-name -prune) expressions exclude directories from the results by name.
|
||||
# The exiftool command will move matched files to $dest/$prefix/year/month/day/filename.ext.
|
||||
# -config loads the config defined above, which adds the OriginTimestamp composite property
|
||||
# -filename tells exiftool to move each file to a new filename, $OriginTimestamp
|
||||
# -d defines how the timestamp will be converted to a string, which ends up handling the pathing
|
||||
${pkgs.findutils}/bin/find $src \
|
||||
-not \( -name FalseKnees -prune \) \
|
||||
-not \( -name Background -prune \) \
|
||||
-type f \
|
||||
-mtime +14 \
|
||||
\( -name "*.jpg" -or -name "*.png" \) \
|
||||
-exec ${pkgs.exiftool}/bin/exiftool \
|
||||
-config ${exiftool-config} \
|
||||
-api largefilesupport=1 \
|
||||
-progress \
|
||||
-filename'<OriginTimestamp' \
|
||||
-d "''${dest}/''${prefix}/%Y-%m-%d/%%f%%-c.%%le" \
|
||||
"$@" \
|
||||
{} +
|
||||
'';
|
||||
|
||||
# Script for cron jobs that sends output to journalctl -t sync-pipeline
|
||||
sibd-cron = prefix: src: dest: pkgs.writeShellScript "sibd-cron" ''
|
||||
${systemd}/bin/systemd-cat -t sync-pipeline ${sibd}/bin/sort-images-by-date ${prefix} ${src} ${dest}
|
||||
'';
|
||||
in {
|
||||
environment.systemPackages = [ sort-images-by-date ];
|
||||
|
||||
services.cron = {
|
||||
enable = true;
|
||||
systemCronJobs = [
|
||||
"0 0 * * 1 tvb ${sibd-cron "nokia" "/home/tvb/phone-sync/DCIM" "/home/tvb/phone-sync/staging"}"
|
||||
"0 0 * * 1 tvb ${sibd-cron "nokia" "/home/tvb/phone-sync/Pictures" "/home/tvb/phone-sync/staging"}"
|
||||
];
|
||||
}
|
|
@ -53,15 +53,8 @@ in {
|
|||
# Options to always set
|
||||
networking.hostName = cfg.hostName;
|
||||
nix.extraOptions = "experimental-features = nix-command flakes";
|
||||
# Link /etc/nixos to the flake source
|
||||
environment.etc.nixos.source = ./..;
|
||||
environment.shellAliases = {
|
||||
# Shortcut for nixos-rebuild
|
||||
nr = "sudo nixos-rebuild --flake $HOME/nixos-configs";
|
||||
# Set some user-friendly defaults (use e.g. "command cp" to skip the alias)
|
||||
# -r (recursively copy dirs) -p (preserve mode, ownership, timestamps)
|
||||
cp = "cp -rp";
|
||||
};
|
||||
environment.shellAliases.nr = "sudo nixos-rebuild --flake $HOME/nixos-configs";
|
||||
security.sudo.extraRules = [{
|
||||
users = [ "tvb" ];
|
||||
commands = [ { command = "/run/current-system/sw/bin/nixos-rebuild"; options = [ "NOPASSWD" ]; } ];
|
||||
|
|
Loading…
Reference in New Issue