diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..61335e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/hardware-configuration.nix +/hardware.nix +/result +*.qcow2 \ No newline at end of file diff --git a/configuration.nix b/configuration.nix index 0b142b0..2a6e860 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,298 +1,23 @@ -# 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, ... }: - -let - unstable = import { config = { allowUnfree = true; }; }; -in { +{ imports = - [ # Include the results of the hardware scan. - + [ ./hardware-configuration.nix + ./packages.nix + ./system.nix + ./hardware.nix # Set in the up.sh script among the files in hardware/ + ./networking.nix + ./user/user.nix ]; + nixpkgs.config.allowUnfree = true; + nix.extraOptions = '' experimental-features = nix-command flakes ''; - boot.loader.systemd-boot.enable = true; - boot.loader.systemd-boot.extraEntries = { - "fedora.conf" = '' - title Fedora - efi /EFI/fedora/grubx64.efi - ''; - }; - boot.loader.systemd-boot.configurationLimit = 10; - boot.loader.efi.canTouchEfiVariables = true; - boot.plymouth.enable = true; - - boot.supportedFilesystems = [ "ntfs" ]; - - networking.hostName = "lyes-nix"; # Define your hostname. - # Pick only one of the below networking options. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. - - networking.nameservers = [ - "1.1.1.1#one.one.one.one" - "1.0.0.1#one.one.one.one" - "9.9.9.9" - "149.112.112.112" - "2620:fe::fe" - "2620:fe::9" - ]; - - services.resolved = { - enable = true; - dnssec = "true"; - domains = [ "~." ]; - fallbackDns = [ - "1.1.1.1#one.one.one.one" - "1.0.0.1#one.one.one.one" - "9.9.9.9" - "149.112.112.112" - "2620:fe::fe" - "2620:fe::9" - ]; - extraConfig = '' - DNSOverTLS=yes - ''; - }; - - # Set your time zone. - time.timeZone = "Europe/Paris"; - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Select internationalisation properties. - i18n.defaultLocale = "fr_FR.UTF-8"; - console = { - font = "Lat2-Terminus16"; - #keyMap = "fr"; - useXkbConfig = true; # use xkbOptions in tty. - }; - - # Enable the X11 windowing system. - services.xserver.enable = true; - programs.xwayland.enable = true; - - # Enable the GNOME Desktop Environment. - services.xserver.displayManager.gdm.enable = true; - services.xserver.desktopManager.gnome.enable = true; - - # Configure keymap in X11 - services.xserver.layout = "fr"; - services.xserver.xkbVariant = "oss"; - # services.xserver.xkbOptions = { - # "eurosign:e"; - # "caps:escape" # map caps to escape. - # }; - - # Enable CUPS to print documents. - services.printing.enable = true; - services.avahi.enable = true; - services.avahi.nssmdns = true; - # for a WiFi printer - services.avahi.openFirewall = true; - - services.fwupd.enable = true; - - # Enable sound. - sound.enable = false; - hardware.pulseaudio.enable = false; - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - #jack.enable = true; - }; - - # Enable touchpad support (enabled default in most desktopManager). - services.xserver.libinput.enable = true; - - services.mozillavpn.enable = true; - - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.lyes = { - description = "Lyes Saadi"; - home = "/home/lyes"; - isNormalUser = true; - extraGroups = [ "wheel" "networkmanager" ]; - shell = pkgs.fish; - packages = with pkgs; [ - firefox - thunderbird - ocaml - starship - fprintd - adw-gtk3 - home-manager - git - nodejs - gnome.gnome-tweaks - joycond - citra-canary - ledit - paper-icon-theme - steam - minecraft - gnomeExtensions.gsconnect - gnome-extension-manager - mpv - vlc - yt-dlp - discord - toolbox - distrobox - pandoc - texlive.combined.scheme-medium - wl-clipboard - pipewire.dev - pulseaudio - nix-index - appimage-run - hplipWithPlugin - syncplay - direnv - libopus - unstable.protonmail-bridge-gui - dropbox - vvvvvv - ]; - }; - - home-manager.useUserPackages = true; - home-manager.users.lyes = { pkgs, ... }: { - home.stateVersion = "22.11"; - }; - - services.fprintd.enable = true; - services.flatpak.enable = true; - services.joycond.enable = true; - zramSwap.enable = true; - - programs.fish.enable = true; - programs.fish.promptInit = '' - any-nix-shell fish --info-right | source - ''; - environment.shells = with pkgs; [ fish ]; - - nixpkgs.config.allowUnfree = true; - - virtualisation.libvirtd.enable = true; - programs.dconf.enable = true; - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - neovim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - helix - wget - ripgrep - eza - bat - pciutils - man-pages - man-pages-posix - qemu - virt-manager - python3 - any-nix-shell - ]; - - fonts = { - packages = with pkgs; [ - noto-fonts - noto-fonts-cjk - noto-fonts-emoji - (nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) - ]; - - fontDir.enable = true; - }; - - documentation.enable = true; - documentation.man.enable = true; - documentation.dev.enable = true; - documentation.nixos.enable = true; - - services.xserver.videoDrivers = [ "nvidia" ]; - - hardware.opengl = { - enable = true; - driSupport = true; - driSupport32Bit = 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.stable; - }; - - # 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; - }; - - virtualisation.containers.enable = true; - virtualisation = { - podman = { - enable = true; - dockerCompat = true; - defaultNetwork.settings.dns_enabled = true; - extraPackages = [ pkgs.zfs ]; - enableNvidia = true; - }; - }; - - # List services that you want to enable: - - # Enable the OpenSSH daemon. - # services.openssh.enable = true; - - # Open ports in the firewall. - networking.firewall.allowedTCPPorts = [ 24872 8998 ]; - networking.firewall.allowedUDPPorts = [ 24872 8998 ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - - #services.syncplay = { - # enable = true; - # port = 8998; - # extraArgs = [ "--password pouicbarilstepson123cassoulet" ]; - #}; - - fileSystems = { - "/".options = [ "compress=zstd:1" ]; - "/home".options = [ "compress=zstd:1" ]; - "/nix".options = [ "compress=zstd:1" "noatime" ]; - }; - - # Copy the NixOS configuration file and link it from the resulting system - # (/run/current-system/configuration.nix). This is useful in case you - # accidentally delete configuration.nix. - system.copySystemConfiguration = 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. It‘s perfectly fine and recommended to leave @@ -300,6 +25,4 @@ in { # 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 = "22.11"; # Did you read the comment? - } - diff --git a/hardware/x1-extreme-gen4.nix b/hardware/x1-extreme-gen4.nix new file mode 100644 index 0000000..e51b28b --- /dev/null +++ b/hardware/x1-extreme-gen4.nix @@ -0,0 +1,31 @@ +{ config, ... }: + +{ + imports = + [ + + ]; + + services.xserver.videoDrivers = [ "nvidia" ]; + + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = 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.stable; + }; +} \ No newline at end of file diff --git a/networking.nix b/networking.nix new file mode 100644 index 0000000..aa5b98a --- /dev/null +++ b/networking.nix @@ -0,0 +1,47 @@ +{ ... }: + +{ + # Networking + networking.hostName = "lyes-nix"; + networking.networkmanager.enable = true; + + networking.nameservers = [ + "1.1.1.1#one.one.one.one" + "1.0.0.1#one.one.one.one" + "9.9.9.9" + "149.112.112.112" + "2620:fe::fe" + "2620:fe::9" + ]; + + services.resolved = { + enable = true; + dnssec = "true"; + domains = [ "~." ]; + fallbackDns = [ + "1.1.1.1#one.one.one.one" + "1.0.0.1#one.one.one.one" + "9.9.9.9" + "149.112.112.112" + "2620:fe::fe" + "2620:fe::9" + ]; + extraConfig = '' + DNSOverTLS=yes + ''; + }; + + # Firewall + networking.firewall.allowedTCPPorts = [ 24872 8998 ]; + networking.firewall.allowedUDPPorts = [ 24872 8998 ]; + #networking.firewall.enable = false; + + # Network services + #services.openssh.enable = true; + + #services.syncplay = { + # enable = true; + # port = 8998; + # extraArgs = [ "--password pouicbarilstepson123cassoulet" ]; + #}; +} \ No newline at end of file diff --git a/packages.nix b/packages.nix new file mode 100644 index 0000000..0ea7be2 --- /dev/null +++ b/packages.nix @@ -0,0 +1,45 @@ + +{ pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + # Utilities + neovim + helix + wget + ripgrep + eza + bat + pciutils + man-pages + man-pages-posix + python3 + any-nix-shell + + # Virtualization + qemu + virt-manager + + # Printing + hplipWithPlugin + ]; + + fonts = { + packages = with pkgs; [ + noto-fonts + noto-fonts-cjk + noto-fonts-lgc-plus + noto-fonts-emoji + (nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) + ]; + + fontDir.enable = true; + }; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + }; +} \ No newline at end of file diff --git a/system.nix b/system.nix new file mode 100644 index 0000000..b237897 --- /dev/null +++ b/system.nix @@ -0,0 +1,102 @@ +{ pkgs, ... }: + +{ + # OS Configuration + boot.loader.systemd-boot.enable = true; + boot.loader.systemd-boot.extraEntries = { + "fedora.conf" = '' + title Fedora + efi /EFI/fedora/grubx64.efi + ''; + }; + boot.loader.systemd-boot.configurationLimit = 10; + boot.loader.efi.canTouchEfiVariables = true; + boot.plymouth.enable = true; + + boot.supportedFilesystems = [ "ntfs" ]; + + fileSystems = { + "/".options = [ "compress=zstd:1" ]; + "/home".options = [ "compress=zstd:1" ]; + "/nix".options = [ "compress=zstd:1" "noatime" ]; + }; + + zramSwap.enable = true; + + # Firmware + services.fwupd.enable = true; + services.fprintd.enable = true; + + # Time + time.timeZone = "Europe/Paris"; + + # Keyboard & Touchpad + i18n.defaultLocale = "fr_FR.UTF-8"; + console = { + font = "Lat2-Terminus16"; + #keyMap = "fr"; + useXkbConfig = true; + }; + + services.xserver.layout = "fr"; + services.xserver.xkbVariant = "oss"; + + services.xserver.libinput.enable = true; + + # Printing + services.printing.enable = true; + services.avahi.enable = true; + services.avahi.nssmdns = 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 ]; + + # Graphics + services.xserver.enable = true; + programs.xwayland.enable = true; + + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.enable = true; + + programs.dconf.enable = true; + + services.flatpak.enable = true; + + services.joycond.enable = true; + + # Sound + sound.enable = false; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + #jack.enable = true; + }; + + # Documentation + documentation.enable = true; + documentation.man.enable = true; + documentation.dev.enable = true; + documentation.nixos.enable = true; + + # Virtualisation + virtualisation.libvirtd.enable = true; + + # Containers + virtualisation.containers.enable = true; + virtualisation.podman = { + enable = true; + dockerCompat = true; + defaultNetwork.settings.dns_enabled = true; + extraPackages = [ pkgs.zfs ]; + enableNvidia = true; + }; +} \ No newline at end of file diff --git a/up.sh b/up.sh new file mode 100755 index 0000000..5529935 --- /dev/null +++ b/up.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +rm *.qcow2 result 2> /dev/null + +if [ -n "$1" ]; then + echo "Changing hardware" + cp hardware/"$1".nix hardware.nix + exit 0 +fi + +if [ "$EUID" -ne 0 ]; then + echo "Please run as root" + exit 1 +fi + +echo "Updating configuration" +rm hardware-configuration.nix +sudo cp -rf * /etc/nixos/ +cp /etc/nixos/hardware-configuration.nix . diff --git a/user/packages.nix b/user/packages.nix new file mode 100644 index 0000000..ff1c632 --- /dev/null +++ b/user/packages.nix @@ -0,0 +1,57 @@ +{ pkgs, ... }: + +let + unstable = import { config = { allowUnfree = true; }; }; +in { + users.users.lyes.packages = with pkgs; [ + # Software + firefox + thunderbird + discord + mpv + vlc + syncplay + gnome.gnome-tweaks + gnome-extension-manager + unstable.protonmail-bridge-gui + + # Games + citra-canary + steam + minecraft + vvvvvv + + # Utilities + home-manager + nix-index + direnv + starship + dropbox + yt-dlp + wl-clipboard + + # Customization + adw-gtk3 + paper-icon-theme + gnomeExtensions.gsconnect + + # Programming + git + ocaml + ledit + nodejs + + # Containers + toolbox + distrobox + + # Note taking + texlive.combined.scheme-medium + pandoc + + # Multimedia + pipewire.dev + pulseaudio + libopus + ]; +} \ No newline at end of file diff --git a/user/user.nix b/user/user.nix new file mode 100644 index 0000000..3cf8093 --- /dev/null +++ b/user/user.nix @@ -0,0 +1,21 @@ +{ pkgs, ... }: + +{ + imports = + [ + ./packages.nix + ]; + + users.users.lyes = { + description = "Lyes Saadi"; + home = "/home/lyes"; + isNormalUser = true; + extraGroups = [ "wheel" "networkmanager" ]; + shell = pkgs.fish; + }; + + home-manager.useUserPackages = true; + home-manager.users.lyes = { pkgs, ... }: { + home.stateVersion = "22.11"; + }; +} \ No newline at end of file