[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reusing code for a build-phase?
From: |
Csepp |
Subject: |
Re: Reusing code for a build-phase? |
Date: |
Sun, 06 Aug 2023 14:49:29 +0200 |
Hartmut Goebel <h.goebel@crazy-compilers.com> writes:
> Hi,
>
> I'm currently packaging vagrant and some plugins. For all plugins an
> additional phase is required, generating a json file, see below. Since this
> is quite
> some code, I'd like to put it into some definition or some wrapper. Since it
> uses (this-package-verion), my attempts failed.
>
> At best, a plugin would then be defined like
>
> (define-public vagrant-abc (vagrant-plugin-wrapper (package …
>
> Anyhow I'd be happy to when being able to use some function in the phase
> instead of duplicating the code.
>
> Any ideas? Many thanks in advance
>
> (arguments
> (list
> #:tests? #f ; tests involve running vagrant and downloading a box
> #:phases
> #~(modify-phases %standard-phases
> (add-after 'install 'install-plugin.json
> (lambda _
> (let* ((plugins.d (string-append
> #$output "/share/vagrant-plugins/plugins.d"))
> (plugin.json (string-append
> plugins.d "/" #$name ".json")))
> (mkdir-p plugins.d)
> #$(with-extensions (list guile-json-4)
> #~(begin
> (use-modules (json))
> (call-with-output-file plugin.json
> (lambda (port)
> (scm->json
> '((#$name
> .
> (("ruby_version"
> . #$(package-version (this-package-input
> "ruby")))
> ("vagrant_version"
> . #$(package-version (this-package-input
> "vagrant")))
> ("gem_version" . "")
> ("require" . "")
> ("sources" . #()))))
> port)))))))))))
Maybe you could create a build system that inherits from the one these
packages use, but adds the extra phase.