nix-on-droid fixes

This commit is contained in:
Fern Garden 2025-07-16 23:56:48 +08:00
parent 11494614c8
commit 9bf27e1960
2 changed files with 17 additions and 9 deletions

View file

@ -100,10 +100,12 @@ with inputs.nixpkgs.lib; {
}: let }: let
pkgs = import nixpkgs { pkgs = import nixpkgs {
system = "aarch64-linux"; system = "aarch64-linux";
config.allowUnfree = true; config = {
overlays = [ allowUnfree = true;
nix-on-droid.overlays.default overlays = [
]; nix-on-droid.overlays.default
];
};
}; };
activateNixOnDroid = configuration: activateNixOnDroid = configuration:
@ -114,12 +116,10 @@ with inputs.nixpkgs.lib; {
nixOnDroidConfigurations.${hostname} = nix-on-droid.lib.nixOnDroidConfiguration { nixOnDroidConfigurations.${hostname} = nix-on-droid.lib.nixOnDroidConfiguration {
inherit pkgs; inherit pkgs;
extraSpecialArgs = {inherit uid gid;};
modules = [ modules = [
./suites/nix-on-droid ./suites/nix-on-droid
{
user.uid = uid;
user.gid = gid;
}
]; ];
}; };

View file

@ -2,6 +2,8 @@
config, config,
pkgs, pkgs,
lib, lib,
uid,
gid,
... ...
}: }:
with lib; let with lib; let
@ -17,6 +19,12 @@ with lib; let
${pkgs.openssh}/bin/sshd -f "${sshdDirectory}/sshd_config" -D ${pkgs.openssh}/bin/sshd -f "${sshdDirectory}/sshd_config" -D
''; '';
in { in {
# Set UID & GID
user = {
uid = uid;
gid = gid;
};
# NixOS version. # NixOS version.
system.stateVersion = "24.05"; system.stateVersion = "24.05";
@ -28,7 +36,7 @@ in {
# SSHD script. # SSHD script.
build.activation.sshd = '' build.activation.sshd = ''
$DRY_RUN_CMD mkdir $VERBOSE_ARG --parents "${config.user.home}/.ssh" $DRY_RUN_CMD mkdir $VERBOSE_ARG --parents "${config.user.home}/.ssh"
$DRY_RUN_CMD cat ${authorizedKeys} > "${config.user.home}/.ssh/authorized_keys" $DRY_RUN_CMD echo ${authorizedKeys} > "${config.user.home}/.ssh/authorized_keys"
if [[ ! -d "${sshdDirectory}" ]]; then if [[ ! -d "${sshdDirectory}" ]]; then
$DRY_RUN_CMD rm $VERBOSE_ARG --recursive --force "${sshdTmpDirectory}" $DRY_RUN_CMD rm $VERBOSE_ARG --recursive --force "${sshdTmpDirectory}"