Subject: bug#61717: guix home reconfigure on a fresh system fails

From: Andrew Tropin <[email-masked]>
Date: Fri, 24 Feb 2023 17:01:38 +0400

On 2023-02-22 16:40, [email-masked] wrote:

> Hi,
>
> I'm trying to setup a Guix machine. I did clean install using guix system init,
> I can provide the config, but it does not seem to be relevant. After that I
> decided to try the guix home reconfigure command, and it ended with:
>
>     guix home: error: while creating directory `/var/guix/profiles/per-user/wolf': Permission denied
>     hint: Please create the `/var/guix/profiles/per-user/wolf' directory, with you as the owner.
>
> The workaround I used was to just install any random package:
>
>     guix install coreutils
>     guix remove coreutils
>
> After that running
>
>     guix home reconfigure config.scm
>
> started to work just fine. However that does not seem like proper way, but more
> like a workaround. I was adviced on IRC to report it, so here I am.
>
> W.

This happens because of this call, which can't create a directory in
root owned /var/guix/profiles:
https://git.savannah.gnu.org/cgit/guix.git/tree/guix/scripts/home.scm?h=2c757e8fb4385f889ec91f02b77acdf27143c316#n476

1. Actually, this call is usually unecessary as the creation of directory
for per-user profiles handled by daemon.
https://git.savannah.gnu.org/cgit/guix.git/tree/nix/libstore/local-store.cc?h=2c757e8fb4385f889ec91f02b77acdf27143c316#n1613
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=37744

2. However, in some circumstances (when used custom $GUIX_STATE_DIRECTORY)
daemon doesn't handle this properly, so probably because of it this line
was added:
https://git.savannah.gnu.org/cgit/guix.git/commit/?id=0f6a27c2c4

I moved it to a place, where connection to store is already openned, so
it work in both scenarios (first one is covered by the daemon, second
one by this call).
https://git.savannah.gnu.org/cgit/guix.git/commit/?id=e615aaca28

Ideally, it would be cool to fix on the daemon side and remove this call
at all.

CCed Ludo, Tobias, Oleg.

-- 
Best regards,
Andrew Tropin