Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpu-screen-recorder-ui: init at 1.0.0 #369574

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
./programs/gpaste.nix
./programs/gphoto2.nix
./programs/gpu-screen-recorder.nix
./programs/gpu-screen-recorder-ui.nix
./programs/haguichi.nix
./programs/hamster.nix
./programs/htop.nix
Expand Down
46 changes: 46 additions & 0 deletions nixos/modules/programs/gpu-screen-recorder-ui.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
config,
lib,
pkgs,
...
}:

let
cfg = config.programs.gpu-screen-recorder-ui;
package = cfg.package.override {
inherit (config.security) wrapperDir;
};
in
{
options = {
programs.gpu-screen-recorder-ui = {
package = lib.mkPackageOption pkgs "gpu-screen-recorder-ui" { };

enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to install gpu-screen-recorder-ui and generate setcap
wrappers for global hotkeys.
'';
};
};
};

config = lib.mkIf cfg.enable {
programs.gpu-screen-recorder.enable = lib.mkDefault true;

environment.systemPackages = [ package ];

systemd.packages = [ package ];

security.wrappers."gsr-global-hotkeys" = {
owner = "root";
group = "root";
capabilities = "cap_setuid+ep";
source = lib.getExe' package "gsr-global-hotkeys";
};
};

meta.maintainers = with lib.maintainers; [ js6pak ];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
lib,
stdenv,
fetchurl,
pkg-config,
meson,
ninja,
libX11,
libXrender,
libXrandr,
libXext,
libglvnd,
gitUpdater,
}:

