unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Issue with local-file
@ 2025-01-05  4:26 jankremser via
  2025-01-05  4:35 ` jankremser via
  0 siblings, 1 reply; 2+ messages in thread
From: jankremser via @ 2025-01-05  4:26 UTC (permalink / raw)
  To: help-guix@gnu.org

Hello everyone. I am trying yo reference some local files in my guix configuartion, but I am running into some isses. Bellow I will past my configuration and the error I see when I run the build command. The code:
;;; base.scm --- Base Guix config inheriting from the official installer
;;;
;;; Defines a module named (machines base). It exports the variable
;;; `base-os`, which is an operating-system record built on top of
;;; `installation-os`. We allow SSH (with pubkey) on root, and run DHCP for
;;; networking.

(define-module (machines base)
;; Import modules providing 'operating-system', 'installation-os', etc.
#:use-module (gnu system install) ; for installation-os
#:use-module (gnu system file-systems) ; for installation-os
#:use-module (gnu system) ; for operating-system, %base-user-accounts
#:use-module (gnu system accounts) ; for operating-system, %base-user-accounts
#:use-module (gnu services) ; base services
#:use-module (gnu services ssh)
#:use-module (gnu services networking) ; for dhcp-client-service-type
#:use-module (guix gexp) ; for installation-os
#:export (base-os))

(define %base-dir
;; The directory where *this* file (base.scm) lives.
(dirname (current-filename)))

;; 1) Define a base OS that *inherits* 'installation-os' (the default Guix
;; live installer environment).
;; 2) Override the 'services' field to provide:
;; - a DHCP client (instead of 'networking-service-type')
;; - an SSH service that allows root login via pubkey only
;; 3) Override the 'users' field so 'root' has a public key.

(define base-os
(operating-system
(inherit installation-os)

;; Basic identity
(host-name "base-installer")
(timezone "UTC")
(locale "en_US.utf8")

(file-system
(device (local-file "./keys/install-key")) ; Danger: private key in store
(mount-point "/root/.ssh/id_rsa")
(type "none")
(flags '(bind-mount)))

;; (file-systems
;; (append
;; (list
;; (file-system
;; (mount-point "/root/.ssh/authorized_keys")
;; (device (local-file "./keys/install-key.pub"))
;; (type "none")
;; (flags '(bind-mount))))
;; (operating-system-file-systems installation-os)))

;; The 'services' field: we append a DHCP service & a custom SSH config
(services
(append
(list
;; Networking: use a DHCP client on all interfaces
(service dhcp-client-service-type
(dhcp-client-configuration
(interfaces '("eno1")))) ; or '("eno1") for a specific interface

;; SSH service: root login by key only
(service openssh-service-type
(openssh-configuration
(permit-root-login 'without-password) ; No password logins
(password-authentication? #false)))
;; (authorized-keys
;; `(("root" ,(local-file "./keys/install-key.pub")))))) ; disable password-based auth

;; Keep everything else from the standard Guix installation-os
(operating-system-services installation-os))))))

;; Finally, just reference 'base-os' at the top level so Guix sees it as
;; the OS to build or reconfigure.
base-os
======== The terminal interaction =========================
[jan@bunker:/dna/@repo/installation-isos-guix]$ ls
machines manifest.scm manifest.scm~

[jan@bunker:/dna/@repo/installation-isos-guix]$ ls machines/
base.scm base.scm~ common.scm~ keys

[jan@bunker:/dna/@repo/installation-isos-guix]$ ls machines/keys/
install-key install-key.pub

[jan@bunker:/dna/@repo/installation-isos-guix]$ ~/.config/guix/current/bin/guix system image -t iso9660 -L . machines/base.scm
machines/base.scm:41:4: error: (file-system (device (local-file "./keys/install-key")) (mount-point "/root/.ssh/id_rsa") (type "none") (flags (quote (bind-mount)))): invalid field specifier
[jan@bunker:/dna/@repo/installation-isos-guix]$

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

* Re: Issue with local-file
  2025-01-05  4:26 Issue with local-file jankremser via
