* foreign-distro?
@ 2022-11-20 20:54 jgart
2022-11-20 22:08 ` foreign-distro? Julien Lepiller
2022-11-23 10:36 ` foreign-distro? Zhu Zihao
0 siblings, 2 replies; 5+ messages in thread
From: jgart @ 2022-11-20 20:54 UTC (permalink / raw)
To: Guix Devel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: foreign-distro?
2022-11-20 20:54 foreign-distro? jgart
@ 2022-11-20 22:08 ` Julien Lepiller
2022-11-21 1:57 ` foreign-distro? Jake Shilling
2022-11-23 10:36 ` foreign-distro? Zhu Zihao
1 sibling, 1 reply; 5+ messages in thread
From: Julien Lepiller @ 2022-11-20 22:08 UTC (permalink / raw)
To: jgart; +Cc: Guix Devel
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: foreign-distro?
2022-11-20 22:08 ` foreign-distro? Julien Lepiller
@ 2022-11-21 1:57 ` Jake Shilling
0 siblings, 0 replies; 5+ messages in thread
From: Jake Shilling @ 2022-11-21 1:57 UTC (permalink / raw)
To: Julien Lepiller, jgart; +Cc: Guix Devel
[-- 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 --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: foreign-distro?
2022-11-20 20:54 foreign-distro? jgart
2022-11-20 22:08 ` foreign-distro? Julien Lepiller
@ 2022-11-23 10:36 ` Zhu Zihao
2022-11-23 12:34 ` foreign-distro? Wojtek Kosior via Development of GNU Guix and the GNU System distribution.
1 sibling, 1 reply; 5+ messages in thread
From: Zhu Zihao @ 2022-11-23 10:36 UTC (permalink / raw)
To: jgart; +Cc: guix-devel
[-- Attachment #1: Type: text/plain, Size: 881 bytes --]
If you want to left the choice to user. You can just don't patch it. Or
you can always patch it because user can still use package transformer
to specify a custom ffmpeg.
jgart <jgart@dismail.de> writes:
> 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
--
Retrieve my PGP public key:
gpg --recv-keys B3EBC086AB0EBC0F45E0B4D433DB374BCEE4D9DC
Zihao
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 255 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: foreign-distro?
2022-11-23 10:36 ` foreign-distro? Zhu Zihao
@ 2022-11-23 12:34 ` Wojtek Kosior via Development of GNU Guix and the GNU System distribution.
0 siblings, 0 replies; 5+ messages in thread
From: Wojtek Kosior via Development of GNU Guix and the GNU System distribution. @ 2022-11-23 12:34 UTC (permalink / raw)
To: Zhu Zihao; +Cc: jgart, guix-devel
[-- Attachment #1: Type: text/plain, Size: 2139 bytes --]
Hi all,
Sorry to tell this - I don't think something like this would be even
possible to implement :/
AFAIK package definition fields like `(inputs)` don't just describe how
the package gets installed. They affect the actual build. So if we
really wanted this feature, we'd need to build 2 separate variants of a
package - one for Guix system and one for foreign distros.
In addition to looking like an overkill, such separate build variants
could also require changes to existing utilities like `guix copy`.
Besides all this, It it not that easy to determine whether Guix is
running under a foreign distro. One idea would be to check whether the
currently-running init system is Shepherd. But what if the user is
running Guix commands inside a Guix system chroot? The Shepherd process
is not going to be visible in such case
Wojtek
-- (sig_start)
website: https://koszko.org/koszko.html
PGP: https://koszko.org/key.gpg
fingerprint: E972 7060 E3C5 637C 8A4F 4B42 4BC5 221C 5A79 FD1A
Meet Kraków saints! #18: blessed Józef Kowalski
Poznaj świętych krakowskich! #18: błogosławiony Józef Kowalski
https://pl.wikipedia.org/wiki/Józef_Kowalski_(duchowny)
-- (sig_end)
On Wed, 23 Nov 2022 18:36:49 +0800
Zhu Zihao <all_but_last@163.com> wrote:
> If you want to left the choice to user. You can just don't patch it. Or
> you can always patch it because user can still use package transformer
> to specify a custom ffmpeg.
>
>
> jgart <jgart@dismail.de> writes:
>
> > 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
>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-11-23 12:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-20 20:54 foreign-distro? jgart
2022-11-20 22:08 ` foreign-distro? Julien Lepiller
2022-11-21 1:57 ` foreign-distro? Jake Shilling
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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.