Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility with stand-alone home-manager #10

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

tmarkov
Copy link

@tmarkov tmarkov commented Nov 10, 2023

osConfig is not always available for homeManager modules - in particular, for standalone installations. This adds a default value for osConfig, and a home-manager-only option services.flatpak.enable whose default is inherited from osConfig. If osConfig is not available, the default is false.

Honestly I'm not sure if the best practice wouldn't be to just remove the reference to osConfig, but that would be a breaking change.

@gmodena gmodena self-requested a review November 12, 2023 12:46
@gmodena
Copy link
Owner

gmodena commented Nov 12, 2023

Hey @tmarkov, thanks for this.

The module does not support standalone home-manager by design, since I don't have a decent test environment for that set up yet.

I'd love to support standalone home-manager though, so thanks a lot for starting this work.

I tried to deploy this change as a drop-in replacement on my test NixOs host, and nix flake check failed with:

error: A definition for option `home-manager.users.gmodena.services.flatpak.enable' is not of type `boolean'

Which might have more to do with my imports chain than your change, but I need to troubleshoot this regression before merging.

Could you maybe share some examples on how your setup? I'd like to understand:

  • What is your base OS?
  • How are importing and enabling nix-flatpak?
  • How was flatpak installed on your system?

@tmarkov
Copy link
Author

tmarkov commented Nov 12, 2023

I had a bug there that most probably caused your issue. Can you try again now?

As for the details of my system:

  • NixOS Unstable
  • flatpak installed system-wide (services.flatpak.enable = true)
  • but home-manager is standalone.

I use a flake with the following:

{
  inputs = {
    unstable.url = "github:nixos/nixpkgs/nixos-unstable";
    hm-unstable = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "unstable";
    };
    ...
    nix-flatpak.url = "github:tmarkov/nix-flatpak/main";
  };
  outputs = inputs@{unstable, hm-unstable, ... }:{
    ...
    homeConfigurations = {
      "todor@todor-laptop" = hm-unstable.lib.homeManagerConfiguration {
        pkgs = import unstable {
          inherit system;
          config.allowUnfree = true;
        };
        extraSpecialArgs = { inherit inputs; system = "x86_64-linux"; };
        modules = [
          ./todor
        ];
      };
    };
  };
}

Then I have in my home.nix:

# home.nix
{ config, pkgs, ... }:
{
  inpotrs = [
    ...
    ./flatpak.nix
  ]
  ...
}

and flatpak.nix then contains

{ inputs, ... }:
{
  imports = [ inputs.nix-flatpak.homeManagerModules.nix-flatpak ];
  services.flatpak = {
    enable = true;
    update.auto.enable = true;
    packages = [
      "com.valvesoftware.Steam"
      "com.viber.Viber"
    ];
  };
}

Copy link
Owner

@gmodena gmodena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left a small nit.

I did a quick test and there's no obvious regression.

I'll need to run a couple more integration tests, but should be good to merge.

modules/home-manager.nix Show resolved Hide resolved
@gmodena
Copy link
Owner

gmodena commented Nov 12, 2023

@tmarkov thanks for the f/up and the examples!

@gmodena gmodena merged commit 39ce271 into gmodena:main Nov 13, 2023
1 check passed
@gmodena gmodena mentioned this pull request Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants