tadfisher / android-nixpkgs

Nix-packaged Android SDK
MIT License
275 stars 42 forks source link

Unable to use with home manager #15

Open doofy opened 2 years ago

doofy commented 2 years ago

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?

tadfisher commented 2 years ago

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 ];

 #  ...
}
doofy commented 2 years ago

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)
tadfisher commented 2 years ago

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.

ari-becker commented 2 years ago

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?

sminf commented 2 years ago

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
  ];
}
ebsi-cgoboncan commented 2 years ago

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.

hacker1024 commented 2 years ago

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.

Eldorico commented 7 months ago

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

offeex commented 5 months ago
nixpkgsConfig

yeah, very unclear to me too