unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Jake Shilling <shilling.jake@gmail.com>
To: Julien Lepiller <julien@lepiller.eu>, jgart <jgart@dismail.de>
Cc: Guix Devel <guix-devel@gnu.org>
Subject: Re: foreign-distro?
Date: Sun, 20 Nov 2022 20:57:30 -0500	[thread overview]
Message-ID: <87o7t19iid.fsf@gmail.com> (raw)
In-Reply-To: <20221120230833.1220f1d8@sybil.lepiller.eu>

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


I've experimented with the distinction in my config, because I wanted to
be able to add home-services conditionally (e.g. I wanted my GuixSD to
install a destop envrionment, but my work laptop to only setup emacs and
its dependencies).

My approache was to just parse the `/etc/os-release` file if it exists:
```
(define (os-release)
  (guard (_
          (else #f))
    (call-with-input-file "/etc/os-release"
      (lambda (port)
        (let loop ((line (read-line port))
                   (result '()))
          (if (eof-object? line)
              (reverse result)
              (begin
                (let* ((split (string-split line #\=))
                       (key (string->symbol (car split)))
                       (val (if (string-match "\".*\"" (cadr split))
                                (substring (cadr split) 1 (- (string-length (cadr split)) 1))
                                (string->symbol (cadr split))))
                       (d (cons key val)))
                  (loop (read-line port)
                        (cons d result))))))))))
```

Then I define a couple wrappers:

```
(define (linux-distro-id)
  (if (linux?)
      (assq-ref (os-release) 'ID)
      #f))

(define (guix-system?)
  (eq? (linux-distro-id) 'guix))
```

The config was never really fleshed out because I ended up just using my
GuixSD computer for work instead.

On 2022-11-20 23:08, Julien Lepiller wrote:

> Le Sun, 20 Nov 2022 14:54:40 -0600,
> jgart <jgart@dismail.de> a écrit :
>
>> Does Guix have a declarative Guix API way of knowing if it is
>> installing a package into foreign distro versus Guix System?
>> 
>> I'm thinking of a function like `foreign-distro?`:
>> 
>> ```
>> (define-public peek
>>   (package
>>    (name "peek")
>>    ...
>> (inputs 
>>   `(,@(if (foreign-distro?) `(("ffmpeg" ,ffmpeg)) '())))
>> ```
>> 
>> The above includes ffmpeg in the inputs only if installing peek on a
>> foreign distro. It could additionally patch the ffmpeg executable in
>> a peek package phases if foreign-distro? returns #t.
>> 
>> WDYT
>> 
>
>
> Guix doesn't have a notion of foreign distro, it's all in your head,
> and there's no difference between Guix System and other distros in the
> Guix package manager's point of view :)
>
> To be more specific, Guix only knows what you current system is (that's
> captured by %current-system). It's probably x86_64-linux right know. As
> you can see, there's no place in there to tell it whether you're on a
> foreign distro or not.
>
> Lastly, I don't think I would want to differentiate the two cases,
> especially since it would mean that somehow Guix packages depend on
> something external. There's this idea that Guix packages should somehow
> be self-sufficient.
>

-- 
Best regards,
Jake Shilling

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

  reply	other threads:[~2022-11-21 15:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-20 20:54 foreign-distro? jgart
2022-11-20 22:08 ` foreign-distro? Julien Lepiller
2022-11-21  1:57   ` Jake Shilling [this message]
2022-11-23 10:36 ` foreign-distro? Zhu Zihao
2022-11-23 12:34   ` foreign-distro? Wojtek Kosior via Development of GNU Guix and the GNU System distribution.

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=87o7t19iid.fsf@gmail.com \
    --to=shilling.jake@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=jgart@dismail.de \
    --cc=julien@lepiller.eu \
    /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).