Refactoring the config

This commit is contained in:
Lyes Saadi 2024-11-10 18:06:07 +01:00
parent 9c3fc1879c
commit 0e866b1cb0
No known key found for this signature in database
GPG key ID: 17418538BAA17767
24 changed files with 355 additions and 304 deletions

12
flake.lock generated
View file

@ -39,11 +39,11 @@
}, },
"nixos-hardware": { "nixos-hardware": {
"locked": { "locked": {
"lastModified": 1730886862, "lastModified": 1730919458,
"narHash": "sha256-wCZtRGM1NGxq6VG4+TMzfsa4cuG2VJVtowtYuWW5W3g=", "narHash": "sha256-yMO0T0QJlmT/x4HEyvrCyigGrdYfIXX3e5gWqB64wLg=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixos-hardware", "repo": "nixos-hardware",
"rev": "90642a0deae927fa911d49d4f7c5616257105141", "rev": "e1cc1f6483393634aee94514186d21a4871e78d7",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -55,11 +55,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1730741070, "lastModified": 1730963269,
"narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=", "narHash": "sha256-rz30HrFYCHiWEBCKHMffHbMdWJ35hEkcRVU0h7ms3x0=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "d063c1dd113c91ab27959ba540c0d9753409edf3", "rev": "83fb6c028368e465cd19bb127b86f971a5e41ebc",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -16,22 +16,35 @@
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = attrs; specialArgs = attrs;
modules = [ modules = [
./general/configuration.nix ./hosts/lyes-pc
./users/lyes
./modules
./modules/desktop
./modules/gaming
./modules/nvidia
./modules/specialisations/old-kernel.nix
nix-flatpak.nixosModules.nix-flatpak nix-flatpak.nixosModules.nix-flatpak
./specific/lyes-pc/configuration.nix
nixos-hardware.nixosModules.lenovo-thinkpad-x1-extreme-gen4 nixos-hardware.nixosModules.lenovo-thinkpad-x1-extreme-gen4
]; ];
}; };
iso = nixpkgs.lib.nixosSystem { desktop-iso = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = attrs; specialArgs = attrs;
modules = [ modules = [
./general/configuration.nix ./hosts/iso
./modules
./modules/desktop
./modules/gaming
./modules/nvidia
nix-flatpak.nixosModules.nix-flatpak nix-flatpak.nixosModules.nix-flatpak
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
"${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix" "${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix"
./specific/iso/configuration.nix
]; ];
}; };
}; };

View file

@ -1,59 +0,0 @@
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
# Utilities
neovim
helix
wget
ripgrep
eza
bat
tree
dust
pciutils
man-pages
man-pages-posix
python3
any-nix-shell
libcgroup
nushell
# Virtualization
qemu
virt-manager
# Printing
hplipWithPlugin
];
fonts = {
enableDefaultPackages = true;
packages = with pkgs; [
noto-fonts
noto-fonts-cjk-sans
noto-fonts-lgc-plus
noto-fonts-emoji
cantarell-fonts
twitter-color-emoji
(nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
];
fontDir.enable = true;
fontconfig = {
defaultFonts = {
sansSerif = [ "Cantarell" "Noto Sans" ];
monospace = [ "JetBrainsMono Nerd Font" ];
emoji = [ "Twitter Color Emoji" "Noto Color Emoji" ];
};
};
};
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
}

View file

@ -1,47 +0,0 @@
{ lib, pkgs, ... }:
{
specialisation = {
old-kernel.configuration = {
boot.kernelPackages = lib.mkForce pkgs.linuxPackages_6_1;
};
gaming.configuration = {
hardware.nvidia = {
prime.sync.enable = lib.mkForce true;
prime.offload = {
enable = lib.mkForce false;
enableOffloadCmd = lib.mkForce false;
};
};
};
kde.configuration = {
# GNOME
services.xserver.displayManager.gdm.enable = lib.mkForce false;
services.xserver.desktopManager.gnome.enable = lib.mkForce false;
# KDE
services.desktopManager.plasma6.enable = true;
services.displayManager.sddm.enable = true;
};
kde-gaming.configuration = {
hardware.nvidia = {
prime.sync.enable = lib.mkForce true;
prime.offload = {
enable = lib.mkForce false;
enableOffloadCmd = lib.mkForce false;
};
};
# GNOME
services.xserver.displayManager.gdm.enable = lib.mkForce false;
services.xserver.desktopManager.gnome.enable = lib.mkForce false;
# KDE
services.desktopManager.plasma6.enable = true;
services.displayManager.sddm.enable = true;
};
};
}

View file

@ -17,5 +17,5 @@ in {
networking.hostName = "lyes-iso"; networking.hostName = "lyes-iso";
networking.wireless.enable = lib.mkForce false; networking.wireless.enable = lib.mkForce false;
services.displayManager.autoLogin.user = lib.mkForce "lyes"; # services.displayManager.autoLogin.user = lib.mkForce "lyes";
} }

View file

@ -1,19 +1,35 @@
{ pkgs, ... }: { ... }:
{ {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
]; ];
# Networking
networking.hostName = "lyes-pc";
# Kernel
# boot.kernelPackages = pkgs.linuxPackages_latest; # boot.kernelPackages = pkgs.linuxPackages_latest;
# Boot # Boot
boot.loader.systemd-boot.enable = true;
boot.loader.systemd-boot.configurationLimit = 10;
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.systemd-boot.extraEntries = { boot.loader.systemd-boot.extraEntries = {
"fedora.conf" = '' "fedora.conf" = ''
title Fedora title Fedora
efi /EFI/fedora/grubx64.efi efi /EFI/fedora/grubx64.efi
''; '';
}; };
boot.kernelParams = [ "quiet" ];
# Reboot Timeout
systemd.extraConfig = ''
DefaultTimeoutStopSec=10s
'';
# Swap
zramSwap.enable = true;
# Filesystem # Filesystem
fileSystems = { fileSystems = {
@ -21,46 +37,7 @@
"/home".options = [ "compress=zstd:1" ]; "/home".options = [ "compress=zstd:1" ];
"/nix".options = [ "compress=zstd:1" "noatime" ]; "/nix".options = [ "compress=zstd:1" "noatime" ];
}; };
# Networking
networking.hostName = "lyes-pc";
# NVidia
services.xserver.videoDrivers = [ "nvidia" ];
hardware.graphics = {
enable = true;
enable32Bit = true;
};
hardware.nvidia = {
# Modesetting is needed for most wayland compositors
modesetting.enable = true;
# Use the open source version of the kernel module
# Only available on driver 515.43.04+
open = true;
# Enable the nvidia settings menu
nvidiaSettings = true;
# Optionally, you may need to select the appropriate driver version for your specific GPU
# package = config.boot.kernelPackages.nvidiaPackages.vulkan_beta;
prime = {
offload = {
enable = true;
enableOffloadCmd = true;
};
intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:1:0:0";
};
};
# For containers
hardware.nvidia-container-toolkit.enable = true;
# Optimisation # Optimisation
# nixpkgs.hostPlatform = { # nixpkgs.hostPlatform = {

View file

@ -1,26 +1,26 @@
{ pkgs, ... }: { nixpkgs-unstable, ... }:
{ {
imports = imports =
[ [
./packages.nix ./packages.nix
./system.nix ./system.nix
./networking.nix
./user/user.nix
./specialisation.nix
./gaming.nix
]; ];
# Import local packages # Import local packages
nixpkgs.overlays = [ nixpkgs.overlays = [
(final: prev: { (final: prev: {
local = import ../pkgs { pkgs = final; }; local = import ../../pkgs { pkgs = final; };
})
# Unstable
(final: prev: {
unstable = import nixpkgs-unstable {
system = prev.system;
};
}) })
]; ];
# Fails for some reason
documentation.nixos.enable = false;
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
nix.extraOptions = '' nix.extraOptions = ''
@ -35,32 +35,6 @@
options = "--delete-older-than 30d"; options = "--delete-older-than 30d";
}; };
# programs.nix-ld = {
# enable = true;
# libraries = with pkgs; [
# glib
# nss
# nspr
# cups
# dbus
# expat
# xorg.libxcb
# libxkbcommon
# cairo
# pango
# at-spi2-atk
# libdrm
# xorg.libX11
# xorg.libXcomposite
# xorg.libXdamage
# xorg.libXext
# xorg.libXfixes
# xorg.libXrandr
# mesa
# alsa-lib
# ];
# };
# This value determines the NixOS release from which the default # This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions # settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave # on your system were taken. Its perfectly fine and recommended to leave

View file

@ -0,0 +1,32 @@
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
# Utilities
neovim
helix
wget
ripgrep
eza
bat
tree
dust
pciutils
man-pages
man-pages-posix
python3
any-nix-shell
# Nix
home-manager
nix-index
direnv
];
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
}

38
modules/common/system.nix Normal file
View file

@ -0,0 +1,38 @@
{ pkgs, ... }:
{
# Time
time.timeZone = "Europe/Paris";
# Locale
i18n.defaultLocale = "fr_FR.UTF-8";
# Keyboard
console = {
font = "Lat2-Terminus16";
# keyMap = "fr";
useXkbConfig = true;
};
services.xserver.xkb.layout = "fr";
services.xserver.xkb.variant = "oss";
# Shell
programs.fish.enable = true;
programs.fish.promptInit = ''
any-nix-shell fish --info-right | source
'';
environment.shells = with pkgs; [ fish ];
# Environment Variables
environment.sessionVariables = {
EDITOR = "hx";
};
# Documentation
documentation.enable = true;
documentation.man.enable = true;
documentation.dev.enable = true;
# Fails for some reason
documentation.nixos.enable = true;
}

8
modules/default.nix Normal file
View file

@ -0,0 +1,8 @@
{ ... }:
{
imports =
[
./common
];
}

View file

@ -0,0 +1,10 @@
{ ... }:
{
imports =
[
./networking.nix
./packages.nix
./system.nix
];
}

View file

@ -37,9 +37,9 @@
}; };
# Firewall # Firewall
# networking.firewall.allowedTCPPorts = [ 24872 8998 ]; networking.firewall.allowedTCPPorts = [ 24872 8998 ];
# networking.firewall.allowedUDPPorts = [ 24872 8998 ]; networking.firewall.allowedUDPPorts = [ 24872 8998 ];
networking.firewall.enable = false; # networking.firewall.enable = false;
# Network services # Network services
#services.openssh.enable = true; #services.openssh.enable = true;

View file

@ -1,4 +1,4 @@
{ pkgs, nixpkgs-unstable, lib, config, ... }: { pkgs, lib, config, ... }:
let let
tex = (pkgs.texlive.combine { inherit (pkgs.texlive) tex = (pkgs.texlive.combine { inherit (pkgs.texlive)
@ -19,9 +19,8 @@ let
comment; comment;
}); });
in { in {
# Packages # Packages
users.users.lyes.packages = with pkgs; [ environment.systemPackages = with pkgs; [
# Web # Web
fragments fragments
dropbox dropbox
@ -62,22 +61,6 @@ in {
helvum helvum
local.quadcastrgb local.quadcastrgb
# Reading
# calibre
papers
# Utilities
impression
resources
gnome.file-roller
baobab
# Proton
protonmail-bridge-gui
protonmail-desktop
protonvpn-gui
unstable.proton-pass
# Games # Games
heroic heroic
# cemu # cemu
@ -87,26 +70,29 @@ in {
# dolphin-emu # dolphin-emu
parsec-bin parsec-bin
# Nix # Reading
home-manager # calibre
nix-index papers
direnv
# Commandline # Office
starship libreoffice
wl-clipboard onlyoffice-bin
sl hunspell
hunspellDicts.fr-reforme1990
# System hunspellDicts.fr-any
gnome-firmware hunspellDicts.fr-moderne
hunspellDicts.en_US
# Customization hunspellDicts.en_GB-ize
gnome.gnome-tweaks
gnome-extension-manager
adw-gtk3
paper-icon-theme
# gnomeExtensions.gsconnect
# Note taking
apostrophe
setzer
tex
pandoc
typst
tinymist
zotero
# Programming # Programming
git git
git-lfs git-lfs
@ -128,29 +114,39 @@ in {
distrobox distrobox
gnome.gnome-boxes gnome.gnome-boxes
# Office # Virtualization
libreoffice qemu
onlyoffice-bin virt-manager
hunspell
hunspellDicts.fr-reforme1990 # System
hunspellDicts.fr-any gnome-firmware
hunspellDicts.fr-moderne
hunspellDicts.en_US # Utilities
hunspellDicts.en_GB-ize impression
resources
gnome.file-roller
baobab
# Proton
protonmail-bridge-gui
protonmail-desktop
protonvpn-gui
unstable.proton-pass
# Customization
gnome.gnome-tweaks
gnome-extension-manager
adw-gtk3
paper-icon-theme
# gnomeExtensions.gsconnect
# Note taking
apostrophe
setzer
tex
pandoc
typst
tinymist
zotero
# Multimedia # Multimedia
pipewire.dev pipewire.dev
pulseaudio pulseaudio
libopus libopus
# Printing
hplipWithPlugin
]; ];
# Flatpaks # Flatpaks
@ -205,6 +201,29 @@ in {
update.auto.enable = true; update.auto.enable = true;
}; };
fonts = {
enableDefaultPackages = true;
packages = with pkgs; [
noto-fonts
noto-fonts-cjk-sans
noto-fonts-lgc-plus
noto-fonts-emoji
cantarell-fonts
twitter-color-emoji
(nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
];
fontDir.enable = true;
fontconfig = {
defaultFonts = {
sansSerif = [ "Cantarell" "Noto Sans" ];
monospace = [ "JetBrainsMono Nerd Font" ];
emoji = [ "Twitter Color Emoji" "Noto Color Emoji" ];
};
};
};
nixpkgs.overlays = [ nixpkgs.overlays = [
# Version pins # Version pins
(final: prev: { (final: prev: {
@ -228,12 +247,5 @@ in {
]; ];
}); });
}) })
# Unstable
(final: prev: {
unstable = import nixpkgs-unstable {
system = prev.system;
};
})
]; ];
} }

View file

@ -1,24 +1,16 @@
{ pkgs, ... }: { pkgs, ... }:
{ {
# OS Configuration # Boot
boot.loader.systemd-boot.enable = true;
boot.loader.systemd-boot.configurationLimit = 10;
boot.loader.efi.canTouchEfiVariables = true;
boot.plymouth.enable = true; boot.plymouth.enable = true;
boot.kernelParams = [ "quiet" ];
# Filesystems
boot.supportedFilesystems = [ "ntfs" ]; boot.supportedFilesystems = [ "ntfs" ];
zramSwap.enable = true;
# Reboot Timeout
systemd.extraConfig = ''
DefaultTimeoutStopSec=10s
'';
# Firmware # Firmware
services.fwupd.enable = true; services.fwupd.enable = true;
# Fingerprint
services.fprintd.enable = true; services.fprintd.enable = true;
security.pam.services.login.fprintAuth = false; security.pam.services.login.fprintAuth = false;
security.pam.services.gdm-fingerprint.text = '' security.pam.services.gdm-fingerprint.text = ''
@ -39,20 +31,7 @@
session optional ${pkgs.gnome.gnome-keyring}/lib/security/pam_gnome_keyring.so auto_start session optional ${pkgs.gnome.gnome-keyring}/lib/security/pam_gnome_keyring.so auto_start
''; '';
# Time # Touchpad
time.timeZone = "Europe/Paris";
# Keyboard & Touchpad
i18n.defaultLocale = "fr_FR.UTF-8";
console = {
font = "Lat2-Terminus16";
#keyMap = "fr";
useXkbConfig = true;
};
services.xserver.xkb.layout = "fr";
services.xserver.xkb.variant = "oss";
services.libinput.enable = true; services.libinput.enable = true;
# Printing # Printing
@ -61,18 +40,6 @@
services.avahi.nssmdns4 = true; services.avahi.nssmdns4 = true;
services.avahi.openFirewall = true; services.avahi.openFirewall = true;
# Shell
programs.fish.enable = true;
programs.fish.promptInit = ''
any-nix-shell fish --info-right | source
'';
environment.shells = with pkgs; [ fish ];
# Environment Variables
environment.sessionVariables = {
EDITOR = "hx";
};
# Graphics # Graphics
services.xserver.enable = true; services.xserver.enable = true;
programs.xwayland.enable = true; programs.xwayland.enable = true;
@ -115,13 +82,6 @@
#jack.enable = true; #jack.enable = true;
}; };
# Documentation
documentation.enable = true;
documentation.man.enable = true;
documentation.dev.enable = true;
# Fails for some reason
documentation.nixos.enable = false;
# Virtualisation # Virtualisation
virtualisation.libvirtd.enable = true; virtualisation.libvirtd.enable = true;
# virtualisation.virtualbox.host.enable = true; # virtualisation.virtualbox.host.enable = true;

View file

@ -5,7 +5,7 @@
programs.steam.gamescopeSession.enable = true; programs.steam.gamescopeSession.enable = true;
programs.gamemode.enable = true; programs.gamemode.enable = true;
users.users.lyes.packages = with pkgs; [ environment.systemPackages = with pkgs; [
mangohud mangohud
protonup protonup
]; ];

View file

@ -0,0 +1,39 @@
{ ... }:
{
# NVidia
services.xserver.videoDrivers = [ "nvidia" ];
hardware.graphics = {
enable = true;
enable32Bit = true;
};
hardware.nvidia = {
# Modesetting is needed for most wayland compositors
modesetting.enable = true;
# Use the open source version of the kernel module
# Only available on driver 515.43.04+
open = true;
# Enable the nvidia settings menu
nvidiaSettings = true;
# Optionally, you may need to select the appropriate driver version for your specific GPU
# package = config.boot.kernelPackages.nvidiaPackages.vulkan_beta;
prime = {
offload = {
enable = true;
enableOffloadCmd = true;
};
intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:1:0:0";
};
};
# For containers
hardware.nvidia-container-toolkit.enable = true;
}

View file

@ -0,0 +1,15 @@
{ lib, ... }:
{
specialisation = {
gaming.configuration = {
hardware.nvidia = {
prime.sync.enable = lib.mkForce true;
prime.offload = {
enable = lib.mkForce false;
enableOffloadCmd = lib.mkForce false;
};
};
};
};
}

View file

@ -0,0 +1,23 @@
{ lib, ... }:
{
specialisation = {
kde-gaming.configuration = {
hardware.nvidia = {
prime.sync.enable = lib.mkForce true;
prime.offload = {
enable = lib.mkForce false;
enableOffloadCmd = lib.mkForce false;
};
};
# GNOME
services.xserver.displayManager.gdm.enable = lib.mkForce false;
services.xserver.desktopManager.gnome.enable = lib.mkForce false;
# KDE
services.desktopManager.plasma6.enable = true;
services.displayManager.sddm.enable = true;
};
};
}

View file

@ -0,0 +1,15 @@
{ lib, ... }:
{
specialisation = {
kde.configuration = {
# GNOME
services.xserver.displayManager.gdm.enable = lib.mkForce false;
services.xserver.desktopManager.gnome.enable = lib.mkForce false;
# KDE
services.desktopManager.plasma6.enable = true;
services.displayManager.sddm.enable = true;
};
};
}

View file

@ -0,0 +1,9 @@
{ lib, pkgs, ... }:
{
specialisation = {
old-kernel.configuration = {
boot.kernelPackages = lib.mkForce pkgs.linuxPackages_6_1;
};
};
}

32
users/lyes/packages.nix Normal file
View file

@ -0,0 +1,32 @@
{ pkgs, nixpkgs-unstable, lib, config, ... }:
{
# Packages
users.users.lyes.packages = with pkgs; [
# Commandline
starship
wl-clipboard
sl
# Programming
git
git-lfs
vscode
unstable.zed-editor
gcc
rustup
python3
ocaml
ocamlPackages.ocaml-lsp
ocamlPackages.ocamlformat
opam
ledit
nodejs
nil
# Containers & VMs
toolbox
distrobox
gnome.gnome-boxes
];
}