Bonjour,
Voici comment installer NixOS.
Télécharger NixOS :
wget https://channels.nixos.org/nixos-23.11/latest-nixos-minimal-x86_64-linux.iso
Installer NixOS :
sudo loadkeys fr
UEFI avec Swap 8 Go
parted /dev/sda -- mklabel gpt
parted /dev/sda -- mkpart primary 512MB -8GB
parted /dev/sda -- mkpart primary linux-swap -8GB 100%
parted /dev/sda -- mkpart ESP fat32 1MB 512MB
parted /dev/sda -- set 3 esp on
mkfs.btrfs /dev/sda1 -f
mount -t btrfs /dev/sda1 /mnt/
mkswap -L swap /dev/sda2
swapon /dev/sda2
mkfs.fat -F 32 /dev/sda3
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@cache
btrfs subvolume create /mnt/@log
umount /mnt/
mount -t btrfs -o subvol=@ /dev/sda1 /mnt/
mkdir -p /mnt/{boot,home,nix,var/cache,var/log}
mount -t btrfs -o subvol=@home /dev/sda1 /mnt/home
mount -t btrfs -o subvol=@nix /dev/sda1 /mnt/nix
mount -t btrfs -o subvol=@cache /dev/sda1 /mnt/var/cache
mount -t btrfs -o subvol=@log /dev/sda1 /mnt/var/log
mount /dev/sda3 /mnt/boot/
nixos-generate-config --root /mnt
nixos-install
reboot
UEFI sans Swap
parted /dev/nvme0n1 -- mklabel gpt
parted /dev/nvme0n1 -- mkpart primary 512MB -512MB
parted /dev/nvme0n1 -- mkpart ESP fat32 1MB 512MB
parted /dev/nvme0n1 -- set 2 esp on
mkfs.btrfs /dev/nvme0n1p1 -f
mount -t btrfs /dev/nvme0n1p1 /mnt/
mkfs.fat -F 32 /dev/nvme0n1p2
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@nix
btrfs subvolume create /mnt/@cache
btrfs subvolume create /mnt/@log
umount /mnt/
mount -t btrfs -o subvol=@ /dev/nvme0n1p1 /mnt/
mkdir -p /mnt/{boot,home,nix,var/cache,var/log}
mount -t btrfs -o subvol=@home /dev/nvme0n1p1 /mnt/home
mount -t btrfs -o subvol=@nix /dev/nvme0n1p1 /mnt/nix
mount -t btrfs -o subvol=@cache /dev/nvme0n1p1 /mnt/var/cache
mount -t btrfs -o subvol=@log /dev/nvme0n1p1 /mnt/var/log
mount /dev/nvme0n1p2 /mnt/boot/
nixos-generate-config --root /mnt
curl -L -o /mnt/etc/nixos/configuration.nix https://gist.githubusercontent.com/liberodark/181f004cbbbc3cbdb83800b5d3503ca8/raw/f4c681e46314dce9f4b3ea8048cc87970852dcd1/configuration.nix
nixos-install
reboot
Configurer NixOS :
nano /etc/nixos/hardware-configuration.nix
Faire une configuration similaire à :
fileSystems."/" =
{ device = "/dev/disk/by-uuid/fbc1b63a-f6fe-4c86-8ddd-62c6a22ef8db";
fsType = "btrfs";
options = [ "subvol=/@,defaults,ssd,autodefrag,compress-force=zstd" ];
};
fileSystems."/home" =
{ device = "/dev/disk/by-uuid/fbc1b63a-f6fe-4c86-8ddd-62c6a22ef8db";
fsType = "btrfs";
options = [ "subvol=/@home,defaults,ssd,autodefrag,compress-force=zstd" ];
};
fileSystems."/nix" =
{ device = "/dev/disk/by-uuid/fbc1b63a-f6fe-4c86-8ddd-62c6a22ef8db";
fsType = "btrfs";
options = [ "subvol=/@nix,defaults,ssd,autodefrag,compress-force=zstd" ];
};
fileSystems."/var/cache" =
{ device = "/dev/disk/by-uuid/fbc1b63a-f6fe-4c86-8ddd-62c6a22ef8db";
fsType = "btrfs";
options = [ "subvol=/@cache,defaults,ssd,autodefrag,compress-force=zstd" ];
};
fileSystems."/var/log" =
{ device = "/dev/disk/by-uuid/fbc1b63a-f6fe-4c86-8ddd-62c6a22ef8db";
fsType = "btrfs";
options = [ "subvol=/@log,defaults,ssd,autodefrag,compress-force=zstd" ];
};
Créer un Utilisateur la configuration de NixOS :
sudo useradd -c 'nixos' -m nixos
Appliquer la configuration de NixOS :
sudo nixos-rebuild switch && reboot
nano /etc/nixos/configuration.nix
# 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.
./hardware-configuration.nix
];
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.kernelPackages = pkgs.linuxPackages_6_6;
# Avoid touchpad click to tap (clickpad) bug. For more detail see:
# https://wiki.archlinux.org/title/Touchpad_Synaptics#Touchpad_does_not_work_after_resuming_from_hibernate/suspend
boot.kernelParams = [ "psmouse.synaptics_intertouch=0" ];
networking.hostName = "nixos"; # 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;
# Hosts
networking.extraHosts =
''
# My Hosts
192.168.1.1 local.ovh.lan
'';
# VPN WireGuard
# networking.wg-quick.interfaces = {
# wg0 = {
# address = [ "IP_CLIENT/32" ];
# dns = [ "1.1.1.1" ];
# privateKeyFile = "/root/.wireguard/private.key";
#
# peers = [
# {
# publicKey = "PUBLIC_KEY";
# #presharedKeyFile = "/root/wireguard-keys/preshared_from_peer0_key";
# allowedIPs = [ "0.0.0.0/24" ];
# endpoint = "SERVER_IP:PORT";
# persistentKeepalive = 25;
# }
# ];
# };
# };
# Set your time zone.
time.timeZone = "Europe/Paris";
# Select internationalisation properties.
i18n.defaultLocale = "fr_FR.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "fr_FR.UTF-8";
LC_IDENTIFICATION = "fr_FR.UTF-8";
LC_MEASUREMENT = "fr_FR.UTF-8";
LC_MONETARY = "fr_FR.UTF-8";
LC_NAME = "fr_FR.UTF-8";
LC_NUMERIC = "fr_FR.UTF-8";
LC_PAPER = "fr_FR.UTF-8";
LC_TELEPHONE = "fr_FR.UTF-8";
LC_TIME = "fr_FR.UTF-8";
};
# Enable the X11 windowing system.
services.xserver.enable = true;
# Enable the KDE Plasma Desktop Environment.
services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
services.xserver.displayManager.defaultSession = "plasmawayland";
programs.dconf.enable = true;
# Enable automatic login for the user.
#services.xserver.displayManager.autoLogin.enable = true;
#services.xserver.displayManager.autoLogin.user = "pc";
services.xserver.videoDrivers = [ "modesettings" ];
# Configure keymap in X11
services.xserver = {
layout = "fr";
xkbVariant = "azerty";
};
# Configure console keymap
console.keyMap = "fr";
# Enable CUPS to print documents.
services.printing.enable = false;
# Enable Bluetooth
hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = true;
#services.blueman.enable = true;
# Enable OpenGL
hardware.opengl.enable = true;
hardware.opengl.driSupport32Bit = true;
hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ gnutls ];
# Enable sound with pipewire.
#sound.enable = true;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
#jack.enable = true;
wireplumber.enable = true;
};
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.pc = {
isNormalUser = true;
description = "pc";
extraGroups = [ "networkmanager" "wheel" "docker" ];
shell = pkgs.fish;
packages = with pkgs; [
#filezilla
];
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# Fish
programs.fish.enable = true;
# Flatpak
xdg.portal.enable = true; # only needed if you are not doing Gnome
services.flatpak.enable = true;
# Docker
virtualisation.docker.enable = true;
virtualisation.docker.storageDriver = "overlay2";
virtualisation.docker.rootless = {
enable = true;
setSocketVariable = true;
};
# Nomachine Server
#services.nxserver.enable = true;
# Samba Browsing
services.avahi = {
enable = true;
nssmdns = true;
};
#services.avahi.enable = true;
#services.avahi.nssmdns = true;
# Fwupd
services.fwupd.enable = true;
# Battery
services.auto-cpufreq.enable = true;
# VMware
virtualisation.vmware.host.enable = true;
# Insecure Packages
nixpkgs.config.permittedInsecurePackages = [
"electron-19.1.9"
];
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
# Core
nano
fish
wget
inxi
xdg-user-dirs
htop
btop
linux-firmware
spectre-meltdown-checker
fwupd
fwupd-efi
wireplumber
lm_sensors
appimage-run
patchelf
dmidecode
avahi
samba
cifs-utils
#(pkgs.uutils-coreutils.override { prefix = ""; })
auto-cpufreq
unzip
# Tools
gparted
angryipscanner
etcher
fd
#sshx
timeshift
libsForQt5.kalk
wrk
# Vmware
linuxKernel.packages.linux_6_6.vmware
vmware-workstation
# Docker
docker
docker-compose
docker-buildx
# Dev
git
pre-commit
shfmt
bats
parallel
shellcheck
vscode.fhs
haskellPackages.ShellCheck
sublime-merge
jq
# Web
filezilla
firefox
element-desktop
discord
thunderbird
riseup-vpn
nodePackages.webtorrent-cli
transmission-qt
# Video
mpv
# VPN
wireguard-tools
# Vulkan
vulkan-tools
vulkan-headers
vulkan-loader
# Driver
mesa
glxinfo
# Wayland
wayland
wayland-protocols
xwayland
libsForQt5.xdg-desktop-portal-kde
libsForQt5.qt5.qttranslations
libsForQt5.sddm-kcm
libsForQt5.plasma-wayland-protocols
xorg.xdpyinfo
# GPU
intel-gpu-tools
intel-media-driver
vaapiIntel
vaapiVdpau
libvdpau-va-gl
xorg.xf86videointel
libva
# Language
poppler_data
hunspell
hunspellDicts.fr-any
hyphen
# Office
softmaker-office
# Game
airshipper
minetest
# Wine
gnutls
haskellPackages.gnutls
libxcrypt
mangohud
fontconfig
faudio
freetype
xorg.libXft
flex
fluidsynth
mpg123
xorg.libXrandr
xorg.libXcomposite
xorg.libXi
xorg.libXinerama
xorg.libXScrnSaver
openal
krb5
gnutls
giflib
#haskellPackages.gstreamer
gst123
gst_all_1.gst-vaapi
gst_all_1.gst-libav
gst_all_1.gst-plugins-bad
gst_all_1.gst-plugins-base
gst_all_1.gst-plugins-good
gst_all_1.gst-plugins-ugly
gst_all_1.gstreamer
libpng
v4l-utils
libgpg-error
libjpeg
libgcrypt
ncurses
ocl-icd
libxslt
libGLU
sqlite
gamemode
vkbasalt
cabextract
];
# Steam
programs.steam.enable = true;
# 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. It‘s 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.autoUpgrade.enable = true;
#system.autoUpgrade.allowReboot = true;
system.stateVersion = "23.05"; # Did you read the comment?
}
KDE 5
https://gist.github.com/liberodark/800c754212256e8d2fb5f055bac8c34b
KDE 6
https://gist.github.com/liberodark/181f004cbbbc3cbdb83800b5d3503ca8
Appliquer la configuration de NixOS :
sudo nixos-rebuild switch
Options Supplémentaire
Restaurer la configuration précédente de NixOS : (Optionnel)
sudo nixos-rebuild switch --rollback
Corriger NixOS : (Optionnel)
sudo nixos-rebuild switch --repair
Mettre à jour NixOS : (Optionnel)
sudo nixos-rebuild switch --upgrade
Nettoyer NixOS : (Optionnel)
sudo nix-collect-garbage --delete-old
Optimiser le Store NixOS : (Optionnel)
Deduplication du store
sudo nix-store --optimise
Nettoyer le boot de NixOS : (Optionnel)
sudo nixos-rebuild boot
Mise à niveau NixOS : (Optionnel)
vérifier la version du channel :
sudo nix-channel --list
nixos https://channels.nixos.org/nixos-23.05
changer la version du channel : (23.11)
sudo nix-channel --add https://channels.nixos.org/nixos-23.11 nixos
sudo nixos-rebuild switch --upgrade
nixos-version
changer la version du channel : (unstable)
sudo nix-channel --add https://channels.nixos.org/nixos-unstable nixos
sudo nixos-rebuild switch --upgrade
nixos-version
Mettre la configuration sur Git : (Optionnel)
sudo nano /etc/nixos/configuration.nix
# Enable Git
environment.etc."gitconfig".text = ''
[user]
name = my_user
email = my_user@email.com
'';
sudo nixos-rebuild switch
cd /etc/nixos
sudo git init
sudo git remote add origin git@github.com:my_user/my_repo.git
sudo git add configuration.nix hardware-configuration.nix hosts/
sudo nano /etc/nixos/.gitignore
# Ignore secrets or sensitive files
secrets.nix
# Ignore generated files
.result
.cache/
sudo git commit -m "Initial commit: NixOS configuration"
sudo git push -u origin main
Créer un Hook sur NixOS : (Optionnel)
# Enable Git Sync
system.activationScripts.gitAutoCommit = ''
cd /etc/nixos
# Check if have modifications
if [ -n "$(/run/current-system/sw/bin/git status --porcelain)" ]; then
echo "Changes have been detected, commit and push in progress..."
# Add Files & Modifications
/run/current-system/sw/bin/git add . || exit 1
# Create Commit
/run/current-system/sw/bin/git commit -m "Auto-commit after nixos-rebuild switch ($(date '+%Y-%m-%d %H:%M:%S'))" || exit 1
# Push Git
GIT_SSH_COMMAND="/run/current-system/sw/bin/ssh" /run/current-system/sw/bin/git push origin master || exit 1
else
echo "No changes detected."
fi
'';