Skip to content

Instantly share code, notes, and snippets.

@tribals
Last active June 6, 2022 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tribals/409ce9906a485346a4fd1410c29d1d2f to your computer and use it in GitHub Desktop.
Save tribals/409ce9906a485346a4fd1410c29d1d2f to your computer and use it in GitHub Desktop.
Guix package for simple script with "literal" source provided as `(plain-file ...)`
(use-modules
(gnu packages python)
(guix build-system copy)
(guix channels)
(guix download)
(guix inferior)
(guix gexp)
((guix licenses) #:select (wtfpl2 license-uri))
(guix packages)
(guix profiles)
(srfi srfi-1))
(define license
(package
(name "license")
(version "0")
(source (program-file
"license.scm"
(with-imported-modules
'((ice-9 popen)
(ice-9 format)
(ice-9 textual-ports)
(srfi srfi-19))
#~(begin
(use-modules
(ice-9 popen)
(ice-9 format)
(ice-9 textual-ports)
(srfi srfi-19)) ; date/time
(define (license)
(copy-file "/usr/src/COPYING.WTFPL" "LICENSE"))
(define (copying)
(with-output-to-file "COPYING"
(lambda ()
(format #t "\
Copyright © ~a ~a ~a
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See the LICENSE file for more details.
"
(date-year (current-date))
(string-trim-both (get-string-all (open-input-pipe "git config user.name")))
(string-trim-both (get-string-all (open-input-pipe "git config user.email")))))))
(define (main _)
(license)
(copying))))))
(build-system copy-build-system) ; gnu-build-system?
(arguments
`(#:install-plan
`(("license.scm" "bin/")
#~`((string-append #$(this-package-input "wtfpl") "/copying") "/usr/src/COPYING.WTFPL"))
#:phases
(modify-phases %standard-phases
; (replace 'install
; (lambda* (#:key inputs outputs #:allow-other-keys)
; (let ((wtfpl (assoc-ref inputs "wtfpl"))
; (out (assoc-ref outputs "out")))
; (mkdir-p (string-append out "/usr/src"))
; (copy-file (string-append wtfpl "/copying")
; (string-append out "/usr/src/COPYING.WTFPL")))))
(add-after 'install 'make-script-executable
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(chmod (string-append out "/bin/license.scm") #o755)))))))
(inputs
`(
; `("guile" ,guile)))
("wtfpl" ,(origin
(method url-fetch)
(uri (string-append (license-uri wtfpl2) "/txt/copying"))
(sha256
(base32 "1r93nakq692clnh97mns4x7f8zv2zrf5c0ga8hfxr471j61jamh3"))))))
(synopsis "Produces LICENSE and COPYING files under working directory")
(description #f)
(license wtfpl2)
(home-page #f)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment