add phone config
This commit is contained in:
		
							parent
							
								
									3b10a0f211
								
							
						
					
					
						commit
						44b17a0648
					
				
					 6 changed files with 318 additions and 2 deletions
				
			
		
							
								
								
									
										14
									
								
								hosts/droid/default.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								hosts/droid/default.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,14 @@
 | 
			
		|||
{
 | 
			
		||||
  nixpkgs,
 | 
			
		||||
  nix-on-droid,
 | 
			
		||||
  home-manager,
 | 
			
		||||
  ...
 | 
			
		||||
}:
 | 
			
		||||
nix-on-droid.lib.nixOnDroidConfiguration {
 | 
			
		||||
  pkgs = import nixpkgs { system = "aarch64-linux"; };
 | 
			
		||||
  modules = [
 | 
			
		||||
    home-manager.nixosModules.home-manager
 | 
			
		||||
    ./sshd.nix
 | 
			
		||||
    ./stuff.nix
 | 
			
		||||
  ];
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										37
									
								
								hosts/droid/sshd.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								hosts/droid/sshd.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,37 @@
 | 
			
		|||
{ config, pkgs, ... }:
 | 
			
		||||
let
 | 
			
		||||
  sshdTmpDirectory = "${config.user.home}/sshd-tmp";
 | 
			
		||||
  sshdDirectory = "${config.user.home}/sshd";
 | 
			
		||||
  pubKeys = ''
 | 
			
		||||
    ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPDNpLDmctyqGpow/ElQvdhY4BLBPS/sigDJ1QEcC7wC vinzenz-lpt2-roaming
 | 
			
		||||
  '';
 | 
			
		||||
  port = 8022;
 | 
			
		||||
in
 | 
			
		||||
{
 | 
			
		||||
  build.activation.sshd = ''
 | 
			
		||||
    $DRY_RUN_CMD mkdir $VERBOSE_ARG --parents "${config.user.home}/.ssh"
 | 
			
		||||
    $DRY_RUN_CMD echo "${pubKeys}" > "${config.user.home}/.ssh/authorized_keys"
 | 
			
		||||
 | 
			
		||||
    if [[ ! -d "${sshdDirectory}" ]]; then
 | 
			
		||||
      $DRY_RUN_CMD rm $VERBOSE_ARG --recursive --force "${sshdTmpDirectory}"
 | 
			
		||||
      $DRY_RUN_CMD mkdir $VERBOSE_ARG --parents "${sshdTmpDirectory}"
 | 
			
		||||
 | 
			
		||||
      $VERBOSE_ECHO "Generating host keys..."
 | 
			
		||||
      $DRY_RUN_CMD ${pkgs.openssh}/bin/ssh-keygen -t rsa -b 4096 -f "${sshdTmpDirectory}/ssh_host_rsa_key" -N ""
 | 
			
		||||
 | 
			
		||||
      $VERBOSE_ECHO "Writing sshd_config..."
 | 
			
		||||
      $DRY_RUN_CMD echo -e "HostKey ${sshdDirectory}/ssh_host_rsa_key\nPort ${toString port}\n" > "${sshdTmpDirectory}/sshd_config"
 | 
			
		||||
 | 
			
		||||
      $DRY_RUN_CMD mv $VERBOSE_ARG "${sshdTmpDirectory}" "${sshdDirectory}"
 | 
			
		||||
    fi
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  environment.packages = [
 | 
			
		||||
    (pkgs.writeScriptBin "sshd-start" ''
 | 
			
		||||
      #!${pkgs.runtimeShell}
 | 
			
		||||
 | 
			
		||||
      echo "Starting sshd in non-daemonized way on port ${toString port}"
 | 
			
		||||
      ${pkgs.openssh}/bin/sshd -f "${sshdDirectory}/sshd_config" -D
 | 
			
		||||
    '')
 | 
			
		||||
  ];
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										23
									
								
								hosts/droid/stuff.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								hosts/droid/stuff.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,23 @@
 | 
			
		|||
{
 | 
			
		||||
  pkgs,
 | 
			
		||||
  ...
 | 
			
		||||
}:
 | 
			
		||||
{
 | 
			
		||||
  environment.packages = with pkgs; [
 | 
			
		||||
    nano
 | 
			
		||||
    hostname
 | 
			
		||||
    zsh
 | 
			
		||||
    openssh
 | 
			
		||||
    which
 | 
			
		||||
    curl
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  # Backup etc files instead of failing to activate generation if a file already exists in /etc
 | 
			
		||||
  environment.etcBackupExtension = ".bak";
 | 
			
		||||
 | 
			
		||||
  system.stateVersion = "24.05";
 | 
			
		||||
  nix.extraOptions = ''
 | 
			
		||||
    experimental-features = nix-command flakes
 | 
			
		||||
  '';
 | 
			
		||||
  time.timeZone = "Europe/Berlin";
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue