Ben Yeoman <[email protected]> writes:
> I have a few basic scripts I'd like to include in a `guix home`
> config. Specifically, I'd like for the scripts to be added to the
> store, and to my PATH. Is there a nice/concise way to do this without
> making an actual package for the scripts, or do people just make some
> kind of function that generates a package given a `local-file` script?
Hi Ben,
While you can use the home-files-service-type to add executable files to your
$HOME directory, you will also need to use the home-bash-service-type to add
the directory where you copied those files to your $PATH. This works, but it
does require keeping those configurations in sync with one another. As has also
been noted, you can write home services to install files into certain
locations, but this is usually only done when a service needs to install
specific files that it will depend on for running later. Moreover, defining
your own services is more complicated than defining your own packages.
What you are looking to do (add executable files to your PATH) is exactly the
use case for a package. To get you going quickly, here's a simple function that
will turn any directory of scripts into a package, which will appear on your
$PATH when you include it in the packages field of your home-environment record:
(use-modules
((gnu home) #:select (home-environment))
((guix build-system copy) #:select (copy-build-system))
((guix gexp) #:select (local-file assume-valid-file-name))
((guix packages) #:select (package)))
(define (make-scripts-package package-name directory)
(package
(name package-name)
(version "LATEST")
(source (local-file (assume-valid-file-name directory) #:recursive? #t))
(build-system copy-build-system)
(arguments `(#:install-plan '(("." "./bin"))))
(home-page #f)
(synopsis (string-append "Scripts package: " package-name))
(description (string-append "Scripts package: " package-name))
(license #f)))
(home-environment
...
(packages (list
(make-scripts-package "good-scripts"
"/home/ben/path/to/my-good-scripts")
(make-scripts-package "great-scripts"
"/home/ben/path/to/my-great-scripts"))))
Have fun and happy hacking!
Gary
--
GPG Key ID: C4FBEDBD
Use `gpg --search-keys [email protected]' to find me
Protect yourself from surveillance: https://emailselfdefense.fsf.org
=======================================================================
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
Why is HTML email a security nightmare? See https://useplaintext.email/
Please avoid sending me MS-Office attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html