Modularize NixOS 'vm' configuration

This commit is contained in:
2025-10-04 21:20:58 +02:00
parent ca8cfd7deb
commit c36b202d4e
5 changed files with 14 additions and 64 deletions

View File

@@ -0,0 +1,52 @@
{ pkgs, ... }:
{
system.stateVersion = "25.05";
imports =
[
./hard.nix
../../modules/bootloader.nix
../../modules/networking.nix
../../modules/users.nix
../../modules/audio.nix
../../modules/printing.nix
../../modules/localization.nix
../../modules/x.nix
];
nix.settings.experimental-features = [ "nix-command" "flakes" ];
programs.git.enable = true;
programs.firefox.enable = true;
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [ neovim ];
services.spice-vdagentd.enable = true;
services.openssh = {
enable = true;
startWhenNeeded = true;
settings = {
## hardening
PermitRootLogin = "no";
MaxAuthTries = 3;
LoginGraceTime = "1m";
PasswordAuthentication = false;
PermitEmptyPasswords = false;
ChallengeResponseAuthentication = false;
KerberosAuthentication = false;
GSSAPIAuthentication = false;
X11Forwarding = false;
PermitUserEnvironment = false;
AllowAgentForwarding = false;
AllowTcpForwarding = false;
PermitTunnel = false;
## sshd_config defaults on Arch Linux
KbdInteractiveAuthentication = false;
UsePAM = true;
PrintMotd = false;
};
};
}

33
hosts/vm/hard.nix Normal file
View File

@@ -0,0 +1,33 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/7d406784-bf6b-420e-a956-134f719c8206";
fsType = "ext4";
};
swapDevices =
[ { device = "/dev/disk/by-uuid/4cbaffdb-0ca2-4735-87d0-eefe994f0e18"; }
];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp1s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}

12
hosts/vm/home.nix Normal file
View File

@@ -0,0 +1,12 @@
{ config, pkgs, ... }:
{
home.stateVersion = "25.05";
home.username = "h";
home.homeDirectory = "/home/h";
home.file.".inputrc".source = ./dots/.inputrc;
programs.home-manager.enable = true;
}