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

View file

@ -16,22 +16,35 @@
system = "x86_64-linux";
specialArgs = attrs;
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
./specific/lyes-pc/configuration.nix
nixos-hardware.nixosModules.lenovo-thinkpad-x1-extreme-gen4
];
};
iso = nixpkgs.lib.nixosSystem {
desktop-iso = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = attrs;
modules = [
./general/configuration.nix
./hosts/iso
./modules
./modules/desktop
./modules/gaming
./modules/nvidia
nix-flatpak.nixosModules.nix-flatpak
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.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.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 = [
./hardware-configuration.nix
];
# Networking
networking.hostName = "lyes-pc";
# Kernel
# boot.kernelPackages = pkgs.linuxPackages_latest;
# Boot
boot.loader.systemd-boot.enable = true;
boot.loader.systemd-boot.configurationLimit = 10;
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.systemd-boot.extraEntries = {
"fedora.conf" = ''
title Fedora
efi /EFI/fedora/grubx64.efi
'';
};
boot.kernelParams = [ "quiet" ];
# Reboot Timeout
systemd.extraConfig = ''
DefaultTimeoutStopSec=10s
'';
# Swap
zramSwap.enable = true;
# Filesystem
fileSystems = {
@ -22,45 +38,6 @@
"/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
# nixpkgs.hostPlatform = {

View file

@ -1,26 +1,26 @@
{ pkgs, ... }:
{ nixpkgs-unstable, ... }:
{
imports =
[
./packages.nix
./system.nix
./networking.nix
./user/user.nix
./specialisation.nix
./gaming.nix
];
# Import local packages
nixpkgs.overlays = [
(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;
nix.extraOptions = ''
@ -35,32 +35,6 @@
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
# settings for stateful data, like file locations and database versions
# 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
# networking.firewall.allowedTCPPorts = [ 24872 8998 ];
# networking.firewall.allowedUDPPorts = [ 24872 8998 ];
networking.firewall.enable = false;
networking.firewall.allowedTCPPorts = [ 24872 8998 ];
networking.firewall.allowedUDPPorts = [ 24872 8998 ];
# networking.firewall.enable = false;
# Network services
#services.openssh.enable = true;

View file

@ -1,4 +1,4 @@
{ pkgs, nixpkgs-unstable, lib, config, ... }:
{ pkgs, lib, config, ... }:
let
tex = (pkgs.texlive.combine { inherit (pkgs.texlive)
@ -19,9 +19,8 @@ let
comment;
});
in {
# Packages
users.users.lyes.packages = with pkgs; [
environment.systemPackages = with pkgs; [
# Web
fragments
dropbox
@ -62,22 +61,6 @@ in {
helvum
local.quadcastrgb
# Reading
# calibre
papers
# Utilities
impression
resources
gnome.file-roller
baobab
# Proton
protonmail-bridge-gui
protonmail-desktop
protonvpn-gui
unstable.proton-pass
# Games
heroic
# cemu
@ -87,25 +70,28 @@ in {
# dolphin-emu
parsec-bin
# Nix
home-manager
nix-index
direnv
# Reading
# calibre
papers
# Commandline
starship
wl-clipboard
sl
# Office
libreoffice
onlyoffice-bin
hunspell
hunspellDicts.fr-reforme1990
hunspellDicts.fr-any
hunspellDicts.fr-moderne
hunspellDicts.en_US
hunspellDicts.en_GB-ize
# System
gnome-firmware
# Customization
gnome.gnome-tweaks
gnome-extension-manager
adw-gtk3
paper-icon-theme
# gnomeExtensions.gsconnect
# Note taking
apostrophe
setzer
tex
pandoc
typst
tinymist
zotero
# Programming
git
@ -128,29 +114,39 @@ in {
distrobox
gnome.gnome-boxes
# Office
libreoffice
onlyoffice-bin
hunspell
hunspellDicts.fr-reforme1990
hunspellDicts.fr-any
hunspellDicts.fr-moderne
hunspellDicts.en_US
hunspellDicts.en_GB-ize
# Virtualization
qemu
virt-manager
# Note taking
apostrophe
setzer
tex
pandoc
typst
tinymist
zotero
# System
gnome-firmware
# Utilities
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
# Multimedia
pipewire.dev
pulseaudio
libopus
# Printing
hplipWithPlugin
];
# Flatpaks
@ -205,6 +201,29 @@ in {
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 = [
# Version pins
(final: prev: {
@ -228,12 +247,5 @@ in {
];
});
})
# Unstable
(final: prev: {
unstable = import nixpkgs-unstable {
system = prev.system;
};
})
];
}

View file

@ -1,24 +1,16 @@
{ pkgs, ... }:
{
# OS Configuration
boot.loader.systemd-boot.enable = true;
boot.loader.systemd-boot.configurationLimit = 10;
boot.loader.efi.canTouchEfiVariables = true;
# Boot
boot.plymouth.enable = true;
boot.kernelParams = [ "quiet" ];
# Filesystems
boot.supportedFilesystems = [ "ntfs" ];
zramSwap.enable = true;
# Reboot Timeout
systemd.extraConfig = ''
DefaultTimeoutStopSec=10s
'';
# Firmware
services.fwupd.enable = true;
# Fingerprint
services.fprintd.enable = true;
security.pam.services.login.fprintAuth = false;
security.pam.services.gdm-fingerprint.text = ''
@ -39,20 +31,7 @@
session optional ${pkgs.gnome.gnome-keyring}/lib/security/pam_gnome_keyring.so auto_start
'';
# Time
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";
# Touchpad
services.libinput.enable = true;
# Printing
@ -61,18 +40,6 @@
services.avahi.nssmdns4 = 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
services.xserver.enable = true;
programs.xwayland.enable = true;
@ -115,13 +82,6 @@
#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.libvirtd.enable = true;
# virtualisation.virtualbox.host.enable = true;

View file

@ -5,7 +5,7 @@
programs.steam.gamescopeSession.enable = true;
programs.gamemode.enable = true;
users.users.lyes.packages = with pkgs; [
environment.systemPackages = with pkgs; [
mangohud
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
];
}