host/home: add android sdk

This commit is contained in:
Dmitriy Pleshevskiy 2024-02-18 23:08:50 +03:00
parent c526473f4f
commit 19dbd21f4b
Signed by: pleshevskiy
GPG key ID: 79C4487B44403985
4 changed files with 61 additions and 6 deletions

View file

@ -1,4 +1,4 @@
NIX_RUN := sudo nix run .\# NIX_RUN := nix run .\#
NIX_LOCK := nix flake lock NIX_LOCK := nix flake lock
DEPS_MY := \ DEPS_MY := \
@ -34,14 +34,14 @@ define machine_rule
.PHONY: $(1) .PHONY: $(1)
$(1): ; $(1): ;
systemctl --user reset-failed systemctl --user reset-failed
$$(NIX_RUN)switch/$(1) sudo $$(NIX_RUN)switch/$(1)
.PHONY: rollback-$(1) .PHONY: rollback-$(1)
rollback-$(1): rollback-$(1):
$$(NIX_RUN)rollback/$(1) sudo $$(NIX_RUN)rollback/$(1)
.PHONY: test-$(1) .PHONY: test-$(1)
test-$(1): ; $$(NIX_RUN)test/$(1) test-$(1): ; sudo $$(NIX_RUN)test/$(1)
endef endef
define vps_rule define vps_rule

View file

@ -75,7 +75,7 @@
(hostname: machine: pkgs.writeShellScript "deploy-${hostname}" '' (hostname: machine: pkgs.writeShellScript "deploy-${hostname}" ''
${nixos-rebuild}/bin/nixos-rebuild switch \ ${nixos-rebuild}/bin/nixos-rebuild switch \
--flake .#${hostname} \ --flake .#${hostname} \
--target-host ${machine.config.deployment.targetHost} \ --target-host root@${machine.config.deployment.targetHost} \
$@ $@
'') '')
vpsMachines); vpsMachines);

View file

@ -29,6 +29,8 @@ in
(lib.mkIf config.virtualisation.docker.enable "docker") (lib.mkIf config.virtualisation.docker.enable "docker")
(lib.mkIf config.services.transmission.enable "transmission") (lib.mkIf config.services.transmission.enable "transmission")
(lib.mkIf config.services.kubo.enable "ipfs") (lib.mkIf config.services.kubo.enable "ipfs")
(lib.mkIf config.programs.adb.enable "adbusers")
(lib.mkIf config.programs.adb.enable "plugdev")
]; ];
shell = pkgs.zsh; shell = pkgs.zsh;
hashedPasswordFile = config.age.secrets.users-jan-passfile.path; hashedPasswordFile = config.age.secrets.users-jan-passfile.path;
@ -36,6 +38,8 @@ in
openssh.authorizedKeys.keys = data.publicKeys.users.jan; openssh.authorizedKeys.keys = data.publicKeys.users.jan;
}; };
users.groups.plugdev = lib.mkIf config.programs.adb.enable { };
home-manager.users.jan = { lib, ... }: { home-manager.users.jan = { lib, ... }: {
imports = [ imports = [
inputs.wired.homeManagerModules.default inputs.wired.homeManagerModules.default

View file

@ -1,5 +1,6 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
imports = [ imports = [
# Include the results of the hardware scan. # Include the results of the hardware scan.
@ -48,7 +49,12 @@
# enable bluetooth # enable bluetooth
hardware.bluetooth.enable = true; hardware.bluetooth.enable = true;
local.nix.allowUnfreePackages = [ "cnijfilter2" "memtest86" ]; nixpkgs.config.allowUnfree = true;
local.nix.allowUnfreePackages = [
"cnijfilter2"
"memtest86"
"android-sdk-cmdline-tools"
];
services.openssh.enable = true; services.openssh.enable = true;
@ -118,4 +124,49 @@
# 3D printing # 3D printing
local.octoprint.enable = true; local.octoprint.enable = true;
# Android
programs.adb.enable = true;
programs.java = {
enable = true;
package = pkgs.jdk17;
};
nixpkgs.config.android_sdk.accept_license = true;
environment.variables =
let
buildToolsVersion = "33.0.2";
androidComposition = pkgs.unstable.androidenv.composeAndroidPackages {
platformToolsVersion = "34.0.5";
buildToolsVersions = [ buildToolsVersion ];
includeEmulator = false;
emulatorVersion = "34.1.9";
platformVersions = [ "29" "30" "33" ];
includeSources = false;
includeSystemImages = false;
systemImageTypes = [ "google_apis_playstore" ];
abiVersions = [ "armeabi-v7a" "arm64-v8a" ];
cmakeVersions = [ "3.10.2" ];
includeNDK = true;
ndkVersions = [ "23.2.8568313" ];
useGoogleAPIs = false;
useGoogleTVAddOns = false;
includeExtras = [
"extras;google;gcm"
];
};
in
rec {
ANDROID_SDK_ROOT = "${androidComposition.androidsdk}/libexec/android-sdk";
ANDROID_NDK_ROOT = "${ANDROID_SDK_ROOT}/ndk-bundle";
# Use the same buildToolsVersion here
# GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_SDK_ROOT}/build-tools/${buildToolsVersion}/aapt2";
# JAVA_HOME = pkgs.jdk17.home;
};
services.udev.extraRules = ''
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666", GROUP="plugdev"
'';
} }