android-nixpkgs icon indicating copy to clipboard operation
android-nixpkgs copied to clipboard

Unable to use with home manager

Open doofy opened this issue 3 years ago • 9 comments

I am trying to follow example https://github.com/tadfisher/android-nixpkgs#home-manager and include this into my home.nix but I get the following error:

error: cannot coerce a set to a string
       at /home/doofy/.config/nixpkgs/home.nix:10:15:

            9|     in
           10|       import (android-nixpkgs + "/hm-module.nix");
             |               ^
           11|
(use '--show-trace' to show detailed location information)

Anyone willing to help me?

doofy avatar Dec 08 '21 11:12 doofy

Can you try it with this change?

{ config, pkgs, ... }:

let
  android-sdk =
    let
      android-nixpkgs = fetchTarball "https://github.com/tadfisher/android-nixpkgs/archive/main.tar.gz";
    in
      import (android-nixpkgs + "/hm-module.nix");

in
{
  imports = [ android-sdk ];

 #  ...
}

tadfisher avatar Dec 08 '21 18:12 tadfisher

I guess this got me one step further but:

I have:

{ config, pkgs, ... }:

let
  android-sdk =
    let
      android-nixpkgs = fetchTarball "https://github.com/tadfisher/android-nixpkgs/archive/main.tar.gz";
    in
      import (android-nixpkgs + "/hm-module.nix");

in
{
  imports = [ android-sdk ];

  android-sdk.enable = true;

  # Optional; default path is "~/.local/share/android".
  android-sdk.path = "${config.home.homeDirectory}/.android/sdk";

  android-sdk.packages = sdk: with sdk; [
    build-tools-30-0-2
    cmdline-tools-latest
    emulator
    platforms-android-30
    sources-android-30
  ];

  programs.home-manager.enable = true;
...

but I get error when building:

➜  ~ home-manager switch         
error: attribute 'androidSdk' missing

       at /nix/store/dvslxnzg6j93qad6y2s8b5m5k1zjaanz-source/hm-module.nix:48:32:

           47|   config = mkIf (cfg.enable) {
           48|     android-sdk.finalPackage = pkgs.androidSdk cfg.packages;
             |                                ^
           49|
(use '--show-trace' to show detailed location information)

doofy avatar Dec 09 '21 06:12 doofy

Ah, you need the overlay installed, which isn't exposed outside of the flake. I'll try and make this possible, or avoid requiring an overlay.

tadfisher avatar Dec 09 '21 19:12 tadfisher

Ah, you need the overlay installed, which isn't exposed outside of the flake. I'll try and make this possible, or avoid requiring an overlay.

Hey, I just ran into the same error. I'm not using the nixpkgs Anrdoid setup since it doesn't include cmdline-tools for some reason, which Flutter requires. Is there some kind of workaround?

ari-becker avatar Jan 25 '22 09:01 ari-becker

Ah, you need the overlay installed, which isn't exposed outside of the flake. I'll try and make this possible, or avoid requiring an overlay.

Hey, I just ran into the same error. I'm not using the nixpkgs Anrdoid setup since it doesn't include cmdline-tools for some reason, which Flutter requires. Is there some kind of workaround?

machine.nix

{ config, lib, pkgs, inputs, ... }:
{
  # android-nixpkgs overlay
  nixpkgs.overlays = [
    inputs.android-nixpkgs.overlay
  ];
}

sminf avatar Mar 17 '22 16:03 sminf

I was able to access the overlay and add it to my nixpkg config with the following:

outputs = { self, darwin, nixpkgs, ... }@inputs:
    let
      inherit (darwin.lib) darwinSystem;
      inherit (nixpkgs.lib) attrValues makeOverridable optionalAttrs singleton;
      nixpkgsConfig = {
        config = {
          allowUnfree = true;
        };
        overlays = attrValues self.overlays
          ++ singleton inputs.android-nixpkgs.overlay
      }

Once I added the overlay, I was able to configure android-sdk via home-manager and flakes.

ebsi-cgoboncan avatar Mar 31 '22 18:03 ebsi-cgoboncan

~~How can this be done when using home-manager as a NixOS module? I have no inputs attribute to use. (Sorry if I'm missing something obvious, I'm quite new to this)~~

Edit: Turns out the overlay isn't needed if you use (callPackage <android-nixpkgs> {}).sdk directly.

hacker1024 avatar Jul 07 '22 15:07 hacker1024

Edit: Turns out the overlay isn't needed if you use (callPackage <android-nixpkgs> {}).sdk directly.

Would you have some example please? I'm new to nix and these notions start to be blurry to me

Eldorico avatar Feb 15 '24 07:02 Eldorico

nixpkgsConfig

yeah, very unclear to me too

offeex avatar Apr 28 '24 08:04 offeex