summaryrefslogtreecommitdiff
path: root/guix.scm
blob: 1034b680cc07312bf604d8c45edb853c3c454eb4 (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
(use-modules (guix packages)
             (guix gexp)
             (guix store)
             (guix monads)
             (guix derivations)
             (gnu packages base)
             (gnu packages compression)
             (gnu packages emacs)
             (gnu packages gettext)
             (gnu packages guile)
             (gnu packages guile-xyz)
             (gnu packages version-control))

(let ((local-repo
       (local-file ".git" "disfluid.git" #:recursive? #t))
      (bootstrap-script
       (computed-file
        "bootstrap.scm"
        #~(call-with-output-file #$output
            (lambda (port)
              (write
               '((@ (disfluid build bootstrap) main)
                 #:emacs #$(file-append emacs "/bin/emacs")
                 #:hall #$(file-append guile-hall "/bin/hall")
                 #:git #$(file-append git "/bin/git")
                 #:mkdir #$(file-append coreutils "/bin/mkdir")
                 #:which #$(file-append which "/bin/which")
                 #:autoreconf #$(file-append coreutils "/bin/true"))
               port))))))
  (run-with-store (open-connection)
    (mlet %store-monad
        ((guix.scm
          (gexp->derivation
              "guix.scm"
            (with-imported-modules '((guix build utils))
              #~(begin
                  (use-modules (guix build utils))
                  (set-path-environment-variable "PATH" '("bin") (list #$guile-3.0))
                  (invoke #$(file-append git "/bin/git") "clone" #$local-repo ".")
                  (delete-file "guix.scm")
                  (setenv "HOME" (getcwd))
                  (invoke #$(file-append guile-3.0 "/bin/guile") "-L" "." "-s" #$bootstrap-script)
                  (invoke #$(file-append guile-hall "/bin/hall") "guix" "-x")
                  (copy-file "guix.scm" #$output)))))
         (snapshot.tar.gz
          (gexp->derivation
              "disfluid-snapshot.tar.gz"
            (with-imported-modules '((guix build utils))
              #~(begin
                  (use-modules (guix build utils))
                  (set-path-environment-variable "PATH" '("bin") (list #$gzip))
                  (invoke #$(file-append git "/bin/git") "clone" #$local-repo ".")
                  (invoke #$(file-append git "/bin/git") "archive" "-o" #$output "HEAD"))))))
      (mlet %store-monad
          ((built (built-derivations (list guix.scm snapshot.tar.gz))))
        (let ((base (load (derivation->output-path guix.scm))))
          (return
           (package
             (inherit base)
             (arguments
              `(#:phases
                (modify-phases %standard-phases
                  (replace 'bootstrap
                    (lambda* (#:key inputs #:allow-other-keys)
                      (chdir "..")
                      (setenv "HOME" (getcwd))
                      (invoke "guile" "./bootstrap"))))))
             (native-inputs
              `(,@(package-native-inputs base)
                ("guile-hall" ,guile-hall)
                ("emacs" ,emacs)
                ("gettext" ,gnu-gettext)
                ("autoconf-archive" ,autoconf-archive)))
             (source (derivation->output-path snapshot.tar.gz))
             (synopsis
              (format #f "[SNAPSHOT]: ~a" (package-synopsis base)))
             (description
              (format #f "~a\n\nThis package version is @strong{not} released yet."
                      (package-description base))))))))))