Files
first/configuration.nix
2026-01-10 08:40:15 +01:00

139 lines
3.5 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }:
{
# imports = [ ./hw.nix ];
# boot.loader.grub.device = "/dev/vda";
# fileSystems."/" = {
# device = "/dev/vda1";
# fsType = "ext4";
# };
boot.kernelParams = [
"console=ttyS0,115200"
"console=tty1"
];
# Enable virtio balloon driver for dynamic memory resizing
boot.kernelModules = [ "virtio_balloon" ];
systemd.services."serial-getty@ttyS0" = {
enable = true;
wantedBy = [ "getty.target" ]; # to start at boot
serviceConfig.Restart = "always"; # restart when session is closed
};
# network and proxy
networking.hostName = "minimal";
networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "Europe/Stockholm";
# Select internationalisation properties.
i18n.defaultLocale = "sv_SE.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "sv-latin1";
};
# Define a user account. Don't forget to set a password with passwd.
security.sudo.wheelNeedsPassword = false;
programs.zsh.enable = true;
users.mutableUsers = true;
users.users.kalle = {
isNormalUser = true;
initialHashedPassword = "$6$92TJx1rnVZ8ZBWGk$.0CUy9wLNbfNdmkwhnQCOomFiy.oJA2bSzLOixoQS3UyV/BITD55IhEVfr05VUVJtjcUoVIE1We99qEAWAbkE/";
shell = pkgs.zsh;
extraGroups = [ "wheel" "docker" "networkmanager" "video" "audio" ]; # Enable sudo for the user.
packages = with pkgs; [
# common sense
zsh
tmux
fzf
fzf-zsh
bat
fd
];
};
# system packages
environment.systemPackages = with pkgs; [
# basic stuff
vim
btrfs-progs
cloud-utils
# net
wireguard-tools
inetutils
wget
mosh
rsync
git
];
# List services that you want to enable:
# Enable the OpenSSH daemon.
services.openssh.enable = true;
# Auto-grow root filesystem on boot (for live disk resize support)
# Works with VIRTIO-SCSI (/dev/sda) - detects partition layout automatically
systemd.services.auto-grow-root = {
description = "Auto-grow root filesystem";
wantedBy = [ "multi-user.target" ];
after = [ "local-fs.target" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
path = with pkgs; [ cloud-utils parted e2fsprogs btrfs-progs util-linux ];
script = ''
set -euo pipefail
ROOT_DEV=$(findmnt -n -o SOURCE /)
ROOT_DISK=$(lsblk -no PKNAME "$ROOT_DEV" | head -1)
# If partitioned, grow partition first
if [[ "$ROOT_DEV" =~ [0-9]$ ]]; then
PART_NUM=$(echo "$ROOT_DEV" | grep -oE '[0-9]+$')
growpart "/dev/$ROOT_DISK" "$PART_NUM" 2>/dev/null || true
fi
# Grow filesystem
FSTYPE=$(findmnt -n -o FSTYPE /)
case "$FSTYPE" in
ext4) resize2fs "$ROOT_DEV" 2>/dev/null || true ;;
btrfs) btrfs filesystem resize max / 2>/dev/null || true ;;
esac
'';
};
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "25.05"; # Did you read the comment?
}