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

Initial VDR integration #32050

Closed
wants to merge 13 commits into from
Closed

Initial VDR integration #32050

wants to merge 13 commits into from

Conversation

ck3d
Copy link
Contributor

@ck3d ck3d commented Nov 25, 2017

Motivation for this change

Integrated VDR and some plugins into NixOS.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Copy link
Member

@matthewbauer matthewbauer left a comment

Choose a reason for hiding this comment

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

Merge conflict

@ck3d
Copy link
Contributor Author

ck3d commented Apr 22, 2018

Thanks for reviewing. I updated to nixos-unstable and added two patches.

@matthewbauer
Copy link
Member

@GrahamcOfBorg build vdr

@GrahamcOfBorg
Copy link

Failure on x86_64-linux (full log)

Attempted: vdr

Partial log (click to expand)

   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
   ^~~
/nix/store/ng5kbr6kmh979qaachifbsbblydrcmqc-gcc-7.3.0/include/c++/7.3.0/bits/std_abs.h:102:3: note: candidate: constexpr __float128 std::abs(__float128)
   abs(__float128 __x)
   ^~~
g++ -g -O3 -Wall -Werror=overloaded-virtual -Wno-parentheses -fPIC -c -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DREMOTE_KBD -DBIDI -DSDNOTIFY -DLIRC_DEVICE=\"/var/run/lirc/lircd\" -DVIDEODIR=\"/srv/vdr/video\" -DCONFDIR=\"/var/lib/vdr\" -DARGSDIR=\"/etc/vdr/conf.d\" -DCACHEDIR=\"/var/cache/vdr\" -DRESDIR=\"/usr/local/share/vdr\" -DPLUGINDIR=\"/usr/local/lib/vdr\" -DLOCDIR=\"/usr/local/share/locale\" -I/nix/store/cywh34sn8b00qil2g112bdhgdklkh2ca-fontconfig-2.12.6-dev/include -I/nix/store/dpydsfzmxm2dfmsr1c2llvrra9y663qx-expat-2.2.5-dev/include -I/nix/store/11mvvhykc4svx4f5p5ssw5l87h7v99q6-freetype-2.9-dev/include/freetype2  -I/nix/store/1anjdss6di9zqlqnp9836ymsq5nfbnmx-fribidi-0.19.7/include/fribidi -I/nix/store/a32dmays1bbjswd63rzw4mqrbwbwzxn2-systemd-238-dev/include -o dvbspu.o dvbspu.c
make: *** [Makefile:124: dvbdevice.o] Error 1
make: *** Waiting for unfinished jobs....
builder for '/nix/store/3vy97sf6sgj04imgfq07sm3vfkiiic0s-vdr-2.2.0.drv' failed with exit code 2
�[31;1merror:�[0m build of '/nix/store/3vy97sf6sgj04imgfq07sm3vfkiiic0s-vdr-2.2.0.drv' failed

@GrahamcOfBorg
Copy link

No attempt on x86_64-darwin (full log)

The following builds were skipped because they don't evaluate on x86_64-darwin: vdr

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

Failure on aarch64-linux (full log)

Attempted: vdr

Partial log (click to expand)

        __bos (__s), __fmt, __va_arg_pack ());
                                            ^
ar rv libsi.a util.o si.o section.o descriptor.o
ar: creating libsi.a
a - util.o
a - si.o
a - section.o
a - descriptor.o
builder for '/nix/store/jcpyzqd46df75av5h6ad85891g1xciff-vdr-2.2.0.drv' failed with exit code 2
�[31;1merror:�[0m build of '/nix/store/jcpyzqd46df75av5h6ad85891g1xciff-vdr-2.2.0.drv' failed

@ck3d
Copy link
Contributor Author

ck3d commented Apr 23, 2018

x86_64-linux: fixed the gcc-7 compatibility issue.
x86_64-darwin: Is not supported and not part of the root packages vdrBundle.vdr meta information. What else needs to be done, to pass that check?
aarch64-linux: I can only check x86_64-linux. I should restrict that packages to that platform.

used same plugin mechanism as kodi does
@ck3d
Copy link
Contributor Author

ck3d commented Dec 8, 2018

updated PR contains:

  • restrict to linux 32 and 64 bit platforms
  • updated to vdr 2.4.0 and latest plugins

mkdir -p "${cfg.videoDir}"
chown vdr:vdr "${cfg.videoDir}"
fi
'';
Copy link
Member

Choose a reason for hiding this comment

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

It is better to use systemd.tmpfiles.rules instead of activation scripts, which are executed unconditionally on every switch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

videoDir is the folder where all recordings are put in. tmpfiles is a little bit missleading. I put responsibility to admin. Folder has to exist.

++ optional (config.vdr.enableSvdrpDemo or false) svdrpdemo
++ optional (config.vdr.enableText2Skin or false) text2skin
++ optional (config.vdr.enableVnsiServer or false) vnsiserver
);
Copy link
Member

@Mic92 Mic92 Dec 8, 2018

Choose a reason for hiding this comment

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

Instead of so many options cannot users just pass them to vdrPlugins { plugins = [];}?


if ! [ -d "${libDir}" ]; then
mkdir -p "${libDir}"
cp --dereference -r "${cfg.package}"/share/vdr/conf/* "${libDir}"
Copy link
Member

@Mic92 Mic92 Dec 8, 2018

Choose a reason for hiding this comment

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

This one should be part of the service. Also use touch for a file in libDir afterwards so the command get repeated on failure by checking for the existence of the file instead of the existence of the directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is OK to remove that feature.

'';

security.sudo.configFile = ''
vdr ALL=(root) NOPASSWD:${pkgs.utillinux}/bin/rtcwake
Copy link
Member

Choose a reason for hiding this comment

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

This one also needs sudo to be activated I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true. I think it was a bad design to expect that rtcwake is used during shutdown. Will be removed.

###### implementation

config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
Copy link
Member

Choose a reason for hiding this comment

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

Does this needs to be in PATH?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No not needed. Will be removed.

package = mkOption {
type = types.package;
default = pkgs.vdr-with-plugins;
description = "Package to use.";
Copy link
Member

Choose a reason for hiding this comment

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

Add here an example using wrapVdr.

};

extraArguments = mkOption {
type = types.str;
Copy link
Member

Choose a reason for hiding this comment

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

Better to make this a list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, much better. Will use it with lib.escapeShellArgs

if ! [ -d "${libDir}" ]; then
mkdir -p "${libDir}"
cp --dereference -r "${cfg.package}"/share/vdr/conf/* "${libDir}"
chown -R vdr:vdr "${libDir}"
Copy link
Member

Choose a reason for hiding this comment

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

You can also use systemd's StateDirectory option to automatically create the directory and chown it to the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, but copy of good defaults if folder doesn't exist will the be removed.

system.activationScripts.vdr = ''
if ! [ -d /var/cache/vdr ]; then
mkdir -p /var/cache/vdr
chown vdr:vdr /var/cache/vdr
Copy link
Member

Choose a reason for hiding this comment

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

Use systemd's CacheDirectory here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CacheDirectory matches perfectly.

@ck3d
Copy link
Contributor Author

ck3d commented Dec 9, 2018

@Mic92 Thanks a lot for all the comments. I will take a bit of time to incorporate all your good recommendations.

@Mic92
Copy link
Member

Mic92 commented Dec 13, 2018

Please don't mark reviews as resolves unless you have also pushed the changes, where you addressed the review.

@Mic92
Copy link
Member

Mic92 commented Dec 21, 2018

@GrahamcOfBorg eval

buildInputs = [ gettext vdr ];
nativeBuildInputs = [ pkgconfig ];
preConfigure = "cd PLUGINS/src/${name}";
installFlags = [ "DESTDIR=$(out)" "PREFIX=" ];
Copy link
Member

@Mic92 Mic92 Dec 21, 2018

Choose a reason for hiding this comment

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

Usually this comes with its own set of problems using DESTDIR instead of PREFIX when it uses PREFIX somewhere in the source. What was the offending file that could that ignored PREFIX, when installing?

name = "vdr-${name}-${version}";
inherit (vdr) src;
buildInputs = [ gettext vdr ];
nativeBuildInputs = [ pkgconfig ];
Copy link
Member

Choose a reason for hiding this comment

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

gettext also is a nativeBuildInput.


postPatch = "substituteInPlace Makefile --replace libsystemd-daemon libsystemd";

buildInputs = [ fontconfig libjpeg libcap freetype perl ]
Copy link
Member

Choose a reason for hiding this comment

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

If perl is not linked at runtime or used in runtime scripts, it should be also in nativeBuildInputs.

++ stdenv.lib.optional enableSystemd "SDNOTIFY=1"
++ stdenv.lib.optional enableBidi "BIDI=1";

propagatedBuildInputs = [ pkgconfig gettext ];
Copy link
Member

Choose a reason for hiding this comment

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

Should this not be in nativeBuildInputs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Every vdr plugin need to have the same build tools than vdr itself. If will you propagatedNavtiveBuildInputs. If you want the plugin descriptions more explicit I can change it to no propagated.

Copy link
Member

@Mic92 Mic92 Dec 22, 2018

Choose a reason for hiding this comment

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

The problem is that it also propagate to every other package that uses vdr somehow, which can be surprising at times. You can abstract it way in a variable or so or use vdr.propagatedBuildInputs explicit.

pcre
perl # for pod2man and pos2html
utillinux
groff
Copy link
Member

Choose a reason for hiding this comment

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

perl, utillinux and groff probably belong to nativeBuildInputs.


buildInputs = [ vdr graphicsmagick ];

buildFlags = [ "DESTDIR=$(out)" ];
Copy link
Member

Choose a reason for hiding this comment

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

also here the question as above regarding PREFIX instead of DESTDIR.

-e 's,IMAGELIB = imagemagick,IMAGELIB = graphicsmagic,' \
-e 's,^VDRDIR *=.*,VDRDIR = ${vdr.dev}/include/vdr,' \
-e 's,^LOCALEDIR *=.*,LOCALEDIR = $(DESTDIR)/share/locale,' \
-e 's,^LIBDIR *=.*,LIBDIR = $(DESTDIR)/lib/vdr,'
Copy link
Member

Choose a reason for hiding this comment

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

You can also override variables by using makeFlags instead of sed.


buildInputs = [ vdr boost libconvpp libfritzpp libnetpp liblogpp ];

installFlags = [ "DESTDIR=$(out)" ];
Copy link
Member

Choose a reason for hiding this comment

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

see above.

@@ -338,6 +338,7 @@
minetest = 311;
rss2email = 312;
cockroachdb = 313;
vdr = 314;
Copy link
Member

@Mic92 Mic92 Dec 21, 2018

Choose a reason for hiding this comment

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

not required, will be allocated on first use:

Suggested change
vdr = 314;

@@ -636,6 +637,7 @@
minetest = 311;
rss2email = 312;
cockroachdb = 313;
vdr = 314;
Copy link
Member

Choose a reason for hiding this comment

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

same here:

Suggested change
vdr = 314;


package = mkOption {
type = types.package;
default = pkgs.vdr;
Copy link
Member

Choose a reason for hiding this comment

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

To fix the aarch64 build we also need a defaultText = "pkgs.vdr".

@ck3d
Copy link
Contributor Author

ck3d commented Dec 22, 2018

@Mic92 Thanks for all our good comments! Could you please have once more a look to my PR.

@Mic92
Copy link
Member

Mic92 commented Dec 22, 2018

See #52686

Mic92 added a commit that referenced this pull request Dec 23, 2018
vdr: revisited version of #32050
@ck3d ck3d closed this Dec 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants