Refactor: czysta separacja system/user, moduł Tibii jako shared home-manager

[HermesAI]

Główne zmiany:

1. Separacja pakietów (best practice 2025+):
   - base.nix: tylko konfiguracja Nix-a (gc, flakes, allowUnfree), zero pakietów
   - home.nix: wszystkie pakiety użytkownika (brave, neovim, git, lutris, itd.)
   - NixOS modules (plasma.nix, gaming.nix): tylko enable serwisów, bez pakietów

2. Tibia jako shared home-manager module:
   - modules/home/tibia.nix — opcja programs.tibia.enable dostępna dla każdego usera
   - Rejestracja przez home-manager.sharedModules w flake.nix
   - packages/libxml2-2.9/ — osobny callPackage zamiast inline build
   - Nowe: tibia-install (pobiera launcher na świeżym systemie), .desktop entry
   - tibia-patch: check "already patched", quoted heredoc (bez expandowania $@)
   - Poprawiona ścieżka do tibia-client (store path przez ${...} zamiast /run/...)

3. Porządki:
   - Usunięte puste moduły (3dmodel, 3dprint, network, office) — pakiety w home.nix
   - hosts/nix-latitude/configuration.nix: usunięty duplikat hostname, packages z usera
   - flake.nix: home-manager spięty do nixos-unstable, usunięty brakujący host nix-gaming
   - .gitignore: result, .direnv, *.swp

UWAGA: Wymaga nix flake lock na maszynie NixOS po pull.
Nowy user: programs.tibia.enable = true w home.nix + tibia-install.
This commit is contained in:
Sasza Stanczew 2026-05-30 23:07:03 +02:00
parent 80c904edfd
commit 1a2966e054
13 changed files with 266 additions and 159 deletions

13
.gitignore vendored Normal file
View file

@ -0,0 +1,13 @@
# Nix build artifacts
result
result-*
# Direnv
.direnv
# IDE / edytory
.aider*
# Systemowe pliki tymczasowe
*.swp
*.swo

View file

@ -1,21 +1,18 @@
{ pkgs, ... }: {
# Włączamy Flakes
# === Włączamy Flakes ===
nix.settings.experimental-features = [ "nix-command" "flakes" ];
# paczki systemowe
environment.systemPackages = with pkgs; [
file
tree
wget
git
openssh
neovim
keepassxc
nextcloud-client
tmux
unzip
];
# === Automatyczne sprzątanie store ===
nix.gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
# === Optymalizacja store (deduplikacja) ===
nix.settings.auto-optimise-store = true;
# === Pozwalamy na niewolne pakiety ===
nixpkgs.config.allowUnfree = true;
}

View file

@ -2,25 +2,24 @@
description = "Konfiguracja wielu maszyn na raz";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; # Bleeding edge!
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
url = "github:nix-community/home-manager/nixos-unstable";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, home-manager, ... }:
let # pomocnicza funkcja
let
mk_system = system: hostname: modules: nixpkgs.lib.nixosSystem {
inherit system;
modules = [
{ networking.hostName = hostname; }
# base configuration
./base.nix
# home manager
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.sharedModules = [ ./modules/home/tibia.nix ];
home-manager.users.sasza = import ./home.nix;
}
] ++ modules;
@ -30,22 +29,6 @@
nix-latitude = mk_system "x86_64-linux" "nix-latitude" [
./hosts/nix-latitude/configuration.nix
./modules/plasma.nix
./modules/3dmodel.nix
#./modules/network.nix
#./modules/office.nix
./modules/tibia.nix
./modules/multimedia.nix
];
nix-gaming = mk_system "x86_64-linux" "nix-gaming" [
./hosts/nix-gaming/configuration.nix
./modules/plasma.nix
./modules/gaming.nix
./modules/network.nix
# ./modules/office.nix
./modules/3dmodel.nix
./modules/3dprint.nix
./modules/multimedia.nix
];
};
};

View file

@ -3,18 +3,55 @@
home.homeDirectory = "/home/sasza";
home.packages = with pkgs; [
# Przeglądarki
brave
# Narzędzia CLI
neovim
git
htop
glances
tree
wget
openssh
# Modelowanie 3D
openscad-unstable
# Druk 3D
orca-slicer
# Gry
lutris
# Sieć / VPN
eddie
wireguard-tools
qbittorrent
# Biuro
libreoffice-fresh
# KDE
kdePackages.kate
# Dodane z remote
file
keepassxc
nextcloud-client
tmux
unzip
vlc
];
# Przykład prostej konfiguracji Git
programs.git = {
enable = true;
settings.user.name = "Sasza Stanczew";
settings.user.email = "sasza@stanczew.com";
};
programs.tibia.enable = true;
programs.home-manager.enable = true;
home.stateVersion = "24.11";
home.stateVersion = "25.11";
}

View file

@ -1,38 +1,25 @@
# 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, ... }:
{
imports =
[ # Include the results of the hardware scan.
imports = [
./hardware-configuration.nix
];
# Bootloader.
# Bootloader
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# Use latest kernel.
# Use latest kernel
boot.kernelPackages = pkgs.linuxPackages_latest;
networking.hostName = "nix-latitude"; # 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";
# Enable networking
networking.networkmanager.enable = true;
# Set your time zone.
# Timezone
time.timeZone = "Europe/Warsaw";
# Select internationalisation properties.
# Locale
i18n.defaultLocale = "pl_PL.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "pl_PL.UTF-8";
LC_IDENTIFICATION = "pl_PL.UTF-8";
@ -45,45 +32,16 @@
LC_TIME = "pl_PL.UTF-8";
};
# Configure console keymap
# Console keymap
console.keyMap = "pl2";
# Define a user account. Don't forget to set a password with passwd.
# User account (pakiety w home-manager)
users.users.sasza = {
isNormalUser = true;
description = "Sasza Stanczew";
extraGroups = [ "networkmanager" "wheel" ];
packages = with pkgs; [
kdePackages.kate
# thunderbird
];
};
# 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;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# 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. Its 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 = "25.11"; # Did you read the comment?
# State version
system.stateVersion = "25.11";
}

View file

@ -1,7 +0,0 @@
{ pkgs, ... }: {
# paczki
environment.systemPackages = with pkgs; [
openscad-unstable
];
}

View file

@ -1,7 +0,0 @@
{ pkgs, ... }: {
# paczki
environment.systemPackages = with pkgs; [
orca-slicer
];
}

View file

@ -1,13 +1,9 @@
{ pkgs, ... }: {
# Grafika AMD i Steam
# Akceleracja grafiki (AMD/Intel)
hardware.graphics.enable = true;
hardware.graphics.enable32Bit = true;
# Steam
programs.steam.enable = true;
# paczki
environment.systemPackages = with pkgs; [
lutris
];
}

153
modules/home/tibia.nix Normal file
View file

