nixos/share/common.nix

545 lines
13 KiB
Nix
Raw Normal View History

2023-01-15 18:56:16 +01:00
{ config, pkgs, ... }:
let
impermanence = builtins.fetchTarball "https://github.com/nix-community/impermanence/archive/master.tar.gz";
in
{
#
# stuff shared between home machines
#
2024-07-02 19:54:05 +02:00
# get impermanence working & include more shared parts
2023-01-15 18:56:16 +01:00
imports = [
# manage persistent files
"${impermanence}/nixos.nix"
2024-06-27 20:37:20 +02:00
# our users
"/nix/data/nixos/share/users.nix"
2023-01-15 18:56:16 +01:00
];
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
2023-06-09 18:26:35 +02:00
# on your system were taken. It's perfectly fine and recommended to leave
2023-01-15 18:56:16 +01:00
# 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).
2023-06-09 18:26:35 +02:00
system.stateVersion = "23.05"; # Did you read the comment?
2024-08-18 21:27:08 +02:00
# use the latest kernel
boot.kernelPackages = pkgs.linuxPackages_latest;
2023-01-15 18:56:16 +01:00
# don't check for split locks, for KVM and Co.
boot.kernelParams = [ "split_lock_detect=off" ];
2023-01-15 18:56:16 +01:00
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
2023-06-02 23:53:02 +02:00
# use a high resolution
boot.loader.systemd-boot.consoleMode = "max";
# we want to be able to do a memtest
boot.loader.systemd-boot.memtest86.enable = true;
2024-05-29 21:07:09 +02:00
# use systemd early
boot.initrd.systemd.enable = true;
2023-06-02 23:53:02 +02:00
# setup the console stuff early
console.earlySetup = true;
2024-07-15 22:16:22 +02:00
# boot splash
boot.plymouth.enable = true;
2023-10-24 20:17:19 +02:00
# swap to RAM
zramSwap.enable = true;
2024-05-29 21:07:09 +02:00
# root file system in RAM
2024-03-27 19:49:42 +01:00
fileSystems."/" =
2024-05-29 21:07:09 +02:00
{ device = "none";
fsType = "tmpfs";
2024-03-27 19:49:42 +01:00
neededForBoot = true;
2024-05-29 21:07:09 +02:00
options = [ "defaults" "size=8G" "mode=755" ];
2024-03-27 19:49:42 +01:00
};
# tmp on /nix to not fill RAM
fileSystems."/tmp" =
{ device = "/nix/tmp";
fsType = "none";
2024-03-27 19:49:42 +01:00
neededForBoot = true;
options = [ "bind" ];
depends = [ "/nix" ];
2024-03-27 19:49:42 +01:00
};
2024-05-29 22:34:18 +02:00
# bind mount to have user homes
2024-03-27 19:49:42 +01:00
fileSystems."/home" =
{ device = "/nix/data/home";
2024-03-27 19:49:42 +01:00
fsType = "none";
neededForBoot = true;
options = [ "bind" ];
depends = [ "/nix" ];
2024-03-27 19:49:42 +01:00
};
# bind mount to have root home
fileSystems."/root" =
{ device = "/nix/data/root";
2024-03-27 19:49:42 +01:00
fsType = "none";
neededForBoot = true;
options = [ "bind" ];
depends = [ "/nix" ];
2024-03-27 19:49:42 +01:00
};
# bind mount to have NixOS configuration, different per host
fileSystems."/etc/nixos" =
{ device = "/nix/data/nixos/${config.networking.hostName}";
2024-03-27 19:49:42 +01:00
fsType = "none";
neededForBoot = true;
options = [ "bind" ];
depends = [ "/nix" ];
2024-03-27 19:49:42 +01:00
};
2024-05-30 17:42:54 +02:00
# keep some stuff persistent
environment.persistence."/nix/persistent" = {
hideMounts = true;
directories = [
# user and group mappings
# Either "/var/lib/nixos" has to be persisted, or all users and groups must have a uid/gid specified. The following users are missing a uid
"/var/lib/nixos"
2024-05-30 17:42:54 +02:00
# systemd timers
2024-08-19 23:21:52 +02:00
"/var/lib/systemd/timers"
2024-05-30 17:42:54 +02:00
# alsa state for persistent sound settings
2024-08-19 23:21:52 +02:00
"/var/lib/alsa"
2024-07-04 18:52:50 +02:00
# NetworkManager connections
2024-08-19 23:21:52 +02:00
"/etc/NetworkManager"
"/var/lib/NetworkManager"
2024-05-30 17:42:54 +02:00
];
};
2024-07-12 19:35:16 +02:00
# kill the tmp content on reboots, we mount that to /nix/persistent to avoid memory fill-up
boot.tmp.cleanOnBoot = true;
2024-01-10 17:58:07 +01:00
# enable fast dbus
services.dbus.implementation = "broker";
2023-01-15 22:48:29 +01:00
# allow all firmware
hardware.enableAllFirmware = true;
# use NetworkManager, works well for WiFi, too
networking.networkmanager.enable = true;
2024-06-27 19:39:48 +02:00
# ensure firewall is up, allow ssh in
2023-01-15 22:48:29 +01:00
networking.firewall.enable = true;
2023-06-10 17:42:28 +02:00
networking.firewall.allowedTCPPorts = [ 22 ];
2023-01-15 18:56:16 +01:00
2023-06-09 18:26:35 +02:00
# OpenSSH daemon config
services.openssh = {
2024-04-03 23:42:36 +02:00
# enable with public key only auth, start on demand only
2023-05-02 19:32:11 +02:00
enable = true;
2024-04-03 23:42:36 +02:00
startWhenNeeded = true;
2024-01-11 23:45:38 +01:00
settings.PasswordAuthentication = false;
settings.KbdInteractiveAuthentication = false;
2023-06-09 18:26:35 +02:00
# only ed25519 keys, make them persistent
hostKeys = [{
path = "/nix/persistent/ssh_host_ed25519_key";
type = "ed25519";
}];
# only safe ciphers & Co.
settings.Ciphers = [ "aes256-gcm@openssh.com" ];
settings.KexAlgorithms = [ "sntrup761x25519-sha512@openssh.com" ];
settings.Macs = [ "hmac-sha2-512-etm@openssh.com" ];
2023-05-02 19:32:11 +02:00
};
2023-01-15 18:56:16 +01:00
# Set your time zone.
time.timeZone = "Europe/Berlin";
# default locale is English US
i18n.defaultLocale = "en_US.UTF-8";
# use German stuff for sorting/date/....
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";
};
2023-09-02 17:06:15 +02:00
# allow to have all locales
i18n.supportedLocales = [ "all" ];
# use X11/wayland layout for console, too
2023-10-21 21:31:26 +02:00
console.useXkbConfig = true;
2023-01-15 18:56:16 +01:00
2024-07-15 22:12:39 +02:00
# enable SDDM & the KDE Plasma Desktop Environment with Wayland
2024-03-27 07:40:25 +01:00
services.desktopManager.plasma6.enable = true;
2024-07-15 22:12:39 +02:00
services.displayManager.sddm = {
enable = true;
2024-07-15 22:12:39 +02:00
wayland.enable = true;
};
2023-01-15 18:56:16 +01:00
2023-05-20 22:37:33 +02:00
# enable sound with PipeWire
hardware.pulseaudio.enable = false;
2023-01-15 18:56:16 +01:00
services.pipewire = {
enable = true;
alsa = {
enable = true;
support32Bit = true;
};
2023-05-20 22:37:33 +02:00
pulse.enable = true;
2023-01-15 18:56:16 +01:00
};
# allow realtime
security.rtkit.enable = true;
# package manager config
nix = {
# auto optimize the store
settings.auto-optimise-store = true;
# cleanup the store from time to time
gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 7d";
};
2024-03-29 17:08:51 +01:00
# enable new stuff
settings.experimental-features = "nix-command flakes";
2023-05-20 16:18:12 +02:00
# https://github.com/nix-community/nix-direnv
extraOptions = ''
keep-outputs = true
keep-derivations = true
'';
2023-01-15 18:56:16 +01:00
};
2024-04-04 00:08:33 +02:00
# auto update
system.autoUpgrade = {
enable = true;
allowReboot = false;
};
# avoid suspend ever to be triggered
2023-01-15 18:56:16 +01:00
systemd.targets.sleep.enable = false;
systemd.targets.suspend.enable = false;
systemd.targets.hibernate.enable = false;
systemd.targets.hybrid-sleep.enable = false;
2024-07-08 18:35:39 +02:00
# save power
powerManagement.enable = true;
2024-08-12 21:19:46 +02:00
powerManagement.cpuFreqGovernor = "ondemand";
powerManagement.powertop.enable = true;
2024-07-08 18:35:39 +02:00
2024-05-26 22:55:46 +02:00
# allow unfree packages
2023-01-15 18:56:16 +01:00
nixpkgs.config.allowUnfree = true;
2024-05-26 22:55:46 +02:00
# we want DRM support
nixpkgs.config.chromium.enableWideVine = true;
2023-01-15 18:56:16 +01:00
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
2024-02-05 20:34:37 +01:00
pkgs.kdePackages.ark
2023-01-15 18:56:16 +01:00
aspellDicts.de
aspellDicts.en
2024-06-16 22:12:32 +02:00
bitwise
2023-01-15 18:56:16 +01:00
borgbackup
2023-03-23 20:50:35 +01:00
btop
calibre
2023-10-21 18:15:29 +02:00
chromium
2023-06-10 19:09:58 +02:00
clinfo
2023-09-16 16:54:02 +02:00
config.boot.kernelPackages.perf
2024-08-21 22:28:29 +02:00
delta
2024-06-16 20:53:26 +02:00
duf
2023-07-28 17:11:20 +02:00
efibootmgr
emacs
2024-06-26 19:16:56 +02:00
f2
2023-10-15 17:18:18 +02:00
fdupes
ffmpeg
2023-10-15 17:18:18 +02:00
file
2024-04-27 21:54:41 +02:00
fzf
2024-02-05 20:34:37 +01:00
pkgs.kdePackages.filelight
gimp
2023-01-15 18:56:16 +01:00
gitFull
2023-06-10 19:09:58 +02:00
glxinfo
go
2024-06-30 16:26:25 +02:00
gorilla-bin
2023-07-28 17:29:07 +02:00
gptfdisk
heaptrack
hotspot
hugo
2023-01-15 18:56:16 +01:00
hunspellDicts.de_DE
hunspellDicts.en_US
2023-10-15 17:18:18 +02:00
inetutils
2024-05-12 16:21:45 +02:00
inkscape
2024-02-05 20:34:37 +01:00
pkgs.kdePackages.kate
2024-04-04 00:00:17 +02:00
pkgs.kdePackages.kcachegrind
2024-02-05 20:34:37 +01:00
pkgs.kdePackages.kcalc
keychain
2024-02-05 20:34:37 +01:00
pkgs.kdePackages.kmail
pkgs.kdePackages.konsole
2024-06-16 20:53:26 +02:00
lazygit
libjxl
libreoffice
2023-06-10 19:09:58 +02:00
libva-utils
2023-01-15 18:56:16 +01:00
lsof
2024-07-07 16:40:50 +02:00
mailutils
2023-01-15 18:56:16 +01:00
mc
2024-06-25 22:35:22 +02:00
micro
2024-07-27 17:29:48 +02:00
mission-center
2024-08-15 17:49:55 +02:00
mplayer
2024-02-05 20:34:37 +01:00
pkgs.kdePackages.neochat
nixos-install-tools
nmap
2023-09-16 17:08:34 +02:00
nvme-cli
2024-07-07 16:40:50 +02:00
procmail
okteta
2024-02-05 20:34:37 +01:00
pkgs.kdePackages.okular
2023-08-06 19:41:42 +02:00
p7zip
2023-07-28 17:29:07 +02:00
parted
2023-10-15 17:18:18 +02:00
pciutils
2024-01-28 01:54:01 +01:00
pdftk
2024-06-16 20:53:26 +02:00
procs
pulseaudio
2024-05-30 11:18:56 +02:00
pwgen
qmk
2024-06-16 22:03:26 +02:00
ripgrep
2024-06-16 20:53:26 +02:00
scc
2023-12-29 12:43:35 +01:00
ssh-audit
2024-01-13 16:34:30 +01:00
sysstat
tcl
texlive.combined.scheme-small
tigervnc
tk
2024-06-16 20:53:26 +02:00
tldr
2024-02-05 20:34:37 +01:00
pkgs.kdePackages.tokodon
2023-06-10 17:02:24 +02:00
unrar
unzip
usbutils
valgrind
vlc
vscodium
2023-06-10 19:09:58 +02:00
vulkan-tools
wayland-utils
xorg.xlsclients
2024-04-27 21:54:41 +02:00
zoxide
2023-01-15 18:56:16 +01:00
zsh
];
# olm is insecure
nixpkgs.config.permittedInsecurePackages = [
"olm-3.2.16"
];
2023-10-22 17:56:24 +02:00
# run browsers in a sandbox
2023-10-21 18:15:29 +02:00
programs.firejail = {
enable = true;
2023-10-21 19:22:49 +02:00
2023-10-21 18:15:29 +02:00
wrappedBinaries = {
chromium = {
executable = "${pkgs.lib.getBin pkgs.chromium}/bin/chromium";
profile = "${pkgs.firejail}/etc/firejail/chromium.profile";
};
2023-10-21 19:22:49 +02:00
2023-10-21 18:15:29 +02:00
firefox = {
executable = "${pkgs.lib.getBin pkgs.firefox}/bin/firefox";
profile = "${pkgs.firejail}/etc/firejail/firefox.profile";
};
signal-desktop = {
executable = "${pkgs.signal-desktop}/bin/signal-desktop";
profile = "${pkgs.firejail}/etc/firejail/signal-desktop.profile";
};
2023-10-21 18:08:29 +02:00
};
};
2023-10-21 19:22:49 +02:00
2023-10-21 18:15:29 +02:00
# chromium needs programs.firefox.enable here and systemPackages entry to have icon and work
2023-10-15 16:27:54 +02:00
programs.chromium.enable = true;
2023-10-21 19:22:49 +02:00
2023-10-21 18:15:29 +02:00
# firefox needs programs.firefox.enable here but no systemPackages entry to have icon and work
2023-10-15 16:27:54 +02:00
programs.firefox.enable = true;
# Flatpak to sandbox Steam, Bottles and Co.
#
# flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
# flatpak install --user flathub com.usebottles.bottles
# flatpak install --user flathub com.valvesoftware.Steam
2023-12-07 18:58:23 +01:00
# flatpak update --user
#
services.flatpak.enable = true;
2023-01-15 18:56:16 +01:00
# allow keyboard configure tools to work
2023-05-20 23:22:25 +02:00
hardware.keyboard.qmk.enable = true;
2023-01-15 18:56:16 +01:00
# add ~/bin to PATH
environment.homeBinInPath = true;
2024-08-04 16:25:50 +02:00
# fonts for all users
2023-01-15 18:56:16 +01:00
fonts = {
2024-08-04 16:25:50 +02:00
# no default fonts
enableDefaultPackages = false;
2024-04-04 00:03:20 +02:00
2024-07-21 15:41:29 +02:00
# ensure we have an emulated global fontdir
2024-08-04 22:51:42 +02:00
fontDir = {
enable = true;
decompressFonts = true;
};
2024-07-21 15:41:29 +02:00
2024-08-16 19:07:14 +02:00
# get a small list of curated fonts
# internet hints
# https://biz-mastercreationz.medium.com/the-7-must-have-fonts-for-ruling-ui-ux-design-in-2024-e98c3b8ede31
# https://www.untitledui.com/blog/best-free-fonts
# https://medium.com/@iamakashjaggi/the-5-best-google-serif-fonts-of-2024-d1505543cb02
# https://www.halo-lab.com/blog/best-serif-fonts
# https://hootdesigncompany.com/resources/best-serif-google-fonts
# https://muz.li/blog/best-free-google-fonts
packages = with pkgs; [
# good sans serif fonts
aileron
2024-08-20 00:11:46 +02:00
cabin
2024-08-16 19:07:14 +02:00
dm-sans
fira-sans
hubot-sans
inter
2024-08-22 17:32:50 +02:00
kanit-font
2024-08-16 19:07:14 +02:00
lato
lexend
manrope
mona-sans
montserrat
nacelle
open-sans
2024-08-17 00:51:56 +02:00
paratype-pt-sans
2024-08-16 19:07:14 +02:00
public-sans
roboto
source-sans
work-sans
# good serif fonts
alegreya
crimson
eb-garamond
fraunces
libre-baskerville
libre-bodoni
libre-caslon
merriweather
oldstandard
paratype-pt-serif
2024-08-17 00:51:56 +02:00
roboto-serif
source-serif
2024-08-16 19:07:14 +02:00
# monospace coding and terminal fonts
2024-08-20 00:11:46 +02:00
_0xproto
2024-08-21 23:18:57 +02:00
anonymousPro
cascadia-code
2024-08-20 00:11:46 +02:00
commit-mono
2024-08-21 23:18:57 +02:00
fantasque-sans-mono
fira-code
2024-08-20 00:11:46 +02:00
geist-font
2024-08-21 23:18:57 +02:00
hack-font
hasklig
inconsolata
2024-08-21 22:25:53 +02:00
jetbrains-mono
2024-08-21 23:18:57 +02:00
julia-mono
2024-08-21 22:25:53 +02:00
maple-mono
2024-08-20 23:20:36 +02:00
martian-mono
2024-08-21 23:18:57 +02:00
meslo-lg
2024-08-20 21:35:53 +02:00
monaspace
2024-08-21 23:18:57 +02:00
monoid
2024-08-20 00:11:46 +02:00
mononoki
paratype-pt-mono
recursive
2024-08-21 23:18:57 +02:00
roboto-mono
2024-08-20 00:11:46 +02:00
source-code-pro
2024-08-21 23:18:57 +02:00
victor-mono
# fonts with good unicode coverage as fallback
2024-08-20 00:11:46 +02:00
ibm-plex
2024-08-16 19:07:14 +02:00
noto-fonts
noto-fonts-cjk-sans
noto-fonts-cjk-serif
noto-fonts-lgc-plus
# emoji in Farbe und bunt
noto-fonts-color-emoji
];
2024-08-13 20:10:44 +02:00
# use some proper default fonts
2023-01-15 18:56:16 +01:00
fontconfig = {
2024-08-04 22:51:42 +02:00
enable = true;
2023-01-15 18:56:16 +01:00
defaultFonts = {
2024-08-16 19:07:14 +02:00
emoji = [ "Noto Color Emoji" ];
2024-08-20 21:35:53 +02:00
monospace = [ "Monaspace Argon" "IBM Plex Mono" "Noto Sans Mono" ];
2024-08-20 00:11:46 +02:00
sansSerif = [ "Lexend" "IBM Plex Sans" "Noto Sans" ];
serif = [ "Crimson" "IBM Plex Serif" "Noto Serif" ];
2023-01-15 18:56:16 +01:00
};
};
};
# OpenGL
2024-06-21 23:46:35 +02:00
hardware.graphics.enable = true;
2023-01-15 18:56:16 +01:00
2023-02-06 20:20:40 +01:00
# try to ensure we can use our network LaserJet
2023-01-15 18:56:16 +01:00
services.printing.enable = true;
services.printing.drivers = [ pkgs.hplip ];
# dconf is needed for gtk, see https://nixos.wiki/wiki/KDE
programs.dconf.enable = true;
# https://nixos.wiki/wiki/Chromium - Wayland support on
environment.sessionVariables.NIXOS_OZONE_WL = "1";
2024-07-07 16:40:50 +02:00
# ensure machine can send mails
services.opensmtpd = {
2024-04-04 00:00:17 +02:00
enable = true;
setSendmail = true;
2024-07-07 16:40:50 +02:00
serverConfiguration = ''
table aliases file:/etc/mail/aliases
table secrets file:/etc/mail/secrets
2024-07-07 18:10:47 +02:00
listen on localhost
2024-07-07 16:40:50 +02:00
action "local" mda "procmail -f -" virtual <aliases>
action "relay" relay host smtps://smtp@moon.babylon2k.com auth <secrets> mail-from bot@cullmann.io
match for local action "local"
match for any action "relay"
'';
};
environment.etc."mail/aliases" = {
text = "@ christoph@cullmann.io";
mode = "0400";
};
environment.etc."mail/secrets" = {
text = builtins.readFile "/nix/data/nixos/mail.secret";
2024-07-07 16:40:50 +02:00
mode = "0400";
2024-04-04 00:00:17 +02:00
};
2023-01-15 18:56:16 +01:00
# use ZSH per default
programs.zsh.enable = true;
environment.shells = with pkgs; [ zsh ];
# needed for the ZSH completion
environment.pathsToLink = [ "/share/zsh" ];
2024-06-27 23:25:42 +02:00
2024-06-25 22:35:22 +02:00
# use micro as default terminal editor
environment.variables.EDITOR = "micro";
2023-10-23 19:55:37 +02:00
# enable VirtualBox
2023-01-15 18:56:16 +01:00
virtualisation.virtualbox.host.enable = true;
2024-08-12 21:19:46 +02:00
#virtualisation.virtualbox.host.enableKvm = true;
2024-05-26 16:58:37 +02:00
virtualisation.virtualbox.host.enableHardening = false;
virtualisation.virtualbox.host.addNetworkInterface = false;
2023-01-15 18:56:16 +01:00
2023-01-16 00:03:51 +01:00
# configure sudo
security.sudo.execWheelOnly = true;
security.sudo.extraConfig = ''
Defaults lecture = never
'';
2023-01-15 18:56:16 +01:00
}