Skip to content

Instantly share code, notes, and snippets.

@sicet7
Last active October 15, 2024 09:34
Show Gist options
  • Save sicet7/57486deaaeb2aafdbea34c71538334df to your computer and use it in GitHub Desktop.
Save sicet7/57486deaaeb2aafdbea34c71538334df to your computer and use it in GitHub Desktop.
My Nixos Configuration
# 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, lib, ... }:
let
home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-24.05.tar.gz";
dotnetPkg = pkgs.dotnetCorePackages.sdk_8_0;
forcedUnstable = import
(builtins.fetchTarball https://github.com/nixos/nixpkgs/tarball/nixpkgs-unstable)
# reuse the current configuration
{ config = config.nixpkgs.config; };
in
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
(import "${home-manager}/nixos")
];
# Bootloader.
boot.loader = {
efi = {
canTouchEfiVariables = true;
};
# Setup grub to use osprober
grub = {
enable = true;
device = "nodev";
useOSProber = true;
efiSupport = true;
};
};
# Add firmwares
hardware.firmware = [
# Firmware for: "TP-Link TP-Link UB500 Adapter"
pkgs.rtl8761b-firmware
];
# Windows dual boot system time issue fix.
time.hardwareClockInLocalTime = true;
# Configure Networking
networking = {
hostName = "sicet7-nixos-company"; # Hostname
enableIPv6 = false; # Disable IPv6
# Network Manager
networkmanager = {
enable = true;
};
# Extra hosts
extraHosts = ''
127.0.0.1 1001biler.localhost
127.0.0.1 au2garant.localhost
'';
# Firewall
firewall = {
enable = true;
# allowedTCPPorts = [ ... ];
# allowedUDPPorts = [ ... ];
};
};
# Set time zone.
time.timeZone = "Europe/Copenhagen";
# Select internationalisation properties.
i18n.defaultLocale = "en_DK.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "da_DK.UTF-8";
LC_IDENTIFICATION = "da_DK.UTF-8";
LC_MEASUREMENT = "da_DK.UTF-8";
LC_MONETARY = "da_DK.UTF-8";
LC_NAME = "da_DK.UTF-8";
LC_NUMERIC = "da_DK.UTF-8";
LC_PAPER = "da_DK.UTF-8";
LC_TELEPHONE = "da_DK.UTF-8";
LC_TIME = "da_DK.UTF-8";
};
# Enable modesetting (only if having issues on Nvidia)
#hardware.nvidia.modesetting.enable = true;
# Enable OpenGL
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};
# Configure xserver service.
services.xserver = {
enable = true;
# Configure Graphics Drivers
videoDrivers = ["nvidia"];
# Configure keymap in X11
xkb = {
layout = "dk";
variant = "";
};
# Configure Gnome Display Manger
displayManager = {
gdm = {
enable = true;
wayland = true;
autoSuspend = false;
};
};
# Configure GNOME Desktop Manger
desktopManager = {
# Enable GNOME desktop.
gnome.enable = true;
# Enable XTerm console.
xterm.enable = true;
};
};
# Configure console keymap
console.keyMap = "dk-latin1";
# Enable CUPS to print documents.
services.printing.enable = true;
# Enable bluetooth
hardware.bluetooth.enable = true;
hardware.bluetooth.settings = {
General = {
Enable = "Source,Sink,Media,Socket";
};
};
# Enable sound with pipewire.
sound.enable = true;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
# If you want to use JACK applications, uncomment this
#jack.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default,
# no need to redefine it in your config for now)
#media-session.enable = true;
};
environment.gnome.excludePackages = with pkgs.gnome; [
pkgs.gnome-tour # guided tour and greeter
epiphany # web browser
totem # video player
cheese # photo booth
simple-scan # document scanner
geary # email client
seahorse # password manager
pkgs.gedit # old text editor
pkgs.gnome-connections # "New" RDP client that dosent work.
];
# Configure fonts
fonts = {
fontconfig = {
enable = true;
localConf = ''
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "../fonts.dtd">
<fontconfig>
<alias>
<family>Source Code Pro</family>
<default>
<family>monospace</family>
</default>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Source Code Pro</family>
</prefer>
</alias>
</fontconfig>
'';
};
fontDir.enable = true;
};
# Global Level program Config
programs = {
# Enable dconf program.
dconf = {
enable = true;
};
# Enable ZSH Globally to allow for shell switch
zsh = {
enable = true;
};
# Nano config (installed by default)
nano = {
nanorc = ''
set autoindent
set tabsize 4
set tabstospaces
set numbercolor white
'';
syntaxHighlight = true;
};
xwayland = {
enable = true;
};
};
# Enable touchpad support (enabled default in most desktopManager).
services.libinput.enable = true;
# Virtualization
virtualisation = {
# Docker
docker = {
enable = true;
};
# Libvirtd
libvirtd = {
enable = true;
qemu = {
# Virutal TPM
swtpm = {
enable = true;
};
# Secure boot
ovmf = {
enable = true;
packages = [ pkgs.OVMFFull.fd ];
};
};
};
# USB Redirection
spiceUSBRedirection = {
enable = true;
};
};
# Enable Spice guest vdagent daemon
services.spice-vdagentd.enable = true;
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.sicet7 = {
isNormalUser = true;
description = "Martin René Sørensen";
extraGroups = [ "networkmanager" "wheel" "docker" "libvirtd" ];
shell = pkgs.zsh;
};
# Home Manager
home-manager.useUserPackages = true;
home-manager.useGlobalPkgs = true;
# Home Manager (users)
home-manager.users.sicet7 = { lib, config, ... }: {
home.stateVersion = "23.11";
# User packages
home.packages = with pkgs; [
# Browser
google-chrome
# Music and Video playback
vlc
spotify
# Image Editor
gimp
# Remote Desktop
#anydesk
# Open Broadcaster Software
obs-studio
# Screenshot utillity
flameshot
# REST Client
insomnia
# Jetbrains tooling
jetbrains.rider
jetbrains.goland
jetbrains.webstorm
jetbrains.phpstorm
jetbrains.datagrip
# Communications :-)
signal-desktop
slack
discord
];
# Command Aliases
home.shellAliases = {
mv = "mv -iv";
rm = "rm -v";
df = "df -h";
du = "du -hs";
ds = "docker stats --format=\"table {{.Name}}\t{{.CPUPerc}}\t{{.MemPerc}}\t{{.MemUsage}}\t{{.NetIO}}\"";
gotop = "gotop --color=nord";
gedit = "gnome-text-editor";
};
# Dconf Settings
dconf.settings = {
"org/gnome/TextEditor" = {
custom-font = "SauceCodePro Nerd Font Semi-Bold 12";
highlight-current-line = false;
indent-style = "space";
show-grid = false;
show-map = false;
style-scheme = "Adwaita-dark";
tab-width = lib.hm.gvariant.mkUint32 4;
use-system-font = false;
};
"org/gnome/desktop/calendar" = {
show-weekdate = true;
};
"org/gnome/desktop/interface" = {
clock-show-seconds = true;
clock-show-weekday = true;
color-scheme = "prefer-dark";
document-font-name = "Source Code Pro 11";
enable-hot-corners = false;
font-antialiasing = "rgba";
font-hinting = "slight";
font-name = "Source Code Pro 11";
gtk-theme = "Adwaita-dark";
};
"org/gnome/desktop/session" = {
idle-delay = lib.hm.gvariant.mkUint32 0;
};
"org/gnome/desktop/screensaver" = {
lock-enabled = false;
};
"org/gnome/desktop/wm/preferences" = {
button-layout = "close,minimize,maximize:appmenu";
};
"org/gnome/nautilus/preferences" = {
search-filter-time-type = "last_modified";
};
"org/gnome/settings-daemon/plugins/power" = {
power-button-action = "interactive";
sleep-inactive-ac-type = "nothing";
};
"org/gnome/shell" = {
favorite-apps = [
"google-chrome.desktop"
"org.gnome.Nautilus.desktop"
"slack.desktop"
"discord.desktop"
"signal-desktop.desktop"
"datagrip.desktop"
"phpstorm.desktop"
"rider.desktop"
"goland.desktop"
];
};
"org/gnome/settings-daemon/plugins/media-keys" = {
custom-keybindings = [
"/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/terminal/"
"/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/flameshot/"
];
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/flameshot" = {
binding = "Print";
command = "${pkgs.flameshot}/bin/flameshot gui";
name = "flameshot";
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/terminal" = {
binding = "<Control><Alt>t";
command = "xterm -e tmux";
name = "Open Terminal";
};
"org/gnome/mutter" = {
workspaces-only-on-primary = true;
};
"org/gnome/shell/app-switcher" = {
current-workspace-only = true;
};
"org/gnome/tweaks" = {
show-extensions-notice = false;
};
"org/gnome/shell/keybindings" = {
show-screenshot-ui = [];
};
};
# Services (sicet7)
services = {
flameshot = {
enable = true;
settings = {
General = {
savePath = "${config.home.homeDirectory}/Pictures/Screenshots";
savePathFixed = true;
showHelp = false;
filenamePattern = "%F_%H-%M-%S";
};
};
};
};
# Programs (sicet7)
programs = {
# GIT Config
git = {
enable = true;
userName = "Martin René Sørensen";
userEmail = "[email protected]";
aliases = {
assume = "update-index --assume-unchanged";
unassume = "update-index --no-assume-unchanged";
assumed = "!git ls-files -v | grep ^h | cut -c 3-";
ours = "!f() { git checkout --ours \$@ && git add \$@; }; f";
theirs = "!f() { git checkout --theirs \$@ && git add \$@; }; f";
unstage = "reset HEAD";
recreate = "!f() { [[ -n \$@ ]] && git checkout \"\$@\" && git unpublish && git checkout master && git branch -D \"\$@\" && git checkout -b \"\$@\" && git publish; }; f";
lcf = "diff-tree --no-commit-id --name-only -r";
rr = "!f() { git remote update \"\$1\" --prune; }; f";
diww = "!f() { git diff -w \"\$1^\" \"\$1\"; }; f";
cho = "checkout";
st = "status";
stauts = "status";
stuats = "status";
sta = "status";
chp = "cherry-pick";
tree = "log --graph";
};
extraConfig = {
core = {
fileMode = false;
symlinks = false;
};
pull = {
ff = "only";
};
push = {
autoSetupRemote = true;
};
init = {
defaultBranch = "master";
};
pager = {
branch = false;
};
};
};
# ZSH Config
zsh = {
enable = true;
#enableAutosuggestions = true;
#enableCompletion = true;
envExtra = ''
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#606060"
'';
initExtra = ''
export PATH="$PATH:/home/sicet7/.dotnet/tools"
enter () {
local shellFile="default.nix"
if [ $# -lt 1 ] || [ $# -ge 3 ]; then
echo "Invalid amount of arguments."
return 1
fi
if [ $# -eq 2 ]; then
local shellVersion="$2"
shellFile="''${shellVersion/\./_}.nix"
fi
local shellFilePath="$HOME/.my-nix-shells/$1/$shellFile"
if [ -f "$shellFilePath" ]; then
nix-shell --command zsh "$shellFilePath"
return 0
fi
echo "$shellFilePath does not exist"
return 1
};
'';
plugins = with pkgs; [
{
name = "zsh-autosuggestions";
src = fetchFromGitHub {
owner = "zsh-users";
repo = "zsh-autosuggestions";
rev = "v0.7.0";
sha256 = "28b518a54bb80c746e990677c39f66f5a4d6e9304a3025e5d9470a8b8b8c77bc";
};
}
{
name = "zsh-syntax-highlighting";
src = fetchFromGitHub {
owner = "zsh-users";
repo = "zsh-syntax-highlighting";
rev = "0.7.1";
sha256 = "80e1b434b95a25fa2d25fb3e49484680b4cd3a718b8e8aa7529e7857d685260f";
};
}
{
name = "zsh-completions";
src = fetchFromGitHub {
owner = "zsh-users";
repo = "zsh-completions";
rev = "0.35.0";
sha256 = "1851e5663207516c32795a02a6cce09f80262cf49213c51535f4668ac9e19298";
};
}
];
oh-my-zsh = {
enable = true;
};
};
# StarShip Config
starship = {
enable = true;
settings = {
time = {
disabled = false;
use_12hr = false;
};
nix_shell = {
format = "$state ";
impure_msg = "[\\[](bold red)[\$name](bold blue)[\\]](bold red)";
pure_msg = "[\\[](bold green)[\$name](bold blue)[\\]](bold green)";
unknown_msg = "[\\[](bold yellow)[\$name](bold blue)[\\]](bold yellow)";
};
sudo = {
disabled = false;
};
};
};
# TMUX Config
tmux = {
enable = true;
clock24 = true;
baseIndex = 1;
historyLimit = 10000;
escapeTime = 0;
shell = "${pkgs.zsh}/bin/zsh";
terminal = "screen-256color";
extraConfig = ''
# Prevent tmux from renaming my windows.
set-option -g allow-rename off
# Start new windows and panes from the same path
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# Change panes with <LALT>+<Arrow Keys>
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Next and previous windows on <prefix>(h or j)
bind h previous-window
bind j next-window
# bind T to top current window
bind-key T swap-window -t 1
# Copy Tmux buffer to system buffer with xclip (<prefix> + y)
bind y run "tmux save-buffer - | xsel -ib"
'';
plugins = with pkgs.tmuxPlugins; [
{
plugin = dracula;
extraConfig = ''
set -g @dracula-show-battery false
set -g @dracula-show-network false
set -g @dracula-show-weather false
set -g @dracula-military-time true
set -g @dracula-show-timezone false
set -g @dracula-cpu-usage true
set -g @dracula-ram-usage true
set -g @dracula-day-month true
set -g @dracula-plugins "cpu-usage ram-usage time"
set -g @dracula-left-icon-padding 1
'';
}
];
};
};
home.file = let
myDotFiles = pkgs.fetchFromGitHub {
owner = "sicet7";
repo = "nix";
rev = "1.0.7";
hash = "sha256-tOIraH2FRzx2rS2NdAWDPknXf/KKkWRLGyVZbbo29yw=";
};
in {
# XTERM Configuration
".Xresources".text = ''
XTerm*faceName: Source Code Pro,Source Code Pro Semibold
XTerm*faceSize: 12
XTerm*Background: Grey19
XTerm*Foreground: white
XTerm*VT100*selectToClipboard: true
'';
".my-nix-shells".source = "${myDotFiles}/shells";
};
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# enable zsh completion for system packages
# environment.pathsToLink = [ "/share/zsh" ];
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
# Packages for accessing web resources.
wget
curl
# DNS and Networking tools
dig
# Tool to access the X clipboard from a console application
xsel
# Programming Tools
go
dotnetPkg
mono
(php81.buildEnv {
extensions = { all, ... }: with all; [
filter
openssl
fileinfo
iconv
simplexml
tokenizer
xmlreader
xmlwriter
amqp
bcmath
bz2
curl
gd
imap
intl
ldap
mbstring
mysqli
mysqlnd
pdo_mysql
pgsql
pdo_pgsql
sqlsrv
pdo_sqlsrv
sqlite3
pdo_sqlite
pdo_odbc
mongodb
redis
zip
soap
sockets
sodium
pdo
ftp
dom
zlib
exif
posix
pcntl
ctype
xdebug
gettext
shmop
sysvmsg
sysvsem
sysvshm
imagick
openswoole
xsl
readline
];
})
nodejs_20
# Tools
mysql80
postgresql
gnumake
openssl
zip
gparted
ffmpeg_7-full
#Vulkan
vulkan-tools
lutris
# Terminal file manager
lf
# The unix "watch" command
unixtools.watch
# Process viewers
htop
gotop
#btop
# Docker Compose
docker-compose
# Install Source Code Pro font from NerdFonts
(pkgs.nerdfonts.override { fonts = [ "SourceCodePro" ]; })
# Remote desktop tools
remmina
forcedUnstable.anydesk
# Virtualization software
virt-manager
virt-viewer
win-virtio
spice
spice-gtk
spice-protocol
win-spice
# PGP
gnupg
# Install Gnome Packages.
gnome.baobab # disk usage analyzer
gnome.eog # image viewer
gnome.yelp # help viewer
gnome.evince # document viewer
gnome.file-roller # archive manager
# more gnome apps
gnome.gnome-calculator
gnome.gnome-calendar
gnome.gnome-characters
gnome.gnome-clocks
gnome.gnome-contacts
gnome.gnome-font-viewer
gnome.gnome-logs
gnome.gnome-maps
gnome.gnome-music
gnome.gnome-system-monitor
gnome.gnome-weather
gnome.gnome-disk-utility
gnome.gnome-tweaks
gnome.gnome-screenshot
#ODBC Driver install
unixODBC
];
#ODBC Drivers
environment.unixODBCDrivers = [
pkgs.unixODBCDrivers.msodbcsql18
pkgs.unixODBCDrivers.sqlite
pkgs.unixODBCDrivers.psql
pkgs.unixODBCDrivers.mariadb
];
environment.sessionVariables = {
NIXOS_OZONE_WL = "1";
};
environment.variables = rec {
DOTNET_ROOT="${dotnetPkg}";
};
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
# 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. It‘s 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 = "23.11"; # Did you read the comment?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment