diff --git a/hosts/phone/configuration.nix b/hosts/phone/configuration.nix index 7d786826..3b079daf 100644 --- a/hosts/phone/configuration.nix +++ b/hosts/phone/configuration.nix @@ -47,30 +47,7 @@ in ; config = { - programs = { - fish.functions.video = # fish - '' - ${pkgs.v4l-utils}/bin/media-ctl -d1 --links '"gc2145 3-003c":0->1:0[0],"ov5640 3-004c":0->1:0[1]' - ${pkgs.v4l-utils}/bin/media-ctl -d1 --set-v4l2 '"ov5640 3-004c":0[fmt:UYVY8_2X8/1280x720@1/30]' - - ffmpeg \ - -input_format yuv420p \ - -s 1280x720 \ - -f video4linux2 \ - -thread_queue_size 4096 \ - -i /dev/video1 \ - -f pulse \ - -thread_queue_size 256 \ - -i alsa_input.platform-sound.Voice_Call__DigitalMic__source \ - -c:a libopus \ - -c:v libx264 \ - -preset ultrafast \ - -qp 23 \ - "$(date '+%x(%a)%R').mp4" - ''; - - man.generateCaches = mkForce false; - }; + programs.man.generateCaches = mkForce false; xdg = { desktopEntries = { diff --git a/packages/pinephone-scripts.nix b/packages/pinephone-scripts.nix new file mode 100644 index 00000000..71bb5863 --- /dev/null +++ b/packages/pinephone-scripts.nix @@ -0,0 +1,72 @@ +{ + lib, + stdenvNoCC, + writeTextFile, + makeWrapper, + fish, + v4l-utils, + ffmpeg, +}: + +let + pinephone-video = writeTextFile { + name = "pinephone-video"; + text = # fish + '' + media-ctl -d1 --links '"gc2145 3-003c":0->1:0[0],"ov5640 3-004c":0->1:0[1]' + media-ctl -d1 --set-v4l2 '"ov5640 3-004c":0[fmt:UYVY8_2X8/1280x720@1/30]' + + ffmpeg \ + -input_format yuv420p \ + -s 1280x720 \ + -f video4linux2 \ + -thread_queue_size 4096 \ + -i /dev/video1 \ + -f pulse \ + -thread_queue_size 256 \ + -i alsa_input.platform-sound.Voice_Call__DigitalMic__source \ + -c:a libopus \ + -c:v libx264 \ + -preset ultrafast \ + -qp 23 \ + "$(date '+%x(%a)%R').mp4" + ''; + }; +in +stdenvNoCC.mkDerivation { + pname = "pinephone-scripts"; + version = "0.1.0"; + + dontUnpack = true; + + nativeBuildInputs = [ makeWrapper ]; + + installPhase = '' + runHook preInstall + + install -Dm755 ${pinephone-video} $out/bin/pinephone-video + + runHook postInstall + ''; + + postInstall = '' + for bin in $out/bin/*; do + wrapProgram "$bin" \ + --prefix PATH ":" "${ + lib.makeBinPath [ + fish + v4l-utils + ffmpeg + ] + }" + done + ''; + + meta = { + homepage = "https://github.com/donovanglover/nix-config"; + description = "PinePhone-specific scripts like video recording"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ donovanglover ]; + platforms = lib.platforms.linux; + }; +}