Skip to content

Instantly share code, notes, and snippets.

@ajgringo619
Last active July 6, 2024 23:18
Show Gist options
  • Save ajgringo619/c3dbc88ca03a380caac8a14139d7442d to your computer and use it in GitHub Desktop.
Save ajgringo619/c3dbc88ca03a380caac8a14139d7442d to your computer and use it in GitHub Desktop.
My NixOS config using Hyper-V
# NOTE: this config contains a fair amount of user-specific settings, but I
# left them in as they provide working examples (Samba, systemd services, etc.).
#
# This config is designed for the Budgie Desktop, but can easily be adapted to
# any DE. For Hyper-V to work, blacklisting the hyperv_fb module was critical.
#
# I am also using GRUB instead of the default systemd-boot.
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
# ----- Hyper-V Guest support ----- #
virtualisation.hypervGuest = {
enable = true;
videoMode = "1920x1080";
};
boot.blacklistedKernelModules = [ "hyperv_fb" ];
# ----- GRUB bootloader ----- #
boot.loader = {
efi = {
canTouchEfiVariables = true;
efiSysMountPoint = "/boot/efi";
};
grub = {
efiSupport = true;
device = "nodev";
};
};
# ----- Networking ----- #
networking = {
hostName = "nixos-budgie";
networkmanager.enable = true;
firewall = {
enable = true;
allowedTCPPorts = [ 22 ];
};
};
# ----- Samba mounts ----- #
fileSystems."/media/host/Downloads" = {
device = "//dss-windows/host-Downloads";
fsType = "cifs";
options = [ "credentials=/root/smbcredentials" "uid=1000" "gid=1000" ];
};
fileSystems."/media/host/Shared-Files" = {
device = "//dss-windows/host-Shared-Files";
fsType = "cifs";
options = [ "credentials=/root/smbcredentials" "uid=1000" "gid=1000" ];
};
# ----- systemd services ----- #
systemd.services.btrfs_balance = {
description = "balance of mounted BTFS file systems";
serviceConfig = {
Type = "simple";
ExecStart = "/run/current-system/sw/bin/bash -l -c '/media/host/Shared-Files/btrfs_maintenance/btrfs_maintenance balance'";
};
};
systemd.timers.btrfs_balance = {
description = "Weekly balancing of BTRFS file systems";
timerConfig = {
Unit = "btrfs_balance.service";
OnCalendar = "weekly";
AccuracySec = "1h";
Persistent = "true";
RandomizedDelaySec = "60min";
};
wantedBy = [ "timers.target" ];
};
systemd.services.btrfs_scrub = {
description = "scrub of mounted BTFS file systems";
serviceConfig = {
Type = "simple";
ExecStart = "/run/current-system/sw/bin/bash -l -c '/media/host/Shared-Files/btrfs_maintenance/btrfs_maintenance scrub'";
};
};
systemd.timers.btrfs_scrub = {
description = "Monthly scrub of BTRFS file systems";
timerConfig = {
Unit = "btrfs_scrub.service";
OnCalendar = "monthly";
AccuracySec = "1h";
Persistent = "true";
RandomizedDelaySec = "60min";
};
wantedBy = [ "timers.target" ];
};
# Set your time zone.
time.timeZone = "America/Los_Angeles";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
# ----- Budgie Desktop Environment ----- #
services.xserver = {
enable = true;
layout = "us";
xkbVariant = "";
displayManager = {
autoLogin.enable = true;
autoLogin.user = "ajgringo619";
lightdm.enable = true;
};
desktopManager.budgie.enable = true;
};
# ----- Printing ----- #
services = {
avahi = {
enable = true;
nssmdns = true;
openFirewall = true;
};
printing = {
enable = true;
drivers = [ pkgs.hplip ];
};
};
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.ajgringo619 = {
isNormalUser = true;
description = "ajgringo619";
extraGroups = [ "networkmanager" "wheel" ];
initialPassword = "";
packages = with pkgs; [
fish
fastfetch
];
};
systemd.user.services.vm_info = {
description = "Updates virtual machine config data";
enable = true;
unitConfig = {
RequiresMountsFor = "/media/host/Shared-Files";
};
serviceConfig = {
Type = "simple";
ExecStart = "/run/current-system/sw/bin/bash -l -c 'python3 /media/host/Shared-Files/vm_info/get_vm_info_static.py'";
};
wantedBy = [ "default.target" ];
};
# ----- Packages, program settings ----- #
nixpkgs.config.allowUnfree = true;
boot.kernelPackages = pkgs.linuxPackages_latest;
environment.systemPackages = with pkgs; [
# system
conky
lsb-release
xdg-user-dirs
# development
git
man-pages
man-pages-posix
(python312Full.withPackages (ps: with ps; [
distro
psutil
pyaml ]))
# other programs
bat
duf
fd
gparted
inxi
lsd
lynis
nano
ncdu
nerdfonts
nmap
unison
];
programs = {
nano.syntaxHighlight = true;
nano.nanorc = ''
set atblanks
set autoindent
set boldtext
set breaklonglines
set casesensitive
set constantshow
set historylog
set indicator
set linenumbers
set locking
set matchbrackets "(<[{)>]}"
set mouse
set nonewlines
set softwrap
set tabsize 4
set tabstospaces
set trimblanks
set titlecolor bold,white,magenta
set promptcolor black,yellow
set statuscolor bold,white,magenta
set errorcolor bold,white,red
set spotlightcolor black,orange
set selectedcolor lightwhite,cyan
set stripecolor ,yellow
set scrollercolor magenta
set numbercolor magenta
set keycolor lightmagenta
set functioncolor magenta
extendsyntax python tabgives " "
extendsyntax makefile tabgives " "
bind ^X cut main
bind ^C copy main
bind ^V paste all
bind ^Q exit all
bind ^S savefile main
bind ^F whereis all
bind ^G findnext all
bind ^R replace main
unbind ^U all
unbind ^N main
unbind ^Y all
unbind M-J main
unbind M-T main
bind ^Z undo main
'';
};
# ----- Services, security settings ----- #
services = {
fstrim.enable = true;
openssh.enable = true;
};
security = {
rtkit.enable = true;
sudo.wheelNeedsPassword = false;
};
system.stateVersion = "23.11";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment