unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#48974: A possible shepherd bug (it's very minor)
@ 2021-06-12 13:26 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
  0 siblings, 2 replies; 14+ messages in thread
From: Joshua Branson via Bug reports for GNU Guix @ 2021-06-12 13:26 UTC (permalink / raw)
  To: 48974

Hello!

I've had this issue every since I enabled automatic login on my guix
system like so:

#+BEGIN_SRC scheme
(define %my-desktop-services
  (modify-services
      %desktop-services 
    (mingetty-service-type config =>
                           (mingetty-configuration
                            (inherit config)
                            ;;auto login as joshua
                            (auto-login "joshua")))))

(operating-system
   ...
   (services (list %my-desktop-services)))
#+END_SRC

This is the "error message"

#+BEGIN_SRC sh
This is the GNU system.  Welcome
dobby login: joshua (automatic login)
This is the GNU operating system, welcome!

Cannot make/remove an entry for the specified session
#+END_SRC

Essentially, mingetty tries to auto log me in, but I am using desktop
services.  So mingetty tries to log me in, before many of the desktop
services are started.  However, I guess this doesn't work.  Meaning,
my autostart sway script is NOT run, until AFTER all of the desktop
services are started.  WHICH IS PROBABLY A GOOD IDEA.  I would rather
log in, when my desktop services have started, not before.

BUT the minor issue is that after I log in, =users= reports:

#+BEGIN_SRC sh
joshua@dobby ~> users
joshua joshua joshua joshua joshua joshua
#+END_SRC

So it looks like 6 versions of myself are logged in by the time I am
officially logged in and I auto start sway via .bash_profile:

#+BEGING_SRC sh
# Honor per-interactive-shell startup file
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi

# shepherd

if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
    export MOZ_ENABLE_WAYLAND=1
    export GUIX_PACKAGE_PATH=/home/joshua/prog/gnu/guix/guix-packages/
    XDG_DATA_DIRS=/var/lib/flatpak/exports/share:/home/joshua/.local/share/flatpak/exports/share:$XDG_DATA_DIRS
    # this may fix a bug that I have with termite confusing backspace as space in guix environment
    # export TERM=linux
    shepherd -c /home/joshua/.config/shepherd/init.scm &
    exec dbus-run-session sway
fi
#+END_SRC 


I'm guessing the root cause is that the shepherd starts most services
sequentially at the moment.  Anyway, I thought I'd share a minor issue
with you all!


Thanks!

Joshua Branson




^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#48974: A possible shepherd bug (it's very minor)
  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
  1 sibling, 0 replies; 14+ messages in thread
From: Leo Prikler @ 2021-06-12 19:39 UTC (permalink / raw)
  To: Joshua Branson, 48974

Am Samstag, den 12.06.2021, 09:26 -0400 schrieb Joshua Branson:
> Hello!
> 
> I've had this issue every since I enabled automatic login on my guix
> system like so:
> 
> #+BEGIN_SRC scheme
> (define %my-desktop-services
>   (modify-services
>       %desktop-services 
>     (mingetty-service-type config =>
>                            (mingetty-configuration
>                             (inherit config)
>                             ;;auto login as joshua
>                             (auto-login "joshua")))))
> 
> (operating-system
>    ...
>    (services (list %my-desktop-services)))
> #+END_SRC
I am sorry to say this, but rather than this being (just) a bug with
shepherd, your config looks seriously borked.  Why are you asking Guix
to autologin you on *every available console*?

