added base nix configuration

This commit is contained in:
Sven Vogel 2023-11-17 12:34:15 +01:00
parent f2697f7115
commit 2341438861
11 changed files with 146118 additions and 2 deletions

View File

@ -1,3 +1,19 @@
# NixOS
# Dotfiles
configuration of my nixos setups
Config files for various apps and services
## DVD decryption
DVDs can be decrypted without any configuration via the `libdvdcss` library and a transcoder such as `Handbrake` or `VLC`.
### Packages (System)
- libdvdcss
## Blueray Decryption
This configuration is capable of decrypting blueray disks through various libraries.
In order to work the `libaacs` requires a database with decryption keys per movie. That file is located at `~/.config/aacs/KEYDB.cfg`
and requires updates uppon new movie release. Updated files can be downloaded from here: [VUK Online Database](http://fvonline-db.bplaced.net/).
### Packages (System)
- libaacs
- libbdplus
- libbluray

50
boot.nix Normal file
View File

@ -0,0 +1,50 @@
{ pkgs, ... }:
{
# ======================================================
# ____ _ _ _
# | __ ) ___ ___ | |_| | ___ __ _ __| | ___ _ __
# | _ \ / _ \ / _ \| __| |/ _ \ / _` |/ _` |/ _ \ '__|
# | |_) | (_) | (_) | |_| | (_) | (_| | (_| | __/ |
# |____/ \___/ \___/ \__|_|\___/ \__,_|\__,_|\___|_|
#
# Bootloader
# UEFI enabled GRUB2 setup
# with full disk encryption and swap with hibernation
# Bootloader
boot.loader = {
efi = {
canTouchEfiVariables = false;
efiSysMountPoint = "/boot";
};
grub = {
enable = true;
efiSupport = true;
extraEntriesBeforeNixOS = true;
efiInstallAsRemovable = true; # in case canTouchEfiVariables doesn't work for your system
device = "nodev";
useOSProber = true;
};
};
boot.kernelPackages = pkgs.linuxPackages_latest;
# extra enabled kernel modules
boot.kernelModules = [
"sg" # for generic SCSI devices such as /dev/sg0
"wireguard"
];
# Kernel parameter on boot
boot.kernelParams = [
"quiet"
"splash"
"psi=1"
"boot_delay=0"
];
# Setup keyfile
boot.initrd.secrets = {
"/crypto_keyfile.bin" = null;
};
}

277
configuration.nix Normal file
View File

@ -0,0 +1,277 @@
# 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-23.05.tar.gz";
# python packages to include with python3
python-packages = import ./python-packages.nix;
in
{
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
(import "${home-manager}/nixos")
./nix-settings.nix
./boot.nix
./users/servostar/user.nix
./.luks-swap.nix
./fonts.nix
];
hardware.bluetooth.enable = true;
hardware.opengl.enable = true;
# for rotation sensors
hardware.sensor.iio.enable = true;
# screen and keybord backlight
hardware.acpilight.enable = true;
networking.firewall.checkReversePath = false;
networking.hostName = "servostar-nixos-flex"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
networking.wireguard.enable = true;
# Enable networking
networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "Europe/Berlin";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "de_DE.UTF-8";
LC_IDENTIFICATION = "de_DE.UTF-8";
LC_MEASUREMENT = "de_DE.UTF-8";
LC_MONETARY = "de_DE.UTF-8";
LC_NAME = "de_DE.UTF-8";
LC_NUMERIC = "de_DE.UTF-8";
LC_PAPER = "de_DE.UTF-8";
LC_TELEPHONE = "de_DE.UTF-8";
LC_TIME = "de_DE.UTF-8";
};
# Enable the X11 windowing system.
services.xserver.enable = true;
services.rpcbind.enable = true; # needed for NFS
# Enable the KDE Plasma Desktop Environment.
services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
# set wayland as default session
services.xserver.displayManager.defaultSession = "plasmawayland";
programs.partition-manager.enable = true;
programs.zsh.enable = true;
# use bash shell for other users
environment.shells = with pkgs; [ bash ];
programs.dconf.enable = true;
programs.xwayland.enable = true;
xdg.portal.enable = true;
# exclude packages from plasma5
environment.plasma5.excludePackages = with pkgs.libsForQt5; [
elisa
oxygen
khelpcenter
kcolorpicker
];
# Configure keymap in X11
services.xserver = {
layout = "de";
xkbVariant = "";
};
# Configure console keymap
console.keyMap = "de";
# Enable CUPS to print documents.
services.printing.enable = true;
################################################
# __ ___ _ _ _ _ _
# \ \ / (_)_ __| |_ _ _ __ _| (_)___ __ _| |_(_) ___ _ __
# \ \ / /| | '__| __| | | |/ _` | | / __|/ _` | __| |/ _ \| '_ \
# \ V / | | | | |_| |_| | (_| | | \__ \ (_| | |_| | (_) | | | |
# \_/ |_|_| \__|\__,_|\__,_|_|_|___/\__,_|\__|_|\___/|_| |_|
#
# This sections enbales host virtualisation for:
# - KVM
# - Waydroid (android based on LineageOS)
# - Docker
################################################
# enable rootless docker for more security
virtualisation.docker.rootless = {
enable = true;
setSocketVariable = true;
};
# regulary clean unused docker images
virtualisation.docker.autoPrune.enable = true;
# add user teridax to docker group
users.extraGroups.docker.members = [ "servostar" ];
# KVM
virtualisation.libvirtd.enable = true;
# android container
virtualisation.waydroid.enable = true;
################################################
# ____ _ _
# | _ \(_)_ __ _____ _(_)_ __ ___
# | |_) | | '_ \ / _ \ \ /\ / / | '__/ _ \
# | __/| | |_) | __/\ V V /| | | | __/
# |_| |_| .__/ \___| \_/\_/ |_|_| \___|
# |_|
################################################
# 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;
};
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
programs.java.enable = true;
programs.steam = {
enable = true;
remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
};
hardware.opengl.driSupport32Bit = true; # Enables support for 32bit libs that steam uses
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
(python3.withPackages(python-packages))
virt-manager
distrobox
# Rust toolchain
rustup
libiconv
rust-analyzer
php
php.packages.composer
go
nodejs
sass
# embedded board development
platformio-core # toolchain manager for various microcontrollers
openocd # on-chip programming and debugging support
avrdude # esp32 and others support
libdvdcss
libaacs
libbdplus
libbluray
devbox
filelight
ffmpeg-full
openssl
imagemagick
gnumake
cmake
# Clipboard support for Wayland Session
# used by Vim/Neovim and etc.
wl-clipboard
# GNU Compiler Collection and toolchain
glibc
gcc
gdb
stdenv.cc
stdenv.cc.libc
stdenv.cc.libc_dev
pkg-config
fontconfig
# SCSI driver
sg3_utils
wineWowPackages.stable
winetricks
];
# 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;
services.udev.packages = [ pkgs.platformio ];
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
networking.firewall.allowedUDPPorts = [
51820 # wireguard client
];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# 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.05"; # Did you read the comment?
environment.sessionVariables = rec {
_JAVA_OPTIONS = "-Dawt.useSystemAAFontSettings=lcd";
# rust
CARGO_TERM_COLOR = "always";
RUST_BACKTRACE = "1";
# Wayland for electron Ozone
NIXOS_OZONE_WL = "1";
GTK_THEME = "Breeze-Dark";
};
}

49
fonts.nix Normal file
View File

@ -0,0 +1,49 @@
{ pkgs, ... }:
{
fonts = {
enableDefaultFonts = true;
# extra font packages
fonts = with pkgs; [
corefonts
noto-fonts
noto-fonts-cjk
noto-fonts-emoji
noto-fonts-lgc-plus
dejavu_fonts
liberation_ttf
mplus-outline-fonts.githubRelease
dina-font
proggyfonts
open-fonts
open-sans
gyre-fonts
font-awesome
source-han-sans
vistafonts
inconsolata # monospaced
vazir-fonts # persian font
unifont # some international languages
# nerd fonts
(nerdfonts.override {
fonts = [
"Hack"
"FiraCode"
"DroidSansMono"
];
})
];
fontDir.enable = true;
fontconfig = {
enable = true;
defaultFonts = {
serif = [ "Noto Serif" ];
sansSerif = [ "Noto Sans" ];
emoji = [ "Noto Color Emoji" ];
monospace = [ "Noto Sans Mono" "Noto Sans" "Noto Color Emoji" ];
};
};
};
}

34
nix-settings.nix Normal file
View File

@ -0,0 +1,34 @@
# ======================================================
# _ _ _
# | \ | (_)_ __
# | \| | \ \/ /
# | |\ | |> <
# |_| \_|_/_/\_\
#
# Configuration for nix
{ config, pkgs, lib, ... }:
let
unstableTarball = fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz;
in
{
# cleanup nix store after every build
nix.settings.auto-optimise-store = true;
# confgure garbage collector of nixos
# to run weekly
nix.gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
# enable unstable packages
nixpkgs.config = {
packageOverrides = pkgs: with pkgs; {
unstable = import unstableTarball {
config = config.nixpkgs.config;
};
};
};
}

35
nixos-build.sh Normal file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env sh
# prompt user the option to abort and not doing anything
printf "Continue copying files and bulding config (y/n)? "
read -r choice
case "$choice" in
y|Y )
echo "copying files..."
cp -rv nixos /etc
;;
n|N )
echo "aborting..."
exit 0
;;
* )
echo "invalid"
exit 1
;;
esac
case "$1" in
"switch" | "boot" | "dry-run")
echo "building config..."
nixos-rebuild "$1"
;;
"upgrade")
echo "upgrading nixos..."
nixos-rebuild --upgrade switch
;;
* )
echo "no option specified, not building config..."
;;
esac
echo "done"

15
python-packages.nix Normal file
View File

@ -0,0 +1,15 @@
ps: with ps;
[
pandas
requests
pygments
tkinter
numpy
setuptools
youtube-dl
pip
setuptools
ipykernel
scipy
gurobipy
]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
{
"window.titleBarStyle": "custom",
"git.autofetch": true,
"update.mode": "none",
"git.enableSmartCommit": true,
"workbench.iconTheme": "material-icon-theme",
"git.confirmSync": false,
"window.zoomLevel": 1,
"editor.fontFamily": "'DroidSansM Nerd Font Mono', 'Droid Sans Mono', 'monospace', monospace"
}

View File

@ -0,0 +1,76 @@
# Based on: https://starship.rs/presets/pastel-powerline.html
format = """
[](#a3aed2)\
[ ](bg:#a3aed2 fg:#090c0c)\
$username\
[](bg:#769ff0 fg:#a3aed2)\
$directory\
[](fg:#769ff0 bg:#394260)\
$git_branch\
$git_status\
[](fg:#394260 bg:#212736)\
$nodejs\
$rust\
$golang\
$php\
[](fg:#212736 bg:#1d2230)\
$time\
[ ](fg:#1d2230)"""
[username]
show_always = true
style_user = "bg:#a3aed2 fg:#090c0c"
style_root = "bg:#a3aed2 fg:#090c0c"
format = '[$user ]($style)'
disabled = false
[directory]
style = "fg:#e3e5e5 bg:#769ff0"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"
[directory.substitutions]
"Documents" = "󰈙 "
"Downloads" = " "
"Music" = " "
"Pictures" = " "
"Video" = " "
"Desktop" = " "
[git_branch]
symbol = ""
style = "bg:#394260"
format = '[[ $symbol $branch ](fg:#769ff0 bg:#394260)]($style)'
[git_status]
style = "bg:#394260"
format = '[[($all_status$ahead_behind )](fg:#769ff0 bg:#394260)]($style)'
[nodejs]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'
[rust]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'
[golang]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'
[php]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'
[time]
disabled = false
time_format = "%R" # Hour:Minute Format
style = "bg:#1d2230"
format = '[[  $time ](fg:#a0a9cb bg:#1d2230)]($style)'

248
users/servostar/user.nix Normal file
View File

