gmodena / nix-flatpak

Install flatpaks declaratively
Apache License 2.0
276 stars 10 forks source link

flatpak-managed-install.service fails to start properly when update.onactivation set to true (v0.2.0) #30

Closed 8bitbuddhist closed 6 months ago

8bitbuddhist commented 7 months ago

When starting up my laptop, I get an error that flatpak-managed-install.service fails to start. When I pull up the service logs, it says it couldn't reach dl.flathub.org. My first guess is that it was trying to start before the network was active (I'm on a laptop with Wi-Fi), but the same thing happened in a virtual machine. Restarting the service using systemctl fixes the issue.

My config:

inputs = {
    nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=v0.2.0";
}

...

services.flatpak = {
        enable = true;

        # Enable automatic updates
        update = {
            onActivation = true;

            # Check for updates daily
            auto = {
                enable = true;
                onCalendar = "daily";
            };
        };

        # Add remote(s)
        remotes = [
            { name = "flathub"; location = "https://dl.flathub.org/repo/flathub.flatpakrepo"; }
            { name = "kdeapps"; location = "https://distribute.kde.org/kdeapps.flatpakrepo"; }
        ];

        # Install Flatpaks. For details, see https://github.com/gmodena/nix-flatpak
        packages = [ ...];
        };
};

systemd logs:

➜  nix-configuration git:(main) ✗ systemctl status flatpak-managed-install.service
× flatpak-managed-install.service
     Loaded: loaded (/etc/systemd/system/flatpak-managed-install.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Wed 2024-01-31 19:03:10 EST; 14min ago
TriggeredBy: ● flatpak-managed-install.timer
    Process: 1035 ExecStart=/nix/store/5ha0n1hqf2ialvy84k8hx52aavmv4gl2-flatpak-managed-install (code=exited, status=1/FAILURE)
   Main PID: 1035 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 25ms

Jan 31 19:03:10 legion systemd[1]: Starting flatpak-managed-install.service...
Jan 31 19:03:10 legion 5ha0n1hqf2ialvy84k8hx52aavmv4gl2-flatpak-managed-install[1044]: error: Can't load uri https://dl.flathub.org/repo/flathub.flatpakrepo: While fetching https://dl.flathub.org/>
Jan 31 19:03:10 legion systemd[1]: flatpak-managed-install.service: Main process exited, code=exited, status=1/FAILURE
Jan 31 19:03:10 legion systemd[1]: flatpak-managed-install.service: Failed with result 'exit-code'.
Jan 31 19:03:10 legion systemd[1]: Failed to start flatpak-managed-install.service.
gmodena commented 7 months ago

Hey @8bitbuddhist,

Are you tracking main or a release?

8bitbuddhist commented 7 months ago

Hey @8bitbuddhist,

Are you tracking main or a release?

I'm using v0.2.0

8bitbuddhist commented 7 months ago

I just tried booting a build without onActivation and the service started up just fine. And I have daily updates configured anyway, so it's not like this is a major issue for me. Thanks for your work on this!

ReedClanton commented 7 months ago

I'm also seeing this issue.

ReedClanton commented 7 months ago

I did some more testing, and I get the bellow when I have nothing in services.flatpak.update... set:

[FAILED] Failed to start flatpak-managed-install.service.
See `systemctl status flatpak-managed-install.service` for details.

but when I have anything set in services.flatpak.update... then I also get:

[FAILED] Failed to start Home Manager environment for reedclanton.
See `systemctl status home-manager-reedclanton.service` for details.
gmodena commented 7 months ago

I was able to replicate on a nixos 23.11 vm. Working on a fix.

gmodena commented 7 months ago

Hey @8bitbuddhist @ReedClanton. I think the issue was an incorrect dependency on systemd unit boot order. I required the flatpak-managed-install to start after network.target was reached, but that alone does not guarantee that connectivity has been established.

There a tentative fix in the linked PR (#37). Tagged as WIP since I'd like to do a bit more testing.

ReedClanton commented 7 months ago

@gmodena Stupid question, how would I test this in my setup? What URL would I change inputs.nix-flatpak.url to in my flake.nix?

ReedClanton commented 7 months ago

@gmodena Stupid question, how would I test this in my setup? What URL would I change inputs.nix-flatpak.url to in my flake.nix?

nvm, figured it out. I used inputs.nix-flatpak.url = "hithub:gnodena/nix-flatpak/fix-boot-activation";

ReedClanton commented 7 months ago

@gmodena & @8bitbuddhist No more failures during boot! Seems like it fixed it. Also, pretty sure that getting ride of those failures decrease my boot time!

gmodena commented 7 months ago

thanks for testing the patch @ReedClanton !