Regards,
Leo





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#48974: A possible shepherd bug (it's very minor)
  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-12 23:34   ` jbranso--- via Bug reports for GNU Guix
  1 sibling, 2 replies; 14+ messages in thread
From: jbranso--- via Bug reports for GNU Guix @ 2021-06-12 20:09 UTC (permalink / raw)
  To: Leo Prikler, 48974

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've had this issue every since I enabled automatic login on my guix
>> system like so:
>> 
>> #+BEGIN_SRC scheme
>> (define %my-desktop-services
>> (modify-services
>> %desktop-services
>> (mingetty-service-type config =>
>> (mingetty-configuration
>> (inherit config)
>> ;;auto login as joshua
>> (auto-login "joshua")))))
>> 
>> (operating-system
>> ...
>> (services (list %my-desktop-services)))
>> #+END_SRC
> 
> I am sorry to say this, but rather than this being (just) a bug with

Thank you for speaking so gently! :)

> shepherd, your config looks seriously borked. Why are you asking Guix
> to autologin you on *every available console*?

HAHAHA! That's what I'm doing! I forgot that! Honestly, I did that, because I
couldn't figure out how to code "just auto log into console 1 ONLY". :)

Would you mind explaining how bad of a decision this is? Is this a BAD security practice?

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!

Thanks Leo (You sir, are a superstar!),

Joshua

> Regards,
> Leo




^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#48974: A possible shepherd bug (it's very minor)
  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-12 23:34   ` jbranso--- via Bug reports for GNU Guix
  1 sibling, 1 reply; 14+ messages in thread
From: Leo Prikler @ 2021-06-12 21:13 UTC (permalink / raw)
  To: jbranso, 48974

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've had this issue every since I enabled automatic login on my
> > > guix
> > > system like so:
> > > 
> > > #+BEGIN_SRC scheme
> > > (define %my-desktop-services
> > > (modify-services
> > > %desktop-services
> > > (mingetty-service-type config =>
> > > (mingetty-configuration
> > > (inherit config)
> > > ;;auto login as joshua
> > > (auto-login "joshua")))))
> > > 
> > > (operating-system
> > > ...
> > > (services (list %my-desktop-services)))
> > > #+END_SRC
> > 
> > I am sorry to say this, but rather than this being (just) a bug
> > with
> 
> Thank you for speaking so gently! :)
> 
> > shepherd, your config looks seriously borked. Why are you asking
> > Guix
> > to autologin you on *every available console*?
> 
> HAHAHA! That's what I'm doing! I forgot that! Honestly, I did that,
> because I
> couldn't figure out how to code "just auto log into console 1 ONLY".
> :)
> 
> Would you mind explaining how bad of a decision this is? Is this a
> BAD security practice?
It is seriously bad practice.  With just one TTY, you can usually
suspend it with programs such as vlock, plus it's expected that you
actually sit in front of the given TTY when the autologin happens. 
With all TTYs though, anyone could switch to the other and "lol, now
I'm jbranso".  The only configuration, that could possibly be worse is
autologin root :P

(Granted, it probably still takes physical access to exploit, but it's
something your family/friends could likely do just to troll you.)

> 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!
I'm pretty sure that the actual bug also exists, just not sure whether
that's on your config or on shepherd.  Using TTY1 for graphical stuff
is also somewhat rare in Guix land, I presume.  (Or rather, I can't
think of it as anything but a container for debug output spam :D)

As for getting this to work only on TTY1, you do get the config object,
so you can do stuff like 
  (if (is-tty1? config) (inherit+autologin config) config)  
Note of course, that is-tty1? is not a procedure that's ready-made, but
one that you'd need to build from primitives such as record accessors.

Regards,
Leo





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#48974: A possible shepherd bug (it's very minor)
  2021-06-12 20:09 ` jbranso--- via Bug reports for GNU Guix
  2021-06-12 21:13   ` Leo Prikler
@ 2021-06-12 23:34   ` jbranso--- via Bug reports for GNU Guix
  2021-06-13  7:48     ` Leo Prikler
  1 sibling, 1 reply; 14+ messages in thread
From: jbranso--- via Bug reports for GNU Guix @ 2021-06-12 23:34 UTC (permalink / raw)
  To: Leo Prikler, 48974

June 12, 2021 5:13 PM, "Leo Prikler" <leo.prikler@student.tugraz.at> wrote:

> 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:
>> 
> 
> I'm pretty sure that the actual bug also exists, just not sure whether
> that's on your config or on shepherd. Using TTY1 for graphical stuff
> is also somewhat rare in Guix land, I presume. (Or rather, I can't
> think of it as anything but a container for debug output spam :D)

So...whay tty should I auto login to start my sway session?  tty2?  tty3?

