Skip to content

Instantly share code, notes, and snippets.

@xane256
Last active April 6, 2026 20:17
Show Gist options
  • Select an option

  • Save xane256/7c58cb209ef6017eefe3625aa2b894b7 to your computer and use it in GitHub Desktop.

Select an option

Save xane256/7c58cb209ef6017eefe3625aa2b894b7 to your computer and use it in GitHub Desktop.
nix-ssh-speedrun
# INSTRUCTIONS:
# 1. Get this flake.
# 2. nix --extra-experimental-features 'nix-command flakes' shell nixpkgs#vim
# 3. vi flake.nix
# 4. CHANGE the parameters in the `let ... in` block below
# 5. nixos-generate-config --dir .
# 6. sudo nixos-rebuild --extra-experimental-settings 'nix-command flakes' .#nixos
{
description = "Minimal NixOS bootstrap";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs =
inputs@{ self, ... }:
let
# CHANGE for your system
hostname = "nixos";
username = "user";
sshKey = "YOUR_SSH_KEY";
# system = "x86_64-linux";
system = "aarch64-linux";
in
{
nixosConfigurations.${hostname} = inputs.nixpkgs.lib.nixosSystem {
inherit system;
modules = [
self.nixosModules.bootstrap
./hardware-configuration.nix
];
};
nixosModules.bootstrap =
{ pkgs, ... }:
{
networking.hostName = hostname;
networking.useNetworkd = true;
networking.useDHCP = true;
networking.firewall.enable = false;
services.openssh = {
enable = true;
settings.PermitRootLogin = "yes";
};
users.users.root = {
openssh.authorizedKeys.keys = [ sshKey ];
# set password once when user is created
initialPassword = "root";
};
users.users.${username} = {
isNormalUser = true;
extraGroups = [
"networkmanager"
"wheel"
];
openssh.authorizedKeys.keys = [ sshKey ];
# set password once when user is created
initialPassword = "user";
};
users.mutableUsers = true;
users.defaultUserShell = pkgs.zsh;
programs.zsh = {
enable = true;
enableCompletion = true;
interactiveShellInit = ''
EDITOR = "${pkgs.lib.getExe pkgs.vim}";
VISUAL = EDITOR;
'';
};
environment.systemPackages = with pkgs; [
curl
dig
gh
git
helix
iputils
just
neovim
vim
wget
];
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
time.timeZone = "America/Los_Angeles";
i18n.defaultLocale = "en_US.UTF-8";
system.stateVersion = "26.05";
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment