Re: system reconfigure: rename-file: invalid cross-device link

2024-04-18 Thread Kenny Ballou

Connecting back to the list.

On 2024-04-18 21:19 -04, Connor Clark wrote:
> Hey all,
>
> I would like to say I'm having the same issue. My root filesystem is btrfs 
> with 
> a similar layout (subvolumes at /var, /home, etc), though I also have an ext4 
> raid array of three other disks mounted at /srv.
>
> The problem started happening when I bumped my channel commit to 
> 0f9f266542e611bee277b5e593072318942ed643, working fine on 
> 16d2be641424815a1779119bb64bc6ba1be1161b. If we need to troubleshoot this 
> further I can provide some logs.
>
> p.s. I'm not too familiar with mailing lists. If this goes straight to the 
> individual who started the thread, sorry and please let me know.


The issue seems to stem from [[https://issues.guix.gnu.org/70165][this
bug]] with DBus.  I was able to work around it with some finagling.  I
"copied" some of the DBus files and rebooted.  I have another Guix
system I'll need to try this with and I can report back with some more
concrete steps.  Unfortunately, I have some deadlines I need to hit and
cannot be breaking things at the moment.

An alternative approach I was not able to get to work because I can't
quite figure out how to get bind mounts to work in Guix (even with the
[[https://guix.gnu.org/en/cookbook/en/html_node/Setting-up-a-bind-mount.html][cookbook]]):
bind mount a TMPFS for the set of paths.  That is, create a TMPFS for
~/run~ and then bind mount it to ~/var/run~, or vise versa, if you
prefer.  To do this, you likely will need to rollback (downgrade) to the
working revision.  Configure the new mounts.  Reboot.  Upgrade to the
new revision (which has a new version of DBus). ... Profit!

Hope that helps.



-- 
-Kenny


system reconfigure: rename-file: invalid cross-device link

2024-04-11 Thread Kenny Ballou


Hello fellow Guix'ers,

I'm encountering a new error sometime after 
[[https://git.savannah.gnu.org/cgit/guix.git/commit/?id=28bc0e870b4d48b8e3e773382bb0e999df2e3611][28bc0e870b4d48b8]].

The elided output for the error:

#+begin_example
building /gnu/store/fmhhk62qagcg8jjfk6m2wzsnw8gyi6a0-switch-to-system.scm.drv...
making '/var/guix/profiles/system-79-link' the current system...
setting up setuid programs in '/run/setuid-programs'...
populating /etc from /gnu/store/jv2b1lgw3q2nhq6jl242c3vwh6s8szcj-etc...
guix system: error: rename-file: Invalid cross-device link
#+end_example

I have not had issues until trying to upgrade recently.  I don't believe my
configuration is all that exotic.  However, I do leverage several partitions
for each of the main mount points.  Namely, I have a 1GB root partition, with
additional partitions for ~/gnu~, ~/var~, ~/home~, etc.  The details can be 
seen in
my [[https://git.sr.ht/~kennyballou/dotfiles.git/][dotfiles]], specifically: 
[[https://git.sr.ht/~kennyballou/dotfiles.git/tree/master/item/systems/axo.scm][systems/axo.scm]].

Notice, this does not appear to affect home configurations, as I was able to
reconfigure/switch generations for my home configuration 
([[https://git.sr.ht/~kennyballou/dotfiles.git/tree/master/item/homes/axo.scm][homes/axo.scm]]).

I first noticed this issue in commit 
[[https://git.savannah.gnu.org/cgit/guix.git/commit/?id=4d994f98a49e1a6e58b9b0b512a05efc1c431a50][4d994f98a49e1a6e58b9b0b512a05efc1c431a50]].
I haven't tried to bisect to see if there's an immediate culprit due to time.
Before I do that, I'm reaching out to see if anyone here may know what is
happening.

Any help is greatly appreciated.

-- 
Kenny



Re: set environment variables with guix shell [-m manifest.scm]

2022-05-06 Thread Kenny Ballou

On 2022-05-05 11:05 +02, zimoun wrote:
> Wed, 04 May 2022 at 18:53, Kenny Ballou  wrote:
>
>> However, one necessary feature of `guix shell` I'm not seeing: ability
>> to set arbitrary environment variables when `guix shell` loads.
>
> Yes, it misses an equivalent to ’nix-shell’ «shellHook» [1], as also
> reported by [2] Well, maybe you could achieve something via ’--file’
> instead of ’--manifest’, I do not know.

I was not aware of [2], thanks for pointing me to it.

I have not tried `--file`.  My understanding is that this does not quite
do the same thing.

Unrelated to search paths below, I had an idea that it would be possible
to construct a derivation which sets the environment variables and add
the resulting derivation to the "manifest".  However, I suspect I'm
misunderstanding the `#:env-vars` key to the `gexp->derivation`[5]
function.

Along this idea though, how difficult would it be to add an optional
parameter to `*->manifest` functions such that it constructs the profile
with additional environment variables?  Is that desirable?

>
> Since you use Direnv [3], maybe you can set the environment variables
> there instead of in the manifest file.

While this would work in general, I'm trying to add things that directly
reference computed store paths.  I'm not sure how I can easily achieve
this with `direnv`.

For example, I'm trying to set `LD_LIBRARY_PATH` to point to the `lib`
directory of the `z3` package.  Furthermore, I need to set `JAVA_HOME`
to the store path of `openjdk11-jdk`.


> 1: <https://nixos.org/manual/nix/stable/command-ref/nix-shell.html>
> 2: 
> <https://yhetil.org/guix/e92751b5-f3ed-47a0-b7d2-40f9d3f5c...@univ-grenoble-alpes.fr>
> 3: <https://github.com/direnv/direnv/wiki/GNU-Guix>


I've had some success setting search paths[4], as here:

```
(define z3-with-java
  (package
   (inherit z3-4.8.10)
   (native-inputs
`(("which" ,which)
  ("python" ,python-wrapper)
  ("jdk" ,java:openjdk11 "jdk")))
   (arguments
`(#:tests? #f
  #:validate-runpath? #f
  #:phases
  (modify-phases %standard-phases
 (add-after 'unpack 'set-JDK_HOME
(lambda* (#:key inputs #:allow-other-keys)
  (setenv "JDK_HOME" (assoc-ref inputs "jdk"))
  #t))
 (replace 'configure
  (lambda* (#:key inputs outputs #:allow-other-keys)
(invoke "python" "scripts/mk_make.py"
"--java"
(string-append "--prefix=" (assoc-ref 
outputs "out")
 (add-after 'configure 'change-directory
(lambda _
  (chdir "build")
  #t)
   (native-search-paths
(list (search-path-specification
   (variable "LD_LIBRARY_PATH")
   (separator #f)
   (files (list "lib/")))
  (search-path-specification
   (variable "Z3_DIR")
   (separator #f)
   (files (list "")))
```

Unrelated to this whole thing, and likely in need of a new thread, how
do I translate the above package definition which overrides the inputs
to use the new gexp style[6]?

-Kenny

[4]: https://guix.gnu.org/en/manual/devel/en/guix.html#Search-Paths
[5]: 
https://guix.gnu.org/en/manual/devel/en/guix.html#index-gexp_002d_003ederivation
[6]: https://guix.gnu.org/en/blog/2021/the-big-change/


Re: set environment variables with guix shell [-m manifest.scm]

2022-05-04 Thread Kenny Ballou



> ```
> (let ((z3-dir (run-with-store (open-connection)
> (package-file z3-with-java
>   (setenv "LD_LIBRARY_PATH" (string-append z3-dir "/lib"))
>   (setenv "Z3_DIR" z3-dir))
> ...
> ```

Because I cannot sit well enough alone.  I have learned some more
things: it appears these `setenv` calls work if manually invoking `guix
shell`.  However, they do not work when using direnv to invoke `guix
shell`.  This may come down to _how_ direnv invokes `guix shell`.
Worse, if corrected, direnv may not be able to guarantee the `setenv`
variables are hermetic to the project since it seems to be completely
unaware of them (i.e., leaving the directory may not unset the
added environment variables).

Perhaps, this helps stir some insight?

-Kenny



auto-mount NFS file-systems

2022-05-04 Thread Kenny Ballou


Dear list,

I am attempting to auto mount some NFS shares on a Guix system, but
cannot seem to get it to boot past the NFS mounts.  On another system,
I'm able to have the NFS shares auto mount due to a dependency on the
encrypted root file system (mapped-devices).  However, the system where
this does not work has no mapped-devices.

Specifically, for the system that works, the relevant records look as follows:

```
...
(mapped-devices
(list (mapped-device
   (source (list "/dev/sda1" "/dev/sdb1"))
   (target "/dev/md1")
   (type raid-device-mapping))
  (mapped-device
   (source (uuid "4808204d-0116-4234-b931-6cc6161d5f3b"))
   (target "luks-4808204d-0116-4234-b931-6cc6161d5f3b")
   (type luks-device-mapping))
  (mapped-device
   (source (uuid "ddb3da26-ac44-4f4a-b01a-6b21967df63d"))
   (target "luks-ddb3da26-ac44-4f4a-b01a-6b21967df63d")
   (type luks-device-mapping

(file-systems (append
   (list (file-system
  (device 
"/dev/mapper/luks-ddb3da26-ac44-4f4a-b01a-6b21967df63d")
  (mount-point "/")
  (type "ext4")
  (dependencies mapped-devices))
 (file-system
  (device 
"/dev/mapper/luks-4808204d-0116-4234-b931-6cc6161d5f3b")
  (mount-point "/home")
  (type "xfs")
  (dependencies mapped-devices))
 (file-system
  (mount-point "/media/kb/documents")
  (device "baal:/srv/documents")
  (type "nfs4")
  (mount-may-fail? #t)
  (mount? #t)
  (create-mount-point? #t)
  (options nfs-mount-options)
  (dependencies mapped-devices))
  ...)))

```

However, on the system that is not working:

```
;; (mapped-devices '())
(file-systems (append
(list (file-system
(device (uuid "5a0e26fe-8cc4-4ded-9bd9-9930228b6674"))
(mount-point "/")
(type "ext4"))
  (file-system
(device (uuid "B7E7-D5B6" 'fat))
(mount-point "/boot/efi")
(type "vfat"))
  (file-system
(mount-point "/media/kb/music")
(device "baal:/srv/music")
(type "nfs4")
(mount-may-fail? #t)
(mount? #t)
(create-mount-point? #t)
(options nfs-mount-options)
(dependencies '()))
...)))
```

Clearly, the NFS shares need a dependency, but it's not clear from the
documentation exactly what to put in the list in this case.  I've tried
copying, say the root entry wholesale, but get an error that the needed
file system is not provided by any service.

My gratitude in advance.

-Kenny

-- 
:SIG:!0xB0CAA28A02958308!:



set environment variables with guix shell [-m manifest.scm]

2022-05-04 Thread Kenny Ballou


Dear list,

I have been using nix-shell for a while now to have on-demand/ad-hoc
development environments for different projects.  These are hooked in
with direnv and the whole experience is quite nice.  However, I would
like to translate these to Guix because I find the tooling around Guix
and Scheme far better and easier.

However, one necessary feature of `guix shell` I'm not seeing: ability
to set arbitrary environment variables when `guix shell` loads.

Certainly, I thought I could just add some `(setenv "FOO" "bar")` in the
`manifest.scm` file.  But if the environment is reloaded, these
statements do not seem to persist.

For example, I've been working on a manifest for my current main
project, it has the following, elided for brevity, contents:

```
(define z3-with-java
  (package
(inherit z3)
...))

(let ((z3-dir (run-with-store (open-connection)
(package-file z3-with-java
  (setenv "LD_LIBRARY_PATH" (string-append z3-dir "/lib"))
  (setenv "Z3_DIR" z3-dir))

(packages->manifest
  (list openjdk11
...
z3-with-java))
```

Perhaps, this is not the right way to do this?  Is there a different
mechanism I am not aware of?  Would this be a good extension to `guix
shell` manifests?

This would not be an issue if I did not need the store path of the
package.  I could simply set the environment variables in the `.envrc`
file.  However, I still think it would be preferable to have a mechanism
for setting environment variables via `guix shell` similar to `nix
shell`.

Thoughts?

My gratitude in advance.

-Kenny

-- 
:SIG:!0xB0CAA28A02958308!:



Re: Guix and Emacs Integration for Polyglot Development

2018-09-10 Thread Kenny Ballou


On 2018-08-31 12:49 GMT, Maxim Cournoyer wrote:
> Hello!
>
> I'm reposting Janneke's recent answer here so that it can have all its
> context and participants.
>
> Jan Nieuwenhuizen  writes:
>
>> Hi!
>>
>> Just subscribed to help-guix because of a request on IRC, so hoping that
>> OP is subscribed here, or someone can notify them.
>>
>> I have an ugly hack to switch emacs to a profile or environment.  It
>> parses the /etc/profile script...using MANIFEST or
>> `--search-paths' would be much nicer...
>>
>> Anyway, I'm using some named profiles, eg
>>
>> ~/.config/guix/mes
>>
>> and when starting work on mes i do
>>
>> M-x guix-switch-profile RET ~/.config/guix/mes RET
>>
>> similar for other projects I work on.
>>
>> A real solution would be nice...
>>
>> HTH, janneke
>>
>> --8<---cut here---start->8---
>>
>> (defun guix-switch-profile (&optional profile)
>>   "reset Emacs' environment by snarfing PROFILE/etc/profile"
>>
>>   (defun matches-in-string (regexp string)
>> "return a list of matches of REGEXP in STRING."
>> (let ((matches))
>>   (save-match-data
>> (string-match "^" "")
>> (while (string-match regexp string (match-end 0))
>>   (push (or (match-string 1 string) (match-string 0 string)) 
>> matches)))
>>   matches))
>>
>>   (interactive "fprofile: ")
>>   (let* ((output (shell-command-to-string (concat "GUIX_PROFILE= /bin/sh -x 
>> " profile "/etc/profile")))
>>  (exports (matches-in-string "^[+] export \\(.*\\)" output)))
>> (mapcar (lambda (line) (apply #'setenv (split-string line "="))) exports 
>> )))
>> --8<---cut here---end--->8---
>
> Thank you, Janneke!
>
> An alternative if you'd like to also define some variables (say,
> PYTHONPATH to add a couple of sources libraries while working on a
> Python project) would be to use `direnv'[0] and `emacs-direnv'.
>
> Christopher Baines detailed the solution in this thread:
> https://lists.gnu.org/archive/html/guix-devel/2017-05/msg00475.html.
>
> I hope this helps!
>
> Maxim


Thank you for posting this, I still haven't had a chance to play around
with this yet, but I think this is the kind of solution that is exactly
what I'm looking for.  However, Named profiles was sorta where I was
leaning.

I may not use the `emacs-direnv` part.  But I if I understand correctly,
switching profiles will change the `${HOME}/.guix-profile` symlink, I
can just statically add the current profile to any path variables and go
from there(?).

Again, thank you and apologies for the necrobump because of late
replies...

-Kenny



Re: Guix and Emacs Integration for Polyglot Development

2018-08-05 Thread Kenny Ballou


On 2018年08月02日 08:08 GMT, Chris Marusich wrote:
> Kenny Ballou  writes:
>
>> I would like to be able to specify a project's dependencies in a
>> manifest file, add any environment variables as necessary, and have
>> Emacs be aware of those variables when entering that environment.
>
> It may not be what you're looking for, but projects like Haunt [1] put a
> guix.scm file in the root directory of their project.  The file contains
> a package as its top-level form (I think that's the right terminology),
> and you can get the dependencies via "guix environment -l guix.scm".

When I mentioned the "manifest" file, I wasn't aware it was common to
refer to this file as `guix.scm`, but yes, this is definitely the first
part.  However, to clarify, my question is regarding the second part:
how to get the `guix.scm` and any environment variables loaded as part
of `guix environment -l guix.scm` or `guix environment -m
project_manifest.scm`-- search paths and similar -- integrated into the
buffers local to the project directory?  I believe `.dir-locals.el` or
similar might actually be the right approach here, but I'm still in the
early stages of exploring this.

I hope that clarifies my question better.  For more reference, I'm also
thinking of wingo's blog on developing v8 with guix[1] (though I believe
`guix environment` wasn't yet available).

Again, if this is the wrong list, I can move this question to emacs-help
instead.

-Kenny

[1]: https://wingolog.org/archives/2015/08/04/developing-v8-with-guix



Guix and Emacs Integration for Polyglot Development

2018-07-27 Thread Kenny Ballou


This may be the wrong list, but I figure most Guix users/developers are
_probably_ also Emacs users, I figured I would ask here first...

Obviously, there is the [[alezost/guix.el][guix.el]] for interacting
with Guix from within Emacs.  However, what sort of integration is
available for Emacs with the ~guix environment -m
~ command.  I would like to be able to
specify a project's dependencies in a manifest file, add any environment
variables as necessary, and have Emacs be aware of those variables when
entering that environment.  Tools like ~pyflake~ for Python projects, or
~go-fmt~ integration for a Golang project, would have their regular
integration with Emacs when in those environments.  All of this without
having to have some version of the tools installed in either the user
profile or the host OS (regardless if that's GuixSD or some other
foreign distribution), both of which would disallow usage of `--pure`
during development (not my ideal).  Furthermore, to me is it preferable
to only have one Emacs (server) session that is capable of switching
between projects and different ~guix environments~, as opposed to adding
Emacs to the development dependencies of a project and using several
different Emacs instances/sessions.

Understandably, this may be tricky for a number of reasons:

- Keeping many buffers/files that are in a different environments may
  causes issues when the environments switch, causing some buffers to
  lose connections or reference to the tools the buffer expects.

- Global(?) variables everywhere, unless this is easy to add to a buffer
  local or similar?

- (e)Shell or long running process integration and patching.  Similar
  problems for other inferior shells, e.g., ~python~, ~geiser~, ~ghc~,
  etc.

Perhaps a solution is to integrate with a "project" root
~.dir-locals.el~ file for each environment.  However, since I'm not well
versed in what is possible with such a file, I don't know if this is
viable.

Another solution would be to attempt to integrate with something like
~projectile~ for the variables, but this sounds similar to the previous
idea.  Moreover, this forces ~projectile~ onto users and that is perhaps
not appropriate.

Hopefully, what I have described makes sense.  I'm hoping to see what
other users are doing for this kind of setup.

Thanks in advance.

-Kenny

#+LINK: alezost/guix.el https://github.com/alezost/guix.el
#+LINK: bauer-nix-emacs: https://matthewbauer.us/blog/bauer.html