stdenv.mkDerivation rec {
pname = "gpu-screen-recorder-notification";
version = "1.0.0";

src = fetchurl {
url = "https://dec05eba.com/snapshot/${pname}.git.${version}.tar.gz";
hash = "sha256-cyM3y1MYZNEHKyiyAqYXcSwZe0tcnPNukxErm/dIo6Y=";
};

sourceRoot = ".";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stdenv expects the src to have a single directory after extracting if you don't set sourceRoot. But this tarball isn't like that, it has the source files directly in root

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the src a tarball anyways? Why not use fetchgit?

Copy link
Member Author

@js6pak js6pak Jan 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the src a tarball anyways? Why not use fetchgit?

I just followed what @babbaj did for gpu-screen-recorder{,-gtk}, found reasoning for the initial change here: #268443 (comment) (upstream asked for it)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I don't think that reasoning is sound though as fetchgit does indeed do a "shallow" clone (--depth=1) and, unless the speed is abhorrently slow, this doesn't really matter. Each revision needs to be fetched once by a handful of instances:

  • authors of update PRs
  • reviewers of update PRs
  • hydra

Most everyone else will either get the cached binary output path and doesn't need to fetch the source at all or they will fetch the cached source path from hydra.

If you really don't want fetchgit, you should at least use fetchzip instead.

cc @dec05eba

Copy link
Contributor

@dec05eba dec05eba Jan 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src taraball is preferred as its faster on the slow server and increases the load less. But in this case where it does a shallow clone and clone is only done by the ones you mentioned then fetchgit is ok, if it provides a benefit. The git link is primarly intended for development, not distribution, so it's discouraged unless there is a reason to use it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Atemu What's even the advantage of fetchgit here? And for fetchzip vs fetchurl, I guess the only difference is whether you hash the contents or the compressed file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetchgit is the closest to the actual source.

As we've learned in April, a tarball can contain anything Jia Tan wants it to and it's quite a lot easier to hide stuff in a rando tarball download vs. a git history.

fetchzip unpacks a given archive and thereby abstracts away any oddities in how it's packaged up which you had to work around here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my machine fetching the tarball takes about 0.3s, while doing a shallow clone takes ~0.6s.
So with the increased load concern being solved by hydra, I'll go with fetchgit.


postPatch = ''
substituteInPlace depends/mglpp/depends/mgl/src/gl.c \
Atemu marked this conversation as resolved.
Show resolved Hide resolved
--replace-fail "libGL.so.1" "${lib.getLib libglvnd}/lib/libGL.so.1" \
--replace-fail "libGLX.so.0" "${lib.getLib libglvnd}/lib/libGLX.so.0" \
--replace-fail "libEGL.so.1" "${lib.getLib libglvnd}/lib/libEGL.so.1"
'';

nativeBuildInputs = [
pkg-config
meson
ninja
];

buildInputs = [
libX11
libXrender
libXrandr
libXext
libglvnd
];

passthru.updateScript = gitUpdater { url = "https://repo.dec05eba.com/${pname}"; };

meta = {
description = "Notification in the style of ShadowPlay";
homepage = "https://git.dec05eba.com/${pname}/about/";
license = lib.licenses.gpl3Only;
mainProgram = "gsr-notify";
maintainers = with lib.maintainers; [ js6pak ];
platforms = lib.platforms.linux;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
lib,
stdenv,
fetchurl,
pkg-config,
meson,
ninja,
makeWrapper,
gpu-screen-recorder,
gpu-screen-recorder-notification,
libX11,
libXrender,
libXrandr,
libXcomposite,
libXi,
libglvnd,
wrapperDir ? "/run/wrappers/bin",
gitUpdater,
}:

stdenv.mkDerivation rec {
pname = "gpu-screen-recorder-ui";
version = "1.0.0";

src = fetchurl {
url = "https://dec05eba.com/snapshot/${pname}.git.${version}.tar.gz";
hash = "sha256-2gB6FWys5RGDlwc1OZ0NnjU8eIGJefpjc94YKJSnyPI=";
};

sourceRoot = ".";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this


postPatch = ''
substituteInPlace depends/mglpp/depends/mgl/src/gl.c \
--replace-fail "libGL.so.1" "${lib.getLib libglvnd}/lib/libGL.so.1" \
--replace-fail "libGLX.so.0" "${lib.getLib libglvnd}/lib/libGLX.so.0" \
--replace-fail "libEGL.so.1" "${lib.getLib libglvnd}/lib/libEGL.so.1"
Atemu marked this conversation as resolved.
Show resolved Hide resolved

substituteInPlace extra/gpu-screen-recorder-ui.service \
--replace-fail "ExecStart=${meta.mainProgram}" "ExecStart=$out/bin/${meta.mainProgram}"
'';

nativeBuildInputs = [
pkg-config
meson
ninja
makeWrapper
];

buildInputs = [
libX11
libXrender
libXrandr
libXcomposite
libXi
libglvnd
];

mesonFlags = [
# Handled by the module
(lib.mesonBool "capabilities" false)
];

postInstall =
let
gpu-screen-recorder-wrapped = gpu-screen-recorder.override {
inherit wrapperDir;
};
in
''
wrapProgram "$out/bin/${meta.mainProgram}" \
--prefix PATH : "${wrapperDir}" \
--suffix PATH : "${
lib.makeBinPath [
gpu-screen-recorder-wrapped
gpu-screen-recorder-notification
]
}"
'';

passthru.updateScript = gitUpdater { url = "https://repo.dec05eba.com/${pname}"; };

meta = {
description = "A fullscreen overlay UI for GPU Screen Recorder in the style of ShadowPlay";
homepage = "https://git.dec05eba.com/${pname}/about/";
license = lib.licenses.gpl3Only;
mainProgram = "gsr-ui";
maintainers = with lib.maintainers; [ js6pak ];
platforms = lib.platforms.linux;
};
}
4 changes: 4 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13960,6 +13960,10 @@ with pkgs;

gpu-screen-recorder-gtk = callPackage ../applications/video/gpu-screen-recorder/gpu-screen-recorder-gtk.nix { };

gpu-screen-recorder-notification = callPackage ../applications/video/gpu-screen-recorder/gpu-screen-recorder-notification.nix { };

gpu-screen-recorder-ui = callPackage ../applications/video/gpu-screen-recorder/gpu-screen-recorder-ui.nix { };

gpxsee-qt5 = libsForQt5.callPackage ../applications/misc/gpxsee { };

gpxsee-qt6 = qt6Packages.callPackage ../applications/misc/gpxsee { };
Expand Down
Loading