> 
> As for getting this to work only on TTY1, you do get the config object,
> so you can do stuff like
> (if (is-tty1? config) (inherit+autologin config) config)
> Note of course, that is-tty1? is not a procedure that's ready-made, but
> one that you'd need to build from primitives such as record accessors.

Thanks!

> 
> Regards,
> Leo




^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#48974: A possible shepherd bug (it's very minor)
  2021-06-12 23:34   ` jbranso--- via Bug reports for GNU Guix
@ 2021-06-13  7:48     ` Leo Prikler
  0 siblings, 0 replies; 14+ messages in thread
From: Leo Prikler @ 2021-06-13  7:48 UTC (permalink / raw)
  To: jbranso, 48974

Am Samstag, den 12.06.2021, 23:34 +0000 schrieb jbranso@dismail.de:
> June 12, 2021 5:13 PM, "Leo Prikler" <leo.prikler@student.tugraz.at>
> wrote:
> 
> > 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:
> > > 
> > 
> > I'm pretty sure that the actual bug also exists, just not sure
> > whether
> > that's on your config or on shepherd. Using TTY1 for graphical
> > stuff
> > is also somewhat rare in Guix land, I presume. (Or rather, I can't
> > think of it as anything but a container for debug output spam :D)
> 
> So...whay tty should I auto login to start my sway
> session?  tty2?  tty3?
In principle, any number is safe (even 1, but that's dedicated to
receive all the debug stuff and won't be particularly useful), so just
pick your favourite.  (The installer has TTY2 dedicated to the manual
and TTY3 the first console if that helps with your decision.)
> > As for getting this to work only on TTY1, you do get the config
> > object,
> > so you can do stuff like
> > (if (is-tty1? config) (inherit+autologin config) config)
> > Note of course, that is-tty1? is not a procedure that's ready-made, 
> > but
> > one that you'd need to build from primitives such as record
> > accessors.
> 
> Thanks!
> 
> > Regards,
> > Leo





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#48974: A possible shepherd bug (it's very minor)
  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
  0 siblings, 1 reply; 14+ messages in thread
From: Joshua Branson via Bug reports for GNU Guix @ 2021-06-25  9:31 UTC (permalink / raw)
  To: Leo Prikler; +Cc: 48974

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!
> I'm pretty sure that the actual bug also exists, just not sure whether
> that's on your config or on shepherd.  Using TTY1 for graphical stuff
> is also somewhat rare in Guix land, I presume.  (Or rather, I can't
> think of it as anything but a container for debug output spam :D)
>
> As for getting this to work only on TTY1, you do get the config object,
> so you can do stuff like
>   (if (is-tty1? config) (inherit+autologin config) config)
> Note of course, that is-tty1? is not a procedure that's ready-made, but
> one that you'd need to build from primitives such as record accessors.
>

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

I'm just popping in to give you an update on my progress.  I've probably
spent less than 20 minutes working on this.  The good news is I did find
the record accessor for tty is mingetty-configuration-tty.

My goal for the next week is to do something like this:

#+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))

(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))
#+END_SRC


I'll post again in about a week to tell you about my progress!

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




^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#48974: A possible shepherd bug (it's very minor)
  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
  0 siblings, 1 reply; 14+ messages in thread
From: Leo Prikler @ 2021-06-25  9:56 UTC (permalink / raw)
  To: Joshua Branson; +Cc: 48974

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!
> > I'm pretty sure that the actual bug also exists, just not sure
> > whether
> > that's on your config or on shepherd.  Using TTY1 for graphical
> > stuff
> > is also somewhat rare in Guix land, I presume.  (Or rather, I can't
> > think of it as anything but a container for debug output spam :D)
> > 
> > As for getting this to work only on TTY1, you do get the config
> > object,
> > so you can do stuff like
> >   (if (is-tty1? config) (inherit+autologin config) config)
> > Note of course, that is-tty1? is not a procedure that's ready-made, 
> > but
> > one that you'd need to build from primitives such as record
> > accessors.
> > 
> 
> 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.  

Try the following:
#+BEGIN_SRC scheme
(define (auto-login-to-tty tty user)
  ;; TODO: you might want to implement this as match-lambda instead
  (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


> #+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.

> (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).
> #+END_SRC
Regards,
Leo





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#48974: A possible shepherd bug (it's very minor)
  2021-06-25  9:56       ` Leo Prikler
@ 2021-06-25 18:06         ` Joshua Branson via Bug reports for GNU Guix
  2021-06-25 18:28           ` Leo Prikler
  0 siblings, 1 reply; 14+ messages in thread
From: Joshua Branson via Bug reports for GNU Guix @ 2021-06-25 18:06 UTC (permalink / raw)
  To: Leo Prikler; +Cc: 48974

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




^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#48974: A possible shepherd bug (it's very minor)
  2021-06-25 18:06         ` Joshua Branson via Bug reports for GNU Guix
@ 2021-06-25 18:28           ` Leo Prikler
  2021-07-02 22:57             ` Joshua Branson via Bug reports for GNU Guix
  0 siblings, 1 reply; 14+ messages in thread
From: Leo Prikler @ 2021-06-25 18:28 UTC (permalink / raw)
  To: Joshua Branson; +Cc: 48974

Am Freitag, den 25.06.2021, 14:06 -0400 schrieb Joshua Branson:
> 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.
Yes, I've made it a bit more generic, so that you could also add let's
say (auto-login-to-tty "4" "nsa-backdoor") if you wanted ;)

You need a single-argument procedure in the config => proc part.  So
you generate a closure to do everything else.  You could do the same
with let-bindings inside the scope of modify-services, but I found it
more useful to extract that.

> > > #+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!
Haha, yes, guixy records are a charm, but they're subject to quicker
iteration than guile's.

> > > (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?
Did I make a mistake or does it do the job only in a somewhat inelegant
way?  I'm perfectly fine with the latter as I'm not the one using the
code :P
I think the cookbook is a better destination for stuff like this.

Regards,
Leo





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#48974: A possible shepherd bug (it's very minor)
  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
  0 siblings, 1 reply; 14+ messages in thread
From: Joshua Branson via Bug reports for GNU Guix @ 2021-07-02 22:57 UTC (permalink / raw)
  To: Leo Prikler; +Cc: 48974

Leo Prikler <leo.prikler@student.tugraz.at> writes:

> Am Freitag, den 25.06.2021, 14:06 -0400 schrieb Joshua Branson:
>> 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:
>>
>> 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?
> Did I make a mistake or does it do the job only in a somewhat inelegant
> way?  I'm perfectly fine with the latter as I'm not the one using the
> code :P

I've got some code now that works!

#+BEGIN_SRC scheme
(define (auto-login-to-tty tty user config)
  (if (string=? tty (mingetty-configuration-tty config))
        (mingetty-configuration
         (inherit config)
         (auto-login user))
        (mingetty-configuration
         (inherit config))))

;; allegedly %desktop-services now contains network-manager-applet...?  Can I remove that?
(define %my-desktop-services
  (modify-services %desktop-services ;;end of remove services
    (mingetty-service-type config =>
                           (auto-login-to-tty "3" "joshua" config))))

#+END_SRC

> I think the cookbook is a better destination for stuff like this.

I agree, but we should also probably fix the manual:

10.1 Using the Configuration System
===================================

System Services

   For example, suppose you want to modify ‘guix-daemon’ and Mingetty
(the console log-in) in the ‘%base-services’ list (*note
‘%base-services’: Base Services.).  To do that, you can write the
following in your operating system declaration:


     (define %my-services
       ;; My very own list of services.
       (modify-services %base-services
         (guix-service-type config =>
                            (guix-configuration
                             (inherit config)
                             ;; Fetch substitutes from example.org.
                             (substitute-urls
                               (list "https://example.org/guix"
                                     "https://ci.guix.gnu.org"))))
            ;; it looks like the manual is telling you to set up
            ;; auto login on ALL ttys.
         (mingetty-service-type config =>
                                (mingetty-configuration
                                 (inherit config)
                                 ;; Automatially log in as "guest".
                                 (auto-login "guest")))))

     (operating-system
       ;; ...
       (services %my-services))

How about I delete that section in the manual about automatic login and
instead add this to the cookbook?

Section Title:  Setting up automatic login for one tty 

The interested hacker, who wishes to set up automatic login to tty three
can use the following code snippet:

#+BEGIN_SRC scheme
(define (auto-login-to-tty tty user config)
  (if (string=? tty (mingetty-configuration-tty config))
        (mingetty-configuration
         (inherit config)
         (auto-login user))
        (mingetty-configuration
         (inherit config))))

(operating-system
  (host-name "dobby")
  ...
  (services
    (cons*
      (modify-services %base-services
        (mingetty-service-type config =>
                               (auto-login-to-tty "3" "joshua" config))))
#+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




^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#48974: A possible shepherd bug (it's very minor)
  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
  0 siblings, 2 replies; 14+ messages in thread
From: Leo Prikler @ 2021-07-03  6:41 UTC (permalink / raw)
  To: Joshua Branson; +Cc: 48974

Hi,

Am Freitag, den 02.07.2021, 18:57 -0400 schrieb Joshua Branson:
> Leo Prikler <leo.prikler@student.tugraz.at> writes:
> 
> > Am Freitag, den 25.06.2021, 14:06 -0400 schrieb Joshua Branson:
> > > 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:
> > > 
> > > 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?
> > Did I make a mistake or does it do the job only in a somewhat
> > inelegant
> > way?  I'm perfectly fine with the latter as I'm not the one using
> > the
> > code :P
> 
> I've got some code now that works!
> 
> #+BEGIN_SRC scheme
> (define (auto-login-to-tty tty user config)
>   (if (string=? tty (mingetty-configuration-tty config))
>         (mingetty-configuration
>          (inherit config)
>          (auto-login user))
Why do you need to inherit the config, when it doesn't change?  Seems
like a pointless allocation to me.
>         (mingetty-configuration
>          (inherit config))))
> 
> ;; allegedly %desktop-services now contains network-manager-
> applet...?  Can I remove that?
Not with modify-services, but there's some filter example in the manual
as well.
> (define %my-desktop-services
>   (modify-services %desktop-services ;;end of remove services
>     (mingetty-service-type config =>
>                            (auto-login-to-tty "3" "joshua" config))))
> 
> #+END_SRC
> 
> > I think the cookbook is a better destination for stuff like this.
> 
> I agree, but we should also probably fix the manual:
> 
> 10.1 Using the Configuration System
> ===================================
> 
> System Services
> 
>    For example, suppose you want to modify ‘guix-daemon’ and Mingetty
> (the console log-in) in the ‘%base-services’ list (*note
> ‘%base-services’: Base Services.).  To do that, you can write the
> following in your operating system declaration:
> 
> 
>      (define %my-services
>        ;; My very own list of services.
>        (modify-services %base-services
>          (guix-service-type config =>
>                             (guix-configuration
>                              (inherit config)
>                              ;; Fetch substitutes from example.org.
>                              (substitute-urls
>                                (list "https://example.org/guix"
>                                      "https://ci.guix.gnu.org"))))
>             ;; it looks like the manual is telling you to set up
>             ;; auto login on ALL ttys.
>          (mingetty-service-type config =>
>                                 (mingetty-configuration
>                                  (inherit config)
>                                  ;; Automatially log in as "guest".
>                                  (auto-login "guest")))))
> 
>      (operating-system
>        ;; ...
>        (services %my-services))
> 
> How about I delete that section in the manual about automatic login
> and
> instead add this to the cookbook?
No.  Read on, the manual clearly states that this affects *all* TTYs. 
Presumably the guest user only has access to su and logout, maybe guix,
but in any case they ought not to have access to anyone's $HOME, not
even their own.

The thing we've coded up here is a more involved process to solve a
particular problem rather than a general demo of what services can do
and thus belongs to the cookbook.

Regards,
Leo





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#48974: A possible shepherd bug (it's very minor)
  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
  1 sibling, 0 replies; 14+ messages in thread
From: pelzflorian (Florian Pelz) @ 2021-07-03  7:37 UTC (permalink / raw)
  To: Leo Prikler; +Cc: 48974, Joshua Branson

Hi,

On Sat, Jul 03, 2021 at 08:41:08AM +0200, Leo Prikler wrote:
> Am Freitag, den 02.07.2021, 18:57 -0400 schrieb Joshua Branson:
> > ;; allegedly %desktop-services now contains network-manager-
> > applet...?  Can I remove that?
> Not with modify-services, but there's some filter example in the manual
> as well.

There is now a delete in modify-services by Ricardo as a247f5c.

The manual has an example:

(modify-services %desktop-services
  (delete avahi-service-type))

Regards,
Florian Pelz




^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#48974: A possible shepherd bug (it's very minor)
  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
  1 sibling, 0 replies; 14+ messages in thread
From: Joshua Branson via Bug reports for GNU Guix @ 2021-07-05 23:59 UTC (permalink / raw)
  To: 48974-done

Leo Prikler <leo.prikler@student.tugraz.at> writes:

> Hi,
>
> Am Freitag, den 02.07.2021, 18:57 -0400 schrieb Joshua Branson:
>> Leo Prikler <leo.prikler@student.tugraz.at> writes:
>> 
>> > Am Freitag, den 25.06.2021, 14:06 -0400 schrieb Joshua Branson:
>> > > 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:
>> > > 
>> > > 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?
>> > Did I make a mistake or does it do the job only in a somewhat
>> > inelegant
>> > way?  I'm perfectly fine with the latter as I'm not the one using
>> > the
>> > code :P
>> 
>> I've got some code now that works!
>> 
>> #+BEGIN_SRC scheme
>> (define (auto-login-to-tty tty user config)
>>   (if (string=? tty (mingetty-configuration-tty config))
>>         (mingetty-configuration
>>          (inherit config)
>>          (auto-login user))
> Why do you need to inherit the config, when it doesn't change?  Seems
> like a pointless allocation to me.
>>         (mingetty-configuration
>>          (inherit config))))
>> 
>> ;; allegedly %desktop-services now contains network-manager-
>> applet...?  Can I remove that?
> Not with modify-services, but there's some filter example in the manual
> as well.
>> (define %my-desktop-services
>>   (modify-services %desktop-services ;;end of remove services
>>     (mingetty-service-type config =>
>>                            (auto-login-to-tty "3" "joshua" config))))
>> 
>> #+END_SRC
>> 
>> > I think the cookbook is a better destination for stuff like this.
>> 
>> I agree, but we should also probably fix the manual:
>> 
>> 10.1 Using the Configuration System
>> ===================================
>> 
>> System Services
>> 
>>    For example, suppose you want to modify ‘guix-daemon’ and Mingetty
>> (the console log-in) in the ‘%base-services’ list (*note
>> ‘%base-services’: Base Services.).  To do that, you can write the
>> following in your operating system declaration:
>> 
>> 
>>      (define %my-services
>>        ;; My very own list of services.
>>        (modify-services %base-services
>>          (guix-service-type config =>
>>                             (guix-configuration
>>                              (inherit config)
>>                              ;; Fetch substitutes from example.org.
>>                              (substitute-urls
>>                                (list "https://example.org/guix"
>>                                      "https://ci.guix.gnu.org"))))
>>             ;; it looks like the manual is telling you to set up
>>             ;; auto login on ALL ttys.
>>          (mingetty-service-type config =>
>>                                 (mingetty-configuration
>>                                  (inherit config)
>>                                  ;; Automatially log in as "guest".
>>                                  (auto-login "guest")))))
>> 
>>      (operating-system
>>        ;; ...
>>        (services %my-services))
>> 
>> How about I delete that section in the manual about automatic login
>> and
>> instead add this to the cookbook?
> No.  Read on, the manual clearly states that this affects *all* TTYs. 
> Presumably the guest user only has access to su and logout, maybe guix,
> but in any case they ought not to have access to anyone's $HOME, not
> even their own.
>
> The thing we've coded up here is a more involved process to solve a
> particular problem rather than a general demo of what services can do
> and thus belongs to the cookbook.
>
> 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
  




^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-07-06  0:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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