migrate configuration.nix into flexible modular flake setup

This commit is contained in:
2025-06-03 19:17:51 +02:00
parent 44dc0edf96
commit 7633c55ed7
9 changed files with 300 additions and 300 deletions

112
modules/common.nix Normal file
View File

@ -0,0 +1,112 @@
{ config, pkgs, ... }:
{
imports = [
./desktop.nix
./users.nix
./programs.nix
];
# Bootloader.
boot = {
loader.systemd-boot.enable = true;
loader.efi.canTouchEfiVariables = true;
initrd.kernelModules = [ "amdgpu" ];
kernelPackages = pkgs.linuxPackages_latest;
};
# Enable networking
networking.networkmanager.enable = true;
# Network security
# enable firewall and block all ports
networking.firewall.enable = true;
# disable coredump that could be exploited later
# and also slow down the system when something crash
systemd.coredump.enable = false;
# Set your time zone.
time.timeZone = "Europe/Stockholm";
# Select internationalisation properties.
i18n.defaultLocale = "en_GB.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "sv_SE.UTF-8";
LC_IDENTIFICATION = "sv_SE.UTF-8";
LC_MEASUREMENT = "sv_SE.UTF-8";
LC_MONETARY = "sv_SE.UTF-8";
LC_NAME = "sv_SE.UTF-8";
LC_NUMERIC = "sv_SE.UTF-8";
LC_PAPER = "sv_SE.UTF-8";
LC_TELEPHONE = "sv_SE.UTF-8";
LC_TIME = "sv_SE.UTF-8";
};
# Configure console keymap
console.keyMap = "sv-latin1";
# Enable CUPS to print documents.
services.printing.enable = false;
# Enable sound with pipewire.
services.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# Enable Flakes
nix.settings.experimental-features = [ "nix-command" "flakes" ];
# Automatic system upgrades
system.autoUpgrade = {
enable = true;
flake = inputs.self.outPath;
flags = [
"--update-input"
"nixpkgs"
"-L" # print build logs
];
dates = "02:00";
randomizedDelaySec = "45min";
};
# Fonts
fonts.packages = with pkgs; [
intel-one-mono
];
# create system-wide executables firefox and chromium
# that will wrap the real binaries so everything work out of the box.
# enable firejail
programs.firejail = {
enable = true;
wrappedBinaries = {
firefox = {
executable = "${pkgs.lib.getBin pkgs.firefox}/bin/firefox";
profile = "${pkgs.firejail}/etc/firejail/firefox.profile";
};
chromium = {
executable = "${pkgs.lib.getBin pkgs.chromium}/bin/chromium";
profile = "${pkgs.firejail}/etc/firejail/chromium.profile";
};
};
};
# enable antivirus clamav and keep the signatures' database updated
services.clamav.daemon.enable = true;
services.clamav.updater.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.
system.stateVersion = "23.11";
}

18
modules/desktop.nix Normal file
View File

@ -0,0 +1,18 @@
{ config, pkgs, ... }:
{
services.xserver = {
# Enable the X11 windowing system.
enable = true;
# Enable the GNOME Desktop Environment.
displayManager.gdm.enable = true;
desktopManager.gnome.enable = true;
# Configure keymap in X11
xkb = {
layout = "se";
variant = "";
};
};
}

106
modules/programs.nix Normal file
View File

@ -0,0 +1,106 @@
{ config, pkgs, ... }:
{
# Common packages for ALL systems
environment.systemPackages = with pkgs; [
# networking
wget
whois
dig
# files
unzip
ncdu
# security
gnupg
openssl
kdePackages.kleopatra
# cli tools
jq
pciutils
glxinfo
btop
# Development
code-cursor
gitkraken
git-filter-repo
python3
hugo
nodejs_22
pnpm
cypress
gnumake
gcc
libgcc
# Common programs
obsidian
nextcloud-client
multiviewer-for-f1
libreoffice-fresh
tor-browser
wasabiwallet
ungoogled-chromium
prismlauncher
plexamp
mission-center
remmina
# Visual
inkscape
krita
darktable
davinci-resolve
imagemagick
];
programs = {
# CLI
zoxide.enable = true;
fish.enable = true;
vim = {
enable = true;
defaultEditor = true;
};
ssh.extraConfig = "";
gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
git = {
enable = true;
lfs.enable = true;
};
java.enable = true;
# programs
firefox.enable = true;
thunderbird.enable = true;
steam = {
enable = true;
remotePlay.openFirewall = true;
dedicatedServer.openFirewall = true;
};
};
# enable and configure Docker
virtualisation.docker.enable = true;
# enable VMs
programs.virt-manager.enable = true;
virtualisation = {
tmp.enable = true;
libvirtd = {
enable = true;
qemu = {
swtpm.enable = true;
ovmf.enable = true;
ovmf.packages = [ pkgs.OVMFFull.fd ];
};
};
spiceUSBRedirection.enable = true;
};
}

14
modules/users.nix Normal file
View File

@ -0,0 +1,14 @@
{ config, pkgs, ... }:
{
# Define the main user account
users = {
users.schulze = {
isNormalUser = true;
description = "Felix Schulze";
extraGroups = [ "networkmanager" "wheel" "docker" ];
shell = pkgs.fish;
};
groups.libvirtd.members = ["schulze"];
};
}