Subject: [bug#73465] Wireguard: Rename field private-key to private-key-file

From: Apoorv Singh <[email-masked]>
Date: Sat, 28 Sep 2024 10:59:26 +0530

Do you want me to keep both private-key and private-key-file in 
the record but still use private-key for now? but just warn about 
deprecation for the field? Something like,

```
(define-record-type* <wireguard-configuration>
  wireguard-configuration make-wireguard-configuration
  wireguard-configuration?

  ;; other fields here..

  (private-key        wireguard-configuration-private-key-file 
  ;deprecated
                      (default "/etc/wireguard/private.key"))
  (private-key-file   wireguard-configuration-private-key-file 
  ;string
                      (default "/etc/wireguard/private.key"))
```

then, in the `wireguard-configuration-file` procedure, under 
`match-record`, I should do something like,
```
  (match-record config <wireguard-configuration>
    (wireguard interface addresses port private-key peers dns   ;; 
    keeping private-key field here..
               pre-up post-up pre-down post-down table)
    (let* ((config-file (string-append interface ".conf"))
           (peer-keys (fold peers->preshared-keys (list) peers))
           (peers (map peer->config peers))
           (config
            (computed-file
             "wireguard-config"
             #~(begin
                 (use-modules (ice-9 format)
                              (srfi srfi-1))

                 (define lines
                   (list
                     ;; other stuff..

                    (when (not (string-null? #$private-key))
                      (warn-about-deprecation 'private-key
                                              #f
                                              #:replacement 
                                              'private-key-file))

                    (format #f "PostUp = ~a set %i private-key ~a\
~{ peer ~a preshared-key ~a~}" #$(file-append wireguard "/bin/wg")
#$private-key '#$peer-keys)     ;; using private-key field here 
 still..

Sorry I'm not familiar with how all this works. Just making sure 
before I commit any changes.

Also by adjust the documentation you mean edit the 
doc/guix.texi:34373 file and append something like,
```
@item @code{private-key} (default: 
@code{"/etc/wireguard/private.key"})
The private key file for the interface.  It is automatically 
generated
if the file does not exist.  'Using private-key' is deprecated use 
'private-key-file' instead.
```

-- 
- Apoorv Singh
- Sent from Emacs.