Trying to add `nix-flatpak` as a home-manager module. What am I doing wrong?

So, I was looking for a way to install Flatpaks declaratively on NixOS and I came across nix-flatpak.

All good, I added the nix-flatpak input to my NixOS flake, rebuilt and switched to the new generation, everything seemed fine.

Then, I wanted to add the input to my home-manager flake too, since I will want some Flatpaks installed system-wide, and some only for specific users. Followed the instructions as best as I could, since the examples show importing the module inside a NixOS HM module, but I use HM standalone, and I ran into this error.

$ home-manager -v switch --flake ~/.config/home-manager/#andy3153

error:
       … while updating the lock file of flake 'path:/home/andy3153/.config/home-manager?lastModified=1710550103&narHash=sha256-k7/smjAUtDKPYjwQYQ4l2AlW2Tdth/2F0LOlFyGvdHk%3D'

       … while updating the flake input 'nix-flatpak'

       … while fetching the input 'github:gmodena/nix-flatpak/v0.3.0'

       error: failed to extract archive (Could not open /tmp/nix-10224-0/nix-flatpak-a243cb0522f6240c194b873dde68e25370b06034)

This is my home-manager flake.

What have I done wrong?

I think it was just a temporary network error on your side?

lelgenio in ~/n/h/a/.c/home-manager on ~?2552a71
$ home-manager -v build --flake .#andy3153 && echo "It's ok :)"
It's ok :)

lelgenio in ~/n/h/a/.c/home-manager on ~?2552a71
$ git status
HEAD detached at 2552a71
Changes not staged for commit:
	modified:   flake.lock
1 Like

The formatting of your nix files hurts my eyes so much !

Anyway, hope you’ll find a solution.

2 Likes

I have no idea why, but still even after a reboot (and even another day), it wouldn’t run. But I attempted to run it like you with the build flag, then I had the bright idea of running it with the switch flag again and it seems to work? It didn’t give any (related) errors.

$ ~/sdf/ > home-manager build --flake ~/.config/home-manager/#andy3153

warning: updating lock file '/home/andy3153/.config/home-manager/flake.lock':
• Added input 'nix-flatpak':
    'github:gmodena/nix-flatpak/a243cb0522f6240c194b873dde68e25370b06034' (2024-02-18)
trace: warning: You have enabled hyprland.systemd.enable or listed plugins in hyprland.plugins but do not have any configuration in hyprland.settings or hyprland.extraConfig. This is almost certainly a mistake.
trace: warning: You have enabled hyprland.systemd.enable or listed plugins in hyprland.plugins but do not have any configuration in hyprland.settings or hyprland.extraConfig. This is almost certainly a mistake.


$ ~/ > home-manager switch --flake ~/.config/home-manager/#andy3153

Starting Home Manager activation
Activating checkFilesChanged
Activating checkLinkTargets
Activating writeBoundary
Activating linkGeneration
Cleaning up orphan links from /home/andy3153
No change so reusing latest profile generation 5
Creating home file links in /home/andy3153
Activating createXdgUserDirectories
Activating installPackages
replacing old 'home-manager-path'
installing 'home-manager-path'
Activating dconfSettings

(/nix/store/f7zgfsgam3pdny3h1yxrxr36682sxmbv-dconf-0.40.0/bin/dconf:13188): dconf-CRITICAL **: 15:17:29.867: unable to create directory '/run/user/0/dconf': Permission denied.  dconf will not work properly.
error: Could not connect: Permission denied

I have no idea what caused it to not work, but, scarier, I have no idea what caused it to work.

What about it? I am a newbie. Is it that I use

1 =
{
  2 = 
  {
    sdf = true;

    3 =
    {
      foo = "bar";
    };
  };
};

instead of

1.2.sdf   = true;
1.2.3.foo = "bar";

?

I think its more that your opening curly braces are on new lines. This is not common in most other programming languages

This would probably be a more common way to format the example you provided:

{
  1 = {
    2 = {
      sdf = true;
  
      3 = {
        foo = "bar";
      };
    };
  };
}

Also checkout nixpkgs-fmt or alejandra for nix formatters/linters like prettier (js ecosystem) or gofmt or whatever you’re familiar with

2 Likes