gmodena / nix-flatpak

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

`services.flatpak.uninstallUnmanaged` has invalid default value #61

Closed eclairevoyant closed 5 months ago

eclairevoyant commented 5 months ago

Tested with nixos-rebuild build --flake . with the following:

flake.nix ```nix # flake.nix { inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; flatpak.url = "github:gmodena/nix-flatpak"; }; outputs = { self, nixpkgs, flatpak, }: { nixosConfigurations.test = nixpkgs.lib.nixosSystem { modules = [ ( { modulesPath, pkgs, ... }: { imports = [ "${modulesPath}/profiles/minimal.nix" flatpak.nixosModules.nix-flatpak ]; boot.loader.grub.enable = false; fileSystems."/".device = "nodev"; nixpkgs.hostPlatform = "x86_64-linux"; system.stateVersion = "24.05"; services.flatpak.enable = true; xdg.portal = { enable = true; extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; config.common.default = [ "gtk" ]; }; } ) ]; }; }; } ```

Which produces the following error:

error:
       … while calling the 'head' builtin
         at /nix/store/cb1gs888vfqxawvc65q1dk6jzbayh3wz-source/lib/attrsets.nix:1541:11:
         1540|         || pred here (elemAt values 1) (head values) then
         1541|           head values
             |           ^
         1542|         else

       … while evaluating the attribute 'value'
         at /nix/store/cb1gs888vfqxawvc65q1dk6jzbayh3wz-source/lib/modules.nix:809:9:
          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: expected a Boolean but found null: null
       at /nix/store/9h5mvnz9wn5q3bf55q6r4iyvmdsvdw4g-source/modules/options.nix:177:66:
          176|     type = with types; bool;
          177|     default = config.services.flatpak.uninstallUnmanagedPackages || false;
             |                                                                  ^
          178|     description = lib.mdDoc ''

This is because the default value of the option services.flatpak.uninstallUnmanagedPackages is null, but null || false is not a valid expression in nix.

Even if null || false was valid, the option services.flatpak.uninstallUnmanaged is type bool (not nullOr bool) so this option couldn't take null anyway.

gmodena commented 5 months ago

Hey @eclairevoyant ,

I did an oepsie with integration tests and this bug slipped in. Hotfix incoming.

A workarond for this would be to explicitly set services.flatpak.uninstallUnmanagedPackages = false in your config.