unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Sourcing a script in phases
@ 2022-12-25 22:43 phodina via
  2022-12-26 12:52 ` Reza Housseini
  2022-12-26 21:37 ` Edouard Klein
  0 siblings, 2 replies; 4+ messages in thread
From: phodina via @ 2022-12-25 22:43 UTC (permalink / raw)
  To: help-guix

Hi,

is there a way to source a script in the phases?
I tried to do:

(invoke "source" "env.sh")
or
(invoke "." "env.sh")

But it didn't work since they are builtin in the shell.

----
Petr

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sourcing a script in phases
  2022-12-25 22:43 Sourcing a script in phases phodina via
@ 2022-12-26 12:52 ` Reza Housseini
  2022-12-26 21:37 ` Edouard Klein
  1 sibling, 0 replies; 4+ messages in thread
From: Reza Housseini @ 2022-12-26 12:52 UTC (permalink / raw)
  To: help-guix


[-- Attachment #1.1.1: Type: text/plain, Size: 337 bytes --]

> (invoke "source" "env.sh")
> or
> (invoke "." "env.sh")

I had the same problem and ended up doing

(invoke "bash" "-c" "source env && ./command")

not the most elegant, but it did work.

Cheers,

-- 
Reza Housseini

This message is signed with my GnuPG key:

     C0F3 0812 9AF2 80F4 0830 C2C1 C375 C6AF 0512 5C52


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 15557 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sourcing a script in phases
  2022-12-25 22:43 Sourcing a script in phases phodina via
  2022-12-26 12:52 ` Reza Housseini
@ 2022-12-26 21:37 ` Edouard Klein
  2022-12-27 23:25   ` phodina
  1 sibling, 1 reply; 4+ messages in thread
From: Edouard Klein @ 2022-12-26 21:37 UTC (permalink / raw)
  To: phodina; +Cc: help-guix

Hi,

It's probably not the right answer, but for lack of time to find the
actual solution when I faced the same problem as you, here is what I
did:

https://gitlab.com/edouardklein/guix/-/blob/beaverlabs/beaver/packages/python-xyz.scm#L191

#+begin_src scheme
#:builder
      (begin
        (use-modules (guix build utils))
        (let* ((bash (assoc-ref %build-inputs "bash"))
               (requisomatic (assoc-ref %build-inputs "requisomatic"))
               (dir (string-append (assoc-ref %outputs "out") "/bin"))
               (fname (string-append dir "/requisomatic-server")))
          (mkdir-p  dir)
          (with-output-to-file fname
            (lambda _
              (display (string-append "#!" bash "/bin/bash\n"))
              (display "source /run/current-system/profile/etc/profile\n")
              (display "REQUISOMATIC_DB_FILE=$1 gunicorn --bind=$2 --pid=$3 requisomatic:app\n")))
          (chmod fname #o755)
          #t))))
#+end_src

Basically this creates a shell script that sources whatever you want to
source, and then call the executable you want to call.

This is not exactly what you want to do, but you can use this technique
to create a script that will run the build commands you want to run, and
then call it during the build phase.

Again, this is probably not the right answer.

Cheers,

Edouard.
phodina via <help-guix@gnu.org> writes:

> Hi,
>
> is there a way to source a script in the phases?
> I tried to do:
>
> (invoke "source" "env.sh")
> or
> (invoke "." "env.sh")
>
> But it didn't work since they are builtin in the shell.
>
> ----
> Petr


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sourcing a script in phases
  2022-12-26 21:37 ` Edouard Klein
@ 2022-12-27 23:25   ` phodina
  0 siblings, 0 replies; 4+ messages in thread
From: phodina @ 2022-12-27 23:25 UTC (permalink / raw)
  To: help-guix; +Cc: Edouard Klein, reza.housseini@gmail.com

Hi,

thanks for both ideas.

I went the easiest path and opted for:


(invoke "bash" "-c" "source env.sh && kmk")


Not the most polished line of code but it moves me a step ahead :-D

FIY: I'm attempting to build Virtualbox

----
Petr


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-27 23:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-25 22:43 Sourcing a script in phases phodina via
2022-12-26 12:52 ` Reza Housseini
2022-12-26 21:37 ` Edouard Klein
2022-12-27 23:25   ` phodina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).