@ 2025-01-05  4:35 ` jankremser via
  0 siblings, 0 replies; 2+ messages in thread
From: jankremser via @ 2025-01-05  4:35 UTC (permalink / raw)
  To: help-guix@gnu.org

Apologies, the error before was a different one. Here is my updated configuration with the errors:
=============================+
;;; base.scm --- Base Guix config inheriting from the official installer
;;;
;;; Defines a module named (machines base). It exports the variable
;;; `base-os`, which is an operating-system record built on top of
;;; `installation-os`. We allow SSH (with pubkey) on root, and run DHCP for
;;; networking.

(define-module (machines base)
;; Import modules providing 'operating-system', 'installation-os', etc.
#:use-module (gnu system install) ; for installation-os
#:use-module (gnu system file-systems) ; for installation-os
#:use-module (gnu system) ; for operating-system, %base-user-accounts
#:use-module (gnu system accounts) ; for operating-system, %base-user-accounts
#:use-module (gnu services) ; base services
#:use-module (gnu services ssh)
#:use-module (gnu services networking) ; for dhcp-client-service-type
#:use-module (guix gexp) ; for installation-os
#:export (base-os))

(define %base-dir
;; The directory where *this* file (base.scm) lives.
(dirname (current-filename)))

;; 1) Define a base OS that *inherits* 'installation-os' (the default Guix
;; live installer environment).
;; 2) Override the 'services' field to provide:
;; - a DHCP client (instead of 'networking-service-type')
;; - an SSH service that allows root login via pubkey only
;; 3) Override the 'users' field so 'root' has a public key.

(define base-os
(operating-system
(inherit installation-os)

;; Basic identity
(host-name "base-installer")
(timezone "UTC")
(locale "en_US.utf8")

(file-systems
(append
(list
(file-system
(device (local-file "./keys/install-key")) ; Danger: private key in store
(mount-point "/root/.ssh/id_rsa")
(type "none")
(flags '(bind-mount))))
(operating-system-file-systems installation-os)))

;; (file-systems
;; (append
;; (list
;; (file-system
;; (mount-point "/root/.ssh/authorized_keys")
;; (device (local-file "./keys/install-key.pub"))
;; (type "none")
;; (flags '(bind-mount))))
;; (operating-system-file-systems installation-os)))

;; The 'services' field: we append a DHCP service & a custom SSH config
(services
(append
(list
;; Networking: use a DHCP client on all interfaces
(service dhcp-client-service-type
(dhcp-client-configuration
(interfaces '("eno1")))) ; or '("eno1") for a specific interface

;; SSH service: root login by key only
(service openssh-service-type
(openssh-configuration
(permit-root-login 'without-password) ; No password logins
(password-authentication? #false))))
;; (authorized-keys
;; `(("root" ,(local-file "./keys/install-key.pub")))))) ; disable password-based auth

;; Keep everything else from the standard Guix installation-os
(operating-system-services installation-os)))))

;; Finally, just reference 'base-os' at the top level so Guix sees it as
;; the OS to build or reconfigure.
base-os==================================
[jan@bunker:/dna/@repo/installation-isos-guix]$ ls
machines manifest.scm manifest.scm~

[jan@bunker:/dna/@repo/installation-isos-guix]$ ls machines/
base.scm base.scm~ common.scm~ keys

[jan@bunker:/dna/@repo/installation-isos-guix]$ ls machines/keys/
install-key install-key.pub

[jan@bunker:/dna/@repo/installation-isos-guix]$ ~/.config/guix/current/bin/guix system image -t iso9660 -L . machines/base.scm
;;; compiling /gnu/store/zxlzyr0l4k26cajq9m3y82024d4sjlv9-guix-module-union/share/guile/site/3.0/gnu/system/examples/bare-bones.tmpl
;;; compiled /home/jan/.cache/guile/ccache/3.0-LE-8-4.6/gnu/store/nl33050xxqfyclxd4ap0c2rzawhx3syz-guix-system-source/gnu/system/examples/bare-bones.tmpl.go
Backtrace:
In guix/status.scm:
839:4 19 (call-with-status-report _ _)
In guix/scripts/system.scm:
1332:4 18 (_)
In ice-9/boot-9.scm:
1752:10 17 (with-exception-handler _ _ #:unwind? _ # _)
In guix/store.scm:
689:37 16 (thunk)
1330:8 15 (call-with-build-handler #<procedure 7f8a20754d50 at g…> …)
2210:25 14 (run-with-store #<store-connection 256.99 7f8a20706be0> …)
In guix/scripts/system.scm:
859:2 13 (_ _)
In guix/store.scm:
2038:13 12 (_ #<store-connection 256.99 7f8a20706be0>)
In guix/gexp.scm:
300:51 11 (_)
In unknown file:
10 (with-fluids* (#<fluid 7f8a36e29350>) (#f) #<procedure …>)
In guix/gexp.scm:
750:29 9 (_)
In gnu/system/image.scm:
1010:15 8 (_)
941:7 7 (operating-system-for-image _)
In gnu/system.scm:
1408:36 6 (operating-system-uuid #<<operating-system> kernel: #<…> …)
In srfi/srfi-1.scm:
586:29 5 (map1 (#<<file-system> device: "/dev/placeholder" mo…> …))
586:17 4 (map1 (#<<file-system> device: #<<local-file> file: …> …))
In gnu/system.scm:
1394:13 3 (file-system-digest #<<file-system> device: #<<local-fi…>)
In gnu/system/file-systems.scm:
268:2 2 (file-system-device->string _ #:uuid-type _)
In ice-9/boot-9.scm:
1685:16 1 (raise-exception _ #:continuable? _)
1685:16 0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `match-error' with args `("match" "no matching pattern" #<<local-file> file: "./keys/install-key" absolute: #<promise #<procedure 7f8a1f4f1700 at machines/base.scm:45:16 ()>> name: "install-key" recursive?: #f select?: #<procedure true (file stat)>>)'.
[jan@bunker:/dna/@repo/installation-isos-guix]$

On Sunday, January 5th, 2025 at 5:26 AM, jankremser <jankremser@proton.me> wrote:

> Hello everyone. I am trying yo reference some local files in my guix configuartion, but I am running into some isses. Bellow I will past my configuration and the error I see when I run the build command. The code:
> ;;; base.scm --- Base Guix config inheriting from the official installer
> ;;;
> ;;; Defines a module named (machines base). It exports the variable
> ;;; `base-os`, which is an operating-system record built on top of
> ;;; `installation-os`. We allow SSH (with pubkey) on root, and run DHCP for
> ;;; networking.
>
> (define-module (machines base)
> ;; Import modules providing 'operating-system', 'installation-os', etc.
> #:use-module (gnu system install) ; for installation-os
> #:use-module (gnu system file-systems) ; for installation-os
> #:use-module (gnu system) ; for operating-system, %base-user-accounts
> #:use-module (gnu system accounts) ; for operating-system, %base-user-accounts
> #:use-module (gnu services) ; base services
> #:use-module (gnu services ssh)
> #:use-module (gnu services networking) ; for dhcp-client-service-type
> #:use-module (guix gexp) ; for installation-os
> #:export (base-os))
>
> (define %base-dir
> ;; The directory where *this* file (base.scm) lives.
> (dirname (current-filename)))
>
> ;; 1) Define a base OS that *inherits* 'installation-os' (the default Guix
> ;; live installer environment).
> ;; 2) Override the 'services' field to provide:
> ;; - a DHCP client (instead of 'networking-service-type')
> ;; - an SSH service that allows root login via pubkey only
> ;; 3) Override the 'users' field so 'root' has a public key.
>
> (define base-os
> (operating-system
> (inherit installation-os)
>
> ;; Basic identity
> (host-name "base-installer")
> (timezone "UTC")
> (locale "en_US.utf8")
>
> (file-system
> (device (local-file "./keys/install-key")) ; Danger: private key in store
> (mount-point "/root/.ssh/id_rsa")
> (type "none")
> (flags '(bind-mount)))
>
> ;; (file-systems
> ;; (append
> ;; (list
> ;; (file-system
> ;; (mount-point "/root/.ssh/authorized_keys")
> ;; (device (local-file "./keys/install-key.pub"))
> ;; (type "none")
> ;; (flags '(bind-mount))))
> ;; (operating-system-file-systems installation-os)))
>
> ;; The 'services' field: we append a DHCP service & a custom SSH config
> (services
> (append
> (list
> ;; Networking: use a DHCP client on all interfaces
> (service dhcp-client-service-type
> (dhcp-client-configuration
> (interfaces '("eno1")))) ; or '("eno1") for a specific interface
>
> ;; SSH service: root login by key only
> (service openssh-service-type
> (openssh-configuration
> (permit-root-login 'without-password) ; No password logins
> (password-authentication? #false)))
> ;; (authorized-keys
> ;; `(("root" ,(local-file "./keys/install-key.pub")))))) ; disable password-based auth
>
> ;; Keep everything else from the standard Guix installation-os
> (operating-system-services installation-os))))))
>
> ;; Finally, just reference 'base-os' at the top level so Guix sees it as
> ;; the OS to build or reconfigure.
> base-os
> ======== The terminal interaction =========================
> [jan@bunker:/dna/@repo/installation-isos-guix]$ ls
> machines manifest.scm manifest.scm~
>
> [jan@bunker:/dna/@repo/installation-isos-guix]$ ls machines/
> base.scm base.scm~ common.scm~ keys
>
> [jan@bunker:/dna/@repo/installation-isos-guix]$ ls machines/keys/
> install-key install-key.pub
>
> [jan@bunker:/dna/@repo/installation-isos-guix]$ ~/.config/guix/current/bin/guix system image -t iso9660 -L . machines/base.scm
> machines/base.scm:41:4: error: (file-system (device (local-file "./keys/install-key")) (mount-point "/root/.ssh/id_rsa") (type "none") (flags (quote (bind-mount)))): invalid field specifier
> [jan@bunker:/dna/@repo/installation-isos-guix]$

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

end of thread, other threads:[~2025-01-05 16:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-05  4:26 Issue with local-file jankremser via
2025-01-05  4:35 ` jankremser via

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