@ -0,0 +1,248 @@
{ pkgs, config, ... }:
{
# ======================================================
# _ _
# | | | |___ ___ _ __
# | | | / __|/ _ \ '__|
# | |_| \__ \ __/ |
# \___/|___/\___|_|
#
# Configuration for user servostar
services.pcscd.enable = true; # enable support for smart cards
services.printing.enable = true;
services.avahi.enable = true;
# for a WiFi printer
services.avahi.openFirewall = true;
services.avahi.nssmdns = false; # Use the settings from below
# settings from avahi-daemon.nix where mdns is replaced with mdns4
system.nssModules = pkgs.lib.optional (!config.services.avahi.nssmdns) pkgs.nssmdns;
system.nssDatabases.hosts = with pkgs.lib; optionals (!config.services.avahi.nssmdns) (mkMerge [
(mkBefore [ "mdns4_minimal [NOTFOUND=return]" ]) # before resolve
(mkAfter [ "mdns4" ]) # after dns
]);
# Define a user account. Don't forget to set a password with passwd.
users.users.servostar = {
isNormalUser = true;
description = "adminstrator";
# member groups for this user
extraGroups = [
"networkmanager"
"wheel"
"libvirtd"
"dialout"
"tty"
"uucp"
"plugdev"
];
# use zsh
shell = pkgs.zsh;
# ------------------------------------------------------
# user packages
packages = with pkgs; [
# language server
shellcheck
lua-language-server
pyright
# browsers
librewolf
ungoogled-chromium
tor-browser-bundle-bin
# games
prismlauncher
# social media
discord
signal-desktop
# LaTeX and tlmgr
texlive.combined.scheme-full
godot_4
# command line tools
neofetch
lolcat
figlet
cowsay
cmatrix
exa # FIXME: use stable eza version when available
btop
htop
tmux
nvtop-amd
asciiquarium
pipes
tldr
ranger
nmap
busybox
tcpdump
onefetch # neofetch for git repositories
catimg
hollywood
efibootmgr
# less like program for listing a file with colors
# used as a replacement pager for colored man pages
most
lazygit
lazydocker
pandoc
yt-dlp
fzf
nyancat
hexedit
unzip
fd
wget
gzip
ripgrep
lua
okteta
kate
keepassxc
vlc
mpv
inkscape
krita
handbrake
libreoffice-qt
libsForQt5.kcalc
libsForQt5.ark
libsForQt5.ksystemlog
libsForQt5.kcharselect
libsForQt5.kget
libsForQt5.kclock
libsForQt5.breeze-gtk
libsForQt5.kpmcore
libsForQt5.kdenlive
libsForQt5.breeze-gtk
libsForQt5.kweather
libsForQt5.kompare
libsForQt5.skanpage
isoimagewriter
blender
obs-studio
tor
xournalpp
# Yubikey stuff
yubioath-flutter # Yubico authentictor app for managing accounts
yubikey-manager # CLI tool for ykman
yubikey-manager-qt # GUI tool for ykman
pcsclite
jetbrains-toolbox
];
};
# ------------------------------------------------------
# _ _
# | | | | ___ _ __ ___ ___ _ __ ___ __ _ _ __ __ _ __ _ ___ _ __
# | |_| |/ _ \| '_ ` _ \ / _ \ '_ ` _ \ / _` | '_ \ / _` |/ _` |/ _ \ '__|
# | _ | (_) | | | | | | __/ | | | | | (_| | | | | (_| | (_| | __/ |
# |_| |_|\___/|_| |_| |_|\___|_| |_| |_|\__,_|_| |_|\__,_|\__, |\___|_|
# |___/
home-manager.users.servostar = {
home = {
stateVersion = "23.05";
};
programs.vscode = {
enable = true;
package = pkgs.vscodium;
extensions = with pkgs.vscode-extensions; [
james-yu.latex-workshop
jnoortheen.nix-ide
pkief.material-icon-theme
rust-lang.rust-analyzer
bungcip.better-toml
mhutchie.git-graph
ms-azuretools.vscode-docker
ms-python.python
twxs.cmake
ms-python.vscode-pylance
];
};
programs.starship = {
enable = true;
enableZshIntegration = true;
};
programs.kitty = {
enable = true;
theme = "Tokyo Night";
shellIntegration.enableZshIntegration = true;
settings = {
update_check_interval = 0;
cursor_shape = "beam";
background_opacity = "0.85";
font_size = "12.0";
};
};
# ------------------------------------------------------
# Config files
xdg.configFile."starship.toml".source = config/starship.toml; # starship prompt configuration
xdg.configFile."VSCodium/User/settings.json".source = config/settings.json; # VSCodium settings
xdg.configFile."aacs/KEYDB.cfg".source = config/keydb.cfg; # key database for blueray decryption
# ------------------------------------------------------
# ZSH
programs.zsh = {
enable = true;
autocd = true;
completionInit = "autoload -U compinit";
initExtra = ''
export PAGER="most"
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=242"
'';
# Custom keybindings
initExtraFirst = ''
bindkey "^[[1;5C" emacs-forward-word
bindkey "^[[1;5D" emacs-backward-word
'';
enableCompletion = true;
enableAutosuggestions = true;
enableSyntaxHighlighting = true;
shellAliases = {
ls = "exa --icons";
};
history = {
size = 10000;
share = true;
};
zplug = {
enable = true;
plugins = [
{ name = "MichaelAquilina/zsh-you-should-use"; }
{ name = "akash329d/zsh-alias-finder"; }
{ name = "johannchangpro/zsh-interactive-cd"; }
{ name = "zsh-users/zsh-completions"; }
];
};
};
# ------------------------------------------------------
# git
programs.git = {
enable = true;
userName = "servostar";
userEmail = "sven.vogel123@web.de";
lfs.enable = true;
};
programs.command-not-found.enable = true;
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
};
};
}