@ -0,0 +1,153 @@
{ config, pkgs, lib, ... }:
let
cfg = config.programs.tibia;
# Legacy libxml2 (2.9.x) — wymagany przez Tibię, usunięty z nixpkgs-unstable
libxml2_2_9 = pkgs.callPackage ../../packages/libxml2-2.9 { };
# Wspólne ścieżki bibliotek
tibiaLibPath = lib.makeLibraryPath [
pkgs.nss
pkgs.nspr
pkgs.libxkbfile
libxml2_2_9
];
# Helper: eksport LD_LIBRARY_PATH
exportLibs = ''
export LD_LIBRARY_PATH="${tibiaLibPath}:$LD_LIBRARY_PATH"
'';
# Wrapper dla właściwego clienta (uruchamiany przez Tibia package.json)
tibiaClientWrapper = pkgs.writeShellScriptBin "tibia-client" ''
#!/usr/bin/env bash
${exportLibs}
exec steam-run "$HOME/.local/share/CipSoft GmbH/Tibia/packages/Tibia/bin/client" "$@"
'';
# Patchuje package.json Tibii żeby używała wrappera zamiast surowego binary
tibiaPatcher = pkgs.writeShellScriptBin "tibia-patch" ''
#!/usr/bin/env bash
set -e
PKGDIR="$HOME/.local/share/CipSoft GmbH/Tibia/packages/Tibia"
PKGJSON="$PKGDIR/package.json"
LOCALWRAPPER="$PKGDIR/tibia-client-wrapper"
if [ ! -f "$PKGJSON" ]; then
echo "package.json not found run the launcher once first."
exit 0
fi
if grep -q "tibia-client-wrapper" "$PKGJSON" 2>/dev/null; then
echo "Already patched."
exit 0
fi
cat > "$LOCALWRAPPER" <<'TIBIA_WRAPPER'
#!/usr/bin/env bash
${exportLibs}
exec ${tibiaClientWrapper}/bin/tibia-client "$@"
TIBIA_WRAPPER
chmod +x "$LOCALWRAPPER"
sed -i 's#"executable": "bin/client"#"executable": "tibia-client-wrapper"#' "$PKGJSON"
echo "Tibia client patched to use tibia-client-wrapper."
'';
# Uruchamia launcher Tibii (pobrany ręcznie przez tibia-install)
tibiaLauncherWrapper = pkgs.writeShellScriptBin "tibia" ''
#!/usr/bin/env bash
set -e
LAUNCHER="$HOME/Gry/Tibia/Tibia"
if [ ! -x "$LAUNCHER" ]; then
echo "Tibia launcher not found at:"
echo " $LAUNCHER"
echo ""
echo "Run 'tibia-install' first, or download manually from:"
echo " https://www.tibia.com/download/"
exit 1
fi
tibia-patch
${exportLibs}
exec steam-run "$LAUNCHER"
'';
# Pomija launcher, odpala clienta bezpośrednio
tibiaDirect = pkgs.writeShellScriptBin "tibia-direct" ''
#!/usr/bin/env bash
CLIENT="$HOME/.local/share/CipSoft GmbH/Tibia/packages/Tibia/bin/client"
if [ ! -x "$CLIENT" ]; then
echo "Tibia client not found."
echo "Run 'tibia' once so the launcher downloads the client."
exit 1
fi
${exportLibs}
exec steam-run "$CLIENT"
'';
# Instaluje launcher Tibii na nowym systemie
tibiaInstall = pkgs.writeShellScriptBin "tibia-install" ''
#!/usr/bin/env bash
set -e
URL="https://static.tibia.com/download/tibia.x64.tar.gz"
DEST="$HOME/Gry/Tibia"
TMPDIR=$(mktemp -d)
trap "rm -rf $TMPDIR" EXIT
echo "Downloading Tibia launcher from $URL ..."
if command -v wget &>/dev/null; then
wget -q --show-progress -O "$TMPDIR/tibia.tar.gz" "$URL"
elif command -v curl &>/dev/null; then
curl -# -L -o "$TMPDIR/tibia.tar.gz" "$URL"
else
echo "Neither wget nor curl found."
exit 1
fi
mkdir -p "$DEST"
tar xzf "$TMPDIR/tibia.tar.gz" -C "$DEST"
chmod +x "$DEST/Tibia"
echo ""
echo "Tibia launcher installed to: $DEST/Tibia"
echo "Run 'tibia' to start."
'';
# .desktop entry
tibiaDesktop = pkgs.makeDesktopItem {
name = "tibia";
exec = "tibia-direct";
desktopName = "Tibia";
comment = "Tibia MMORPG Client";
categories = [ "Game" ];
};
in {
options.programs.tibia = {
enable = lib.mkEnableOption "Tibia game client support";
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
steam-run
libxml2_2_9
tibiaClientWrapper
tibiaPatcher
tibiaLauncherWrapper
tibiaDirect
tibiaInstall
tibiaDesktop
];
};
}

View file

@ -1,9 +0,0 @@
{ pkgs, ... }: {
# paczki
environment.systemPackages = with pkgs; [
eddie
wireguard-tools
qbittorrent
];
}

View file

@ -1,7 +0,0 @@
{ pkgs, ... }: {
# paczki
environment.systemPackages = with pkgs; [
libreoffice-fresh
];
}

View file

@ -1,26 +1,23 @@
{ pkgs, ... }: {
# Enable the X11 windowing system.
# You can disable this if you're only using the Wayland session.
# Enable X11 (można wyłączyć przy czystym Waylandzie)
services.xserver.enable = true;
# Enable the KDE Plasma Desktop Environment.
services.displayManager = {
# KDE Plasma 6 + SDDM z autologinem
services.displayManager.sddm.enable = true;
services.displayManager.autoLogin = {
enable = true;
autoLogin = {
enable = true;
user = "sasza"; # ← Twój username
};
user = "sasza";
};
services.desktopManager.plasma6.enable = true;
# Configure keymap in X11
# Polski układ klawiatury w X11
services.xserver.xkb = {
layout = "pl";
variant = "";
};
# Enable sound with pipewire.
# Dźwięk — PipeWire zamiast PulseAudio
services.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
@ -28,23 +25,5 @@
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;
};
# paczki graficzne
environment.systemPackages = with pkgs; [
brave
];
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
# Install firefox.
# programs.firefox.enable = true;
}

21
packages/libxml2-2.9/default.nix vendored Normal file
View file

@ -0,0 +1,21 @@
{ stdenv, fetchurl, pkg-config, zlib, xz }:
stdenv.mkDerivation {
pname = "libxml2";
version = "2.9.14";
src = fetchurl {
url = "https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.14.tar.xz";
sha256 = "sha256-YNdKJX0czsBHXnScui8hVZ5IE577pv8oIkNXx8eY3+4=";
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [ zlib xz ];
configureFlags = [
"--disable-static"
"--without-python"
];
enableParallelBuilding = true;
}