From: Joshua Branson via Bug reports for GNU Guix <bug-guix@gnu.org>
To: Leo Prikler <leo.prikler@student.tugraz.at>
Cc: 48974@debbugs.gnu.org
Subject: bug#48974: A possible shepherd bug (it's very minor)
Date: Fri, 25 Jun 2021 14:06:08 -0400 [thread overview]
Message-ID: <875yy1vmy7.fsf@dismail.de> (raw)
In-Reply-To: <6254e4d32697986bd61986e10399f341930c5c2e.camel@student.tugraz.at> (Leo Prikler's message of "Fri, 25 Jun 2021 11:56:40 +0200")
Leo Prikler <leo.prikler@student.tugraz.at> writes:
> Hi,
>
> Am Freitag, den 25.06.2021, 05:31 -0400 schrieb Joshua Branson:
>> Leo Prikler <leo.prikler@student.tugraz.at> writes:
>>
>> > Hi,
>> >
>> > Am Samstag, den 12.06.2021, 20:09 +0000 schrieb jbranso@dismail.de:
>> > > June 12, 2021 3:39 PM, "Leo Prikler" <
>> > > leo.prikler@student.tugraz.at>
>> > > wrote:
>> > >
>> > > > Am Samstag, den 12.06.2021, 09:26 -0400 schrieb Joshua Branson:
>> > > >
>> > > > > Hello!
>> > > > >
>> > > I'll tell you what, why don't we leave this "bug" open for a
>> > > week...I'll try to write
>> > > the code that does what I want, and I'll email the answer.
>> > >
>> > > Then I'll edit the manual to provide an example!
>> Well, it's been about a week. Here is my current code that doesn't
>> work.
>> haha.
>>
>> #+BEGIN_SRC scheme
>> (define %my-desktop-services
>> (modify-services %desktop-services ;;end of remove services
>> (mingetty-service-type config =>
>> (mingetty-configuration
>> (inherit config)
>> ;; ERROR at the NEXT LINE
>> (auto-login-to-tty-3 config)
>> ))))
>>
>> (define (auto-login-to-tty-3 config)
>> (if (string=? "3" (mingetty-configuration-tty config))
>> '(auto-login "joshua")
>> '(auto-login #f)))
>> #+END_SRC
>>
>> It obviously doesn't work because I am treating modify-services as if
>> it were a procedure. In fact, it is a macro. :)
> That's not the issue here, the issue is that you're treating mingetty-
> configuration as… I'm not really sure what exactly, when it is in fact
> a record constructor.
Oh!!!! Light bulb! I knew that! I've made quite a few record
constructors for endlessh and my almost complete sway service:
http://issues.guix.gnu.org/39136
https://notabug.org/jbranso/guix-config/src/master/sway-service.scm
>
> Try the following:
>
> #+BEGIN_SRC scheme
> (define (auto-login-to-tty tty user)
> ;; TODO: you might want to implement this as match-lambda instead
I will try that!
> (lambda (config)
> (if (string=? tty (mingetty-configuration-tty mingetty-config))
> (mingetty-configuration
> (inherit config)
> (auto-login user))
> config)))
>
> (define %my-desktop-services
> (modify-services %desktop-services
>
> (mingetty-service-type config =>
> (auto-login-
> to-tty "3" "joshua"))))
> #+END_SRC
>
Hmmm. Is that (define (auto-login-to-tty tty user) ...) a closure? I
wonder why you need that lambda inside of it...Probably to pass the
config variable into the function...hmmm. I still don't understand why
it is necessary. I'll think about that a bit later on.
>
>> #+BEGIN_SRC scheme
>> (define (auto-login-to-tty-3 mingetty-service)
>> (if (string=? "3" (mingetty-configuration-tty config))
>> '(mingetty-configuration
>> (auto-login "joshua")
>> (tty "3"))
>> mingetty-service))
> Don't quote mingetty-configuration et al. They're first-class syntax,
> not just weird lists.
Yeah that's true. I do actually like (guix records)! I feel like that
file should be upstreamed into guile!
>
>> (define (my-modify-%desktop-services-to-auto-login-on-tty-3 %desktop-
>> services)
>> ;; to be written
>> ;; though I think fold, or map, may be useful functions here.
>>
>> ;;somehow I will use this function...
>> (auto-login-to-tty-3 mingetty-service)
>> )
>>
>> (define %my-desktop-services
>> (my-modify-%desktop-services-to-auto-login-on-tty-3 %desktop-
>> services))
> I don't think you need to implement modify-services on your own, rather
> just use the existing thing in the "correct" way – i.e. adhering to the
> expectations given by the already existing procedure (or macro).
Thanks again! The current code doesn't quite work for me yet. I'll try
using match-lambda to define it. I'll post again when I have a free
moment. When i get it working, I'll send a patch to the manual via
guix-patches and CC you. Is that ok? Or would you rather that
documentation be in the cookbook?
>> #+END_SRC
> Regards,
> Leo
>
--
Joshua Branson (joshuaBPMan in #guix)
Sent from Emacs and Gnus
https://gnucode.me
https://video.hardlimit.com/accounts/joshua_branson/video-channels
https://propernaming.org
"You can have whatever you want, as long as you help
enough other people get what they want." - Zig Ziglar
next prev parent reply other threads:[~2021-06-25 18:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-12 13:26 bug#48974: A possible shepherd bug (it's very minor) Joshua Branson via Bug reports for GNU Guix
2021-06-12 19:39 ` Leo Prikler
2021-06-12 20:09 ` jbranso--- via Bug reports for GNU Guix
2021-06-12 21:13 ` Leo Prikler
2021-06-25 9:31 ` Joshua Branson via Bug reports for GNU Guix
2021-06-25 9:56 ` Leo Prikler
2021-06-25 18:06 ` Joshua Branson via Bug reports for GNU Guix [this message]
2021-06-25 18:28 ` Leo Prikler
2021-07-02 22:57 ` Joshua Branson via Bug reports for GNU Guix
2021-07-03 6:41 ` Leo Prikler
2021-07-03 7:37 ` pelzflorian (Florian Pelz)
2021-07-05 23:59 ` Joshua Branson via Bug reports for GNU Guix
2021-06-12 23:34 ` jbranso--- via Bug reports for GNU Guix
2021-06-13 7:48 ` Leo Prikler
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875yy1vmy7.fsf@dismail.de \
--to=bug-guix@gnu.org \
--cc=48974@debbugs.gnu.org \
--cc=jbranso@dismail.de \
--cc=leo.prikler@student.tugraz.at \
/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 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.