unofficial mirror of 
 help / color / mirror / Atom feed
From: Edouard Klein <>
To: Phil Beadling <>
Subject: Re: Find location of installed package in /gnu/store
Date: Sat, 15 May 2021 10:28:21 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

Hi !

This is where G-expressions will help you :)

Basically the path you need does not exist in the same "strata" as the
code of the package.

The following code will define a build-gexp function that evaluates a
G-expression and prints the resulting directory in the store. You can
try it in "guix repl" or with "guix build -f FILE"

A G-exp begins with #~ and withing the following expr, any piece of code
prefixed by #$ is recursively replaced by its value, but only if this
value is a primitive value (string, int,...) or a package.

If it is a package, it gets replaced by the path in the store of that

So to give a short answer, run the following into the REPL to get your
     (guix gexp)
     (guix store)
     (guix derivations)
     (gnu packages java))
    (define (build-gexp gexp)
      "Build GEXP using the local daemon."
      (let ((derivation 
             (run-with-store (open-connection)
         (list derivation))
        (derivation-output-path (assoc-ref (derivation-outputs derivation) "out"))))

 (with-imported-modules '((guix build utils))
       (use-modules (guix build utils))
       (mkdir-p  (string-append #$output "/bin"))
       (with-output-to-file (string-append #$output "/bin/")
         (lambda _
           (display (string-append "Iced tea lives at:" #$icedtea-8)))))))

This wil output a path, in my case

and in it you'll have the file:

which contains
Iced tea lives at:/gnu/store/vaqdvsqdv5mads38dp6pc5827pdgnmb3-icedtea-3.7.0

Given your stated use case, you may be interested in the following
upcoming patch:

It will let you wrap any executable in the appropriate env vars, so I
guess you will be able to do something like
#$(wrap-in-search-paths #~(string-append #$output "/bin/your-script")
(list icedtea-8))

Hopefully icedtea-8 sets the correct search paths, but I believe it



Phil Beadling writes:

> Hi,
> Given a package definition, eg icedtea-8's JDK, how can can I determine the
> location of the installed package in my /gnu/store?
> There doesn't seem to be anything on the package module itself, presumably
> because this is static data, and what I need is something to calculate the
> hash of the resulting install specific to my Guix?
> eg
> scheme@(guix-user) [3]> (package-outputs icedtea-8)
> $8 = ("out" "jdk" "doc")
> scheme@(guix-user) [3]>
> I'd like to return this location using the package name or definition as an
> input:
> /gnu/store/i3vf1a49m0abcjqza19mb4mkjmc6k60n-icedtea-3.7.0-jdk/
> The aim is to use this to derivive the JDK include directories in a generic
> way for some scripts I'm writing, such that I don't need to update them
> each time the JDK hash changes after a guix pull.
> Cheers,
> Phil.

  reply	other threads:[~2021-05-15  8:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-15  2:28 Phil Beadling
2021-05-15  8:28 ` Edouard Klein [this message]
2021-05-15 16:27   ` Phil Beadling
2021-05-15  9:17 ` Björn Höfling
2021-05-16  2:58 ` Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \
    --subject='Re: Find location of installed package in /gnu/store' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

unofficial mirror of 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror guix-user/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guix-user guix-user/ \
	public-inbox-index guix-user

Example config snippet for mirrors.
Newsgroups are available over NNTP:

AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git