Hi,

I notice youtube-dl comes with a man page, bash completion file and
fish completion file. However, since it is located in a very werid
path, the programs normally wouldn't find it. So, I add
native-search-paths.

I can only confirm that MANPATH is working correctly. I don't know if
fish_complete_path works. I am only following what the documentation
says.

BASH_COMPLETION doesn't work. I think it has to do with the bash
completion package. From the bash completion README
<https://anonscm.debian.org/cgit/bash-completion/bash-completion.git/plain/README>,
it says package X install the bash completion file into the path
return by `pkg-config --variable=completionsdir bash-completion' or
`pkg-config --variable=compatdir bash-completion'. Both commands
return 
`/gnu/store/jyj96nxaw415yqi8vg6r73i1yib34k7i-bash-completion-2.1/share/bash-completion/completions'.
I think it should be point to something like
`~/.guix-profile/etc/bash_completion.d' instead so that other packages
could install their own bash completion file into
`/etc/bash_completion.d'. For instance, git install its own bash
completion file into that directory by default.

Any ideas?

Cheers,
Alex
From 5b04230e30fd594ebab43c50e84f989503dc3535 Mon Sep 17 00:00:00 2001
From: Alex Vong <[email protected]>
Date: Sat, 12 Dec 2015 11:20:44 +0800
Subject: [PATCH] gnu: youtube-dl: Add native-search-paths.

* gnu/packages/video.scm (youtube-dl): Add native-search-paths.
[native-search-paths]: Add fish_complete_path and MANPATH.
---
 gnu/packages/video.scm | 73 +++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 55 insertions(+), 18 deletions(-)

diff --git a/gnu/packages/video.scm b/gnu/packages/video.scm
index 76374e2..e30c1ce 100644
--- a/gnu/packages/video.scm
+++ b/gnu/packages/video.scm
@@ -24,6 +24,7 @@
 
 (define-module (gnu packages video)
   #:use-module (ice-9 match)
+  #:use-module (srfi srfi-26)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix utils)
   #:use-module (guix packages)
@@ -808,25 +809,61 @@ projects while introducing many more.")
     (home-page "http://www.webmproject.org/";)))
 
 (define-public youtube-dl
-  (package
-    (name "youtube-dl")
-    (version "2015.12.09")
-    (source (origin
-              (method url-fetch)
-              (uri (string-append "http://youtube-dl.org/downloads/";
-                                  version "/youtube-dl-"
-                                  version ".tar.gz"))
-              (sha256
-               (base32
-                "11rzb30ik4all43r7bnsnm35mvs37y7xj3g9r7ig9jr7qlbhllwk"))))
-    (build-system python-build-system)
-    (native-inputs `(("python-setuptools" ,python-setuptools)))
-    (home-page "http://youtube-dl.org";)
-    (synopsis "Download videos from YouTube.com and other sites")
-    (description
-     "Youtube-dl is a small command-line program to download videos from
+  (let* ((python-version "3.4")
+         (yt-dl-year "2015")
+         (yt-dl-month "12")
+         (yt-dl-day "09")
+         (make-version-string (lambda (string-list)
+                                (string-join string-list ".")))
+         (make-zero-trimmed-version-string (lambda (string-list)
+                                             (make-version-string
+                                              (map (cut string-trim <> #\0)
+                                                   string-list))))
+         (with-base-dir (lambda (relative-path)
+                          (string-append "lib/python"
+                                         python-version
+                                         "/site-packages/youtube_dl-"
+                                         (make-zero-trimmed-version-string
+                                          (list yt-dl-year
+                                                yt-dl-month
+                                                yt-dl-day))
+                                         "-py"
+                                         python-version
+                                         ".egg/"
+                                         relative-path))))
+    (package
+      (name "youtube-dl")
+      (version
+       (make-version-string (list yt-dl-year
+                                  yt-dl-month
+                                  yt-dl-day)))
+      (source (origin
+                (method url-fetch)
+                (uri (string-append "http://youtube-dl.org/downloads/";
+                                    version "/youtube-dl-"
+                                    version ".tar.gz"))
+                (sha256
+                 (base32
+                  "11rzb30ik4all43r7bnsnm35mvs37y7xj3g9r7ig9jr7qlbhllwk"))))
+      (build-system python-build-system)
+      (native-inputs `(("python-setuptools" ,python-setuptools)))
+      (native-search-paths
+       (list (search-path-specification
+              (variable "fish_complete_path")
+              (files `(,(with-base-dir "etc/fish/completions"))))
+             ;; TODO: fix bash completion
+             ;;(search-path-specification
+             ;; (variable "BASH_COMPLETION") ;we need to fix it
+             ;; (files `(,(with-base-dir "etc/bash_completion.d"))))
+             (search-path-specification
+              (variable "MANPATH")
+              (files `(,(with-base-dir "share/man"))))))
+      (home-page "http://youtube-dl.org";)
+      (synopsis "Download videos from YouTube.com and other sites")
+      (description
+       "Youtube-dl is a small command-line program to download videos from
 YouTube.com and a few more sites.")
-    (license license:public-domain)))
+      (license license:public-domain))))
 
 (define-public libbluray
   (package
-- 
2.6.3

Reply via email to