aboutsummaryrefslogtreecommitdiff
path: root/km-packages/git-annex.scm
blob: e961994fa2cf178de1ee1a320a1960b4be632390 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
;;; git-annex.scm --- custom Guix packages for git-annex
;;;
;;; Copyright © 2019 Kyle Meyer <kyle@kyleam.com>
;;;
;;; This file is NOT part of GNU Guix.
;;;
;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU General Public License as
;;; published by the Free Software Foundation, either version 3 of the
;;; License, or (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;;; General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program.  If not, see
;;; <https://www.gnu.org/licenses/>.

(define-module (km-packages git-annex)
  #:use-module (gnu packages)
  #:use-module (gnu packages haskell)
  #:use-module (gnu packages haskell-apps)
  #:use-module (gnu packages ipfs)
  #:use-module (guix build utils)
  #:use-module (guix build-system trivial)
  #:use-module (guix build-system haskell)
  #:use-module (guix download)
  #:use-module (guix gexp)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (ice-9 popen)
  #:use-module (ice-9 rdelim))

(define %source-dir
  (string-append (getenv "HOME") "/src/haskell/git-annex"))

;; Copied from guile-daemon.
(define (git-output . args)
  "Execute 'git ARGS ...' command and return its output without trailing
newspace."
  (with-directory-excursion %source-dir
    (let* ((port   (apply open-pipe* OPEN_READ "git" args))
           (output (read-string port)))
      (close-port port)
      (string-trim-right output #\newline))))

(define (current-commit)
  (git-output "rev-parse" "HEAD"))

(define-public ghc-magic
  (package
    (name "ghc-magic")
    (version "1.1")
    (source
     (origin
       (method url-fetch)
       (uri (string-append
             "https://hackage.haskell.org/package/magic/magic-"
             version
             ".tar.gz"))
       (sha256
        (base32
         "10p0gjjjwr1dda7hahwrwn5njbfhl67arq3v3nf1jr3vymlkn75j"))))
    (build-system haskell-build-system)
    (home-page
     "http://hackage.haskell.org/package/magic")
    (synopsis "Interface to C file/magic library")
    (description
     "This package provides a Haskell interface to the C libmagic
library. With it, you can determine the type of a file by examining
its contents rather than its name. The Haskell interface provides a
full-featured binding.")
    ;; TODO: check
    (license license:bsd-2)))

(define-public git-annex-dev
  (let ((commit (current-commit)))
    (package
      (inherit git-annex)
      (name "git-annex-dev")
      (version (string-append "000-" (string-take commit 7)))
      (source (local-file %source-dir
                          #:recursive? #t
                          #:select? (git-predicate %source-dir)))
      (arguments
       `(#:tests? #f
         ,@(substitute-keyword-arguments (package-arguments git-annex)
             ((#:phases phases)
              `(modify-phases ,phases
                 (add-before 'factor-setup 'delete-setup
                   (lambda _
                     ;; Otherwise get write error because is read-only.
                     (delete-file "Setup.hs")
                     #t))
                 (delete 'check))))))
      (inputs `(("ghc-concurrent-output" ,ghc-concurrent-output)
                ("ghc-magic" ,ghc-magic)
                ,@(package-inputs git-annex))))))

;; Upstream doesn't use ghc-magic yet.
(define-public km-git-annex
  (package
    (inherit git-annex)
    (name "km-git-annex")
    (version "7.20190730")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://hackage.haskell.org/package/"
                           "git-annex/git-annex-" version ".tar.gz"))
       (sha256
        (base32
         "16mya2dm7q9ggdmwyszri85qnnxf0l71xnn8khnxl5fqrh2zvsjg"))))
    (arguments
     `(#:tests? #f
       ,@(substitute-keyword-arguments (package-arguments git-annex)
           ((#:phases phases)
            `(modify-phases ,phases
               (delete 'check))))))
    (inputs `(("ghc-magic" ,ghc-magic)
              ,@(package-inputs git-annex)))))

(define-public git-annex-remote-ipfs
  (package
    (name "git-annex-remote-ipfs")
    (version "0.20190702")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://git-annex.branchable.com/"
                           "special_remotes/external/git-annex-remote-ipfs"))
       (sha256
        (base32
         "0m3fwaz4r7y0xf07rnh23n7rk2qm8idizslspwcqmp413m97w345"))))
    (build-system trivial-build-system)
    (arguments
     `(#:modules ((guix build utils))
       #:builder
       (begin
         (use-modules (guix build utils))
         (let* ((file (assoc-ref %build-inputs "source"))
                (out (string-append %output "/bin"))
                (outfile (string-append out "/git-annex-remote-ipfs")))
           (mkdir-p out)
           (copy-file file outfile)
           (chmod outfile #o555)
           #t))))
    (propagated-inputs
     `(("go-ipfs" ,go-ipfs)))
    (home-page "https://git-annex.branchable.com")
    (synopsis "todo")
    (description "todo")
    (license license:gpl3)))