unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Pierre Neidhardt <mail@ambrevar.xyz>
To: guix-devel@gnu.org
Subject: How can I set architecture/system-specific origin sources?
Date: Tue, 31 Dec 2019 12:30:06 +0100	[thread overview]
Message-ID: <87imlwd96p.fsf@ambrevar.xyz> (raw)

[-- Attachment #1: Type: text/plain, Size: 1920 bytes --]

Hi!

I'd like to write a package definition whose source is different
depending on the system / arch it is built for.

I thought of writing something like this:

--8<---------------cut here---------------start------------->8---
(source (origin
         (method url-fetch)
         (uri
          (string-append "http://foo.bar/"
                         version "-" 
                         (match (or (%current-target-system)
                                    (%current-system))
                           ("i686-linux" "x86")
                           ("x86_64-linux" "x86_64"))
                         ".tgz"))
         (sha256
          (base32
           (match (or (%current-target-system)
                      (%current-system))
             ("x86_64-linux"
              "0y4qms4lm9xiix93g45337rx5nrp0y3gb0x0avyv7l9qrkk03zz8")
             ("i686-linux"
              "0yc8n6vpqyb6qhcv5kwvr3h21ya271fi930fvd98hlkg8cg5kwyf"))))))
--8<---------------cut here---------------end--------------->8---

My laptop is a x86_64-linux and the above definition always uses the
x86_64 source, even with

  guix build --system=i686-linux foo

In Nix, the following works:

--8<---------------cut here---------------start------------->8---
  src =
    if stdenv.hostPlatform.system == "x86_64-linux" then
      fetchurl {
        url = "http://foo.bar/...";
        sha256 = "e8ff01e6cc38d1b3fd56a083f5860737dbd2f319a39037528fb1a74a89ae9878";
      }
    else if stdenv.hostPlatform.system == "i686-linux" then
      fetchurl {
        url = "http://foo.bar/...";
        sha256 = "cef3591e436f528852db0e8c145d3842f920e0c89bcfb219c466797cb7b18879";
      }
    else throw "foo does not support platform ${stdenv.hostPlatform.system}";
--8<---------------cut here---------------end--------------->8---

Is this a Guix bug?

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

             reply	other threads:[~2019-12-31 11:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-31 11:30 Pierre Neidhardt [this message]
2019-12-31 12:06 ` How can I set architecture/system-specific origin sources? Mathieu Othacehe
2019-12-31 14:00   ` Pierre Neidhardt
2020-01-01 12:22     ` Efraim Flashner
2020-01-02 11:21       ` Pierre Neidhardt
2020-01-02 22:16   ` Ludovic Courtès
2020-01-02 22:33     ` Pierre Neidhardt

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=87imlwd96p.fsf@ambrevar.xyz \
    --to=mail@ambrevar.xyz \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).