Skip to content

Commit eb3c7aa

Browse files
committed
refactor(android): extract common.nix with sshd_config and shared Termux settings
1 parent a7c20e6 commit eb3c7aa

3 files changed

Lines changed: 46 additions & 42 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{ config, pkgs, lib, ... }:
2+
3+
{
4+
home.file.".ssh/sshd_config" = {
5+
text = ''
6+
Port 8022
7+
HostKey ${config.home.homeDirectory}/.ssh/id_ed25519
8+
AuthorizedKeysFile .ssh/authorized_keys
9+
PasswordAuthentication yes
10+
PermitEmptyPasswords no
11+
ChallengeResponseAuthentication no
12+
PrintMotd no
13+
AcceptEnv LANG LC_*
14+
'';
15+
};
16+
17+
home.file.".termux/boot/start-sshd.sh" = {
18+
text = ''
19+
#!/bin/sh
20+
if ! pgrep -x "sshd" > /dev/null; then
21+
${pkgs.openssh}/bin/sshd -f ${config.home.homeDirectory}/.ssh/sshd_config
22+
fi
23+
'';
24+
executable = true;
25+
};
26+
27+
xdg.configFile."nix/nix.conf".text = ''
28+
sandbox = false
29+
connect-timeout = 20
30+
max-jobs = 1
31+
'';
32+
33+
programs.udocker.enable = true;
34+
}

machines/aarch64/android/smartphone/default.nix

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ let
44
hostName = "aarch64.android.smartphone";
55
in
66
{
7-
imports = [ ../../../../home.nix ];
7+
imports = [
8+
../../../../home.nix
9+
../common.nix
10+
];
811

912
home.username = "brantes";
1013
home.homeDirectory = "/home/brantes";
@@ -24,32 +27,14 @@ in
2427
programs.zsh.initExtra = ''
2528
export PROMPT="%F{yellow}%n%f@%F{green}${hostName}%f:%F{blue}%~%f%# "
2629
if ! pgrep -x "sshd" > /dev/null; then
27-
${pkgs.openssh}/bin/sshd -p 8022
30+
${pkgs.openssh}/bin/sshd -f ${config.home.homeDirectory}/.ssh/sshd_config
2831
fi
2932
'';
3033

3134
programs.bash.initExtra = ''
3235
export PS1="\[\033[01;33m\]\u\[\033[00m\]@\[\033[01;32m\]${hostName}\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
3336
if ! pgrep -x "sshd" > /dev/null; then
34-
${pkgs.openssh}/bin/sshd -p 8022
37+
${pkgs.openssh}/bin/sshd -f ${config.home.homeDirectory}/.ssh/sshd_config
3538
fi
3639
'';
37-
38-
home.file.".termux/boot/start-sshd.sh" = {
39-
text = ''
40-
#!/bin/sh
41-
if ! pgrep -x "sshd" > /dev/null; then
42-
${pkgs.openssh}/bin/sshd -p 8022
43-
fi
44-
'';
45-
executable = true;
46-
};
47-
48-
xdg.configFile."nix/nix.conf".text = ''
49-
sandbox = false
50-
connect-timeout = 20
51-
max-jobs = 1
52-
'';
53-
54-
programs.udocker.enable = true;
5540
}

machines/aarch64/android/tablet/default.nix

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ let
44
hostName = "aarch64.android.tablet";
55
in
66
{
7-
imports = [ ../../../../home.nix ];
7+
imports = [
8+
../../../../home.nix
9+
../common.nix
10+
];
811

912
home.username = "brantes";
1013
home.homeDirectory = "/home/brantes";
@@ -24,32 +27,14 @@ in
2427
programs.zsh.initExtra = ''
2528
export PROMPT="%F{yellow}%n%f@%F{green}${hostName}%f:%F{blue}%~%f%# "
2629
if ! pgrep -x "sshd" > /dev/null; then
27-
${pkgs.openssh}/bin/sshd -p 8022
30+
${pkgs.openssh}/bin/sshd -f ${config.home.homeDirectory}/.ssh/sshd_config
2831
fi
2932
'';
3033

3134
programs.bash.initExtra = ''
3235
export PS1="\[\033[01;33m\]\u\[\033[00m\]@\[\033[01;32m\]${hostName}\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
3336
if ! pgrep -x "sshd" > /dev/null; then
34-
${pkgs.openssh}/bin/sshd -p 8022
37+
${pkgs.openssh}/bin/sshd -f ${config.home.homeDirectory}/.ssh/sshd_config
3538
fi
3639
'';
37-
38-
home.file.".termux/boot/start-sshd.sh" = {
39-
text = ''
40-
#!/bin/sh
41-
if ! pgrep -x "sshd" > /dev/null; then
42-
${pkgs.openssh}/bin/sshd -p 8022
43-
fi
44-
'';
45-
executable = true;
46-
};
47-
48-
xdg.configFile."nix/nix.conf".text = ''
49-
sandbox = false
50-
connect-timeout = 20
51-
max-jobs = 1
52-
'';
53-
54-
programs.udocker.enable = true;
5540
}

0 commit comments

Comments
 (0)