From f8fc20953f51d0a90c67aefed902483090641a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20R=C3=B6ger?= Date: Wed, 28 May 2025 00:12:06 +0200 Subject: [PATCH] System Gen44 @ 2025-05-28-00:12:05 by jonas@monolith --- .gitignore | 3 +- flake.nix | 22 +++++++--- hosts/monolith/configuration.nix | 1 + pkgs/default.nix | 3 ++ pkgs/transcode-davinci-resolve/.envrc | 1 + pkgs/transcode-davinci-resolve/default.nix | 25 +++++++++++ pkgs/transcode-davinci-resolve/shell.nix | 7 +++ .../transcode-davinci-resolve.sh | 44 +++++++++++++++++++ 8 files changed, 98 insertions(+), 8 deletions(-) create mode 100644 pkgs/default.nix create mode 100644 pkgs/transcode-davinci-resolve/.envrc create mode 100644 pkgs/transcode-davinci-resolve/default.nix create mode 100644 pkgs/transcode-davinci-resolve/shell.nix create mode 100644 pkgs/transcode-davinci-resolve/transcode-davinci-resolve.sh diff --git a/.gitignore b/.gitignore index bf0824e..050f6da 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*.log \ No newline at end of file +*.log +**/.direnv/ diff --git a/flake.nix b/flake.nix index 1c77e41..c61b208 100644 --- a/flake.nix +++ b/flake.nix @@ -37,6 +37,7 @@ }; outputs = { + self, nixpkgs, nixpkgs-unstable, nixos-hardware, @@ -60,7 +61,7 @@ isHM = false; }; modules = [ - ({...}: {nixpkgs.overlays = [overlay-unstable];}) + ({...}: {nixpkgs.overlays = [overlay-unstable self.overlays.default];}) ({...}: {nixpkgs.config.allowUnfree = true;}) nixos-hardware.nixosModules.msi-b550-a-pro inputs.sops-nix.nixosModules.sops @@ -75,7 +76,7 @@ isHM = false; }; modules = [ - ({...}: {nixpkgs.overlays = [overlay-unstable];}) + ({...}: {nixpkgs.overlays = [overlay-unstable self.overlays.default];}) ({...}: { nixpkgs.config.allowUnfree = true; nixpkgs.config.nvidia.acceptLicense = true; @@ -100,7 +101,7 @@ isHM = false; }; modules = [ - ({...}: {nixpkgs.overlays = [overlay-unstable];}) + ({...}: {nixpkgs.overlays = [overlay-unstable self.overlays.default];}) ({...}: {nixpkgs.config.allowUnfree = true;}) inputs.sops-nix.nixosModules.sops ./modules @@ -123,7 +124,7 @@ # Specify your home configuration modules here, for example, # the path to your home.nix. modules = [ - ({...}: {nixpkgs.overlays = [overlay-unstable];}) + ({...}: {nixpkgs.overlays = [overlay-unstable self.overlays.default];}) ({...}: {nixpkgs.config.allowUnfree = true;}) inputs.plasma-manager.homeManagerModules.plasma-manager inputs.sops-nix.homeManagerModules.sops @@ -144,7 +145,7 @@ # Specify your home configuration modules here, for example, # the path to your home.nix. modules = [ - ({...}: {nixpkgs.overlays = [overlay-unstable];}) + ({...}: {nixpkgs.overlays = [overlay-unstable self.overlays.default];}) ({...}: {nixpkgs.config.allowUnfree = true;}) inputs.plasma-manager.homeManagerModules.plasma-manager inputs.sops-nix.homeManagerModules.sops @@ -165,7 +166,7 @@ # Specify your home configuration modules here, for example, # the path to your home.nix. modules = [ - ({...}: {nixpkgs.overlays = [overlay-unstable];}) + ({...}: {nixpkgs.overlays = [overlay-unstable self.overlays.default];}) ({...}: {nixpkgs.config.allowUnfree = true;}) inputs.plasma-manager.homeManagerModules.plasma-manager inputs.sops-nix.homeManagerModules.sops @@ -186,7 +187,7 @@ # Specify your home configuration modules here, for example, # the path to your home.nix. modules = [ - ({...}: {nixpkgs.overlays = [overlay-unstable];}) + ({...}: {nixpkgs.overlays = [overlay-unstable self.overlays.default];}) ({...}: {nixpkgs.config.allowUnfree = true;}) inputs.plasma-manager.homeManagerModules.plasma-manager inputs.sops-nix.homeManagerModules.sops @@ -201,6 +202,13 @@ isHM = true; }; }; + + devShells.${system} = { + transcode-davinci-resolve = (import ./pkgs/transcode-davinci-resolve/shell.nix) {pkgs = nixpkgs.legacyPackages.${system};}; + }; + + overlays.default = import ./pkgs; + templates = { rust = { path = ./templates/rust; diff --git a/hosts/monolith/configuration.nix b/hosts/monolith/configuration.nix index 581229d..f883bc1 100644 --- a/hosts/monolith/configuration.nix +++ b/hosts/monolith/configuration.nix @@ -97,6 +97,7 @@ ranger sops spotify + transcode-davinci-resolve vim vlc vscode diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..465763f --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,3 @@ +_: prev: { + transcode-davinci-resolve = prev.callPackage ./transcode-davinci-resolve {}; +} diff --git a/pkgs/transcode-davinci-resolve/.envrc b/pkgs/transcode-davinci-resolve/.envrc new file mode 100644 index 0000000..7bdd9c7 --- /dev/null +++ b/pkgs/transcode-davinci-resolve/.envrc @@ -0,0 +1 @@ +use flake ../../#transcode-davinci-resolve --show-trace diff --git a/pkgs/transcode-davinci-resolve/default.nix b/pkgs/transcode-davinci-resolve/default.nix new file mode 100644 index 0000000..990143a --- /dev/null +++ b/pkgs/transcode-davinci-resolve/default.nix @@ -0,0 +1,25 @@ +{ + bash, + ffmpeg, + fzf, + gum, + stdenv, + tree, + ... +}: +stdenv.mkDerivation { + name = "transcode-davinci-resolve"; + src = ./.; + + buildInputs = [ + bash + ffmpeg + fzf + gum + tree + ]; + + installPhase = '' + install -Dm755 transcode-davinci-resolve.sh $out/bin/transcode-davinci-resolve + ''; +} diff --git a/pkgs/transcode-davinci-resolve/shell.nix b/pkgs/transcode-davinci-resolve/shell.nix new file mode 100644 index 0000000..a314d08 --- /dev/null +++ b/pkgs/transcode-davinci-resolve/shell.nix @@ -0,0 +1,7 @@ +{pkgs ? import {}}: let + bin = pkgs.callPackage ./default.nix {}; +in + pkgs.mkShell { + name = "transcode-davinci-resolve"; + inputsFrom = [bin]; + } diff --git a/pkgs/transcode-davinci-resolve/transcode-davinci-resolve.sh b/pkgs/transcode-davinci-resolve/transcode-davinci-resolve.sh new file mode 100644 index 0000000..889cb58 --- /dev/null +++ b/pkgs/transcode-davinci-resolve/transcode-davinci-resolve.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +set -e + +where="${1:-.}" + +selection=$(find "$where" -type f | fzf --multi --preview 'ffprobe -v error -show_format -show_streams {}' --preview-window=up:wrap) + +output_dir=$(find $HOME -type d ! -name '.*' ! -path '*/.*/*' | fzf --preview 'tree -C {}' --preview-window=up:wrap --prompt "Select output directory: ") + +if gum confirm "Flatten the directory structure?"; +then + flatten=true +else + flatten=false +fi + +function transcode_job { + local file="$1" + local output_dir="$2" + local flatten="$3" + local where=$4 + local fname=$(basename "$file") + local segment=$(realpath --relative-to="$where" "$file") + + if [ "$flatten" = true ]; then + output_file="$output_dir/$fname.mov" + else + output_file="$output_dir/$segment.mov" + fi + + mkdir -p "$(dirname "$output_file")" >> log.txt + + ffmpeg -i "$file" -c:v dnxhd -profile:v dnxhr_hq -pix_fmt yuv422p -c:a pcm_s16le "$output_file" || true + +} +export -f transcode_job + +i=1 +len=$(echo "$selection" | wc -l) +while IFS= read -r file; do + gum spin --spinner dot --title "[$i/$len] Transcoding $file" -- bash -c "source <(declare -f transcode_job); transcode_job \"$file\" \"$output_dir\" \"$flatten\" \"$where\"" + ((i++)) +done <<< "$selection"