commit 35f4a8026ea57fecfc764ef9975efb0da0085ea1 Author: Mysaa Java Date: Fri May 2 14:07:51 2025 +0200 Initial working system diff --git a/README.md b/README.md new file mode 100644 index 0000000..9676cb4 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +## Files organization +The nix config files are separated in the following folders: +- `packages` for the self-defined packages that have to be added to the system (i.e. self patched versions of softwares) +- `modules` for self-defined modules +- `machines/xxx` one folder xxx for the specific configuration every machine using this configuration of nixos +- `profiles/xxx` one folder for a set of applications/modules/things i want to get applied diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c7fd1e9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,103 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1745627989, + "narHash": "sha256-mOCdFmxocBPae7wg7RYWOtJzWMJk34u9493ItY0dVqw=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "4d2d32231797bfa7213ae5e8ac89d25f8caaae82", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nix-vscode-extensions": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1745546092, + "narHash": "sha256-Q4vPpbuoJOBXRdGW7ZRqlFq1x4FfWKmfyxSVRQZFNCM=", + "owner": "nix-community", + "repo": "nix-vscode-extensions", + "rev": "baeaec5a10fb8626bea64ebabdfaecdf64832bf3", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-vscode-extensions", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1745487689, + "narHash": "sha256-FQoi3R0NjQeBAsEOo49b5tbDPcJSMWc3QhhaIi9eddw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5630cf13cceac06cefe9fc607e8dfa8fb342dde3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nix-vscode-extensions": "nix-vscode-extensions", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..8d5b2ce --- /dev/null +++ b/flake.nix @@ -0,0 +1,49 @@ +{ + description = "My common nixos system"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; + + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + + nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions"; + nix-vscode-extensions.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = inputs: let + inherit (inputs.nixpkgs) lib; + + mkNixosSystems = lib.mapAttrs ( + name: modules: + lib.nixosSystem { + modules = + modules + ++ [ + { + networking.hostName = name; + nixpkgs.overlays = [inputs.nix-vscode-extensions.overlays.default]; + } + ]; + specialArgs = {inherit inputs;}; + } + ); + in { + formatter.x86_64-linux = inputs.nixpkgs.legacyPackages.x86_64-linux.alejandra; + + nixosConfigurations = mkNixosSystems { + polysaa = [ + ./machines/polysaa + ./profiles/graphical + ]; + mynspiron = [ + ./machines/mynspiron + ./profiles/graphical + ]; + myssian = [ + ./machines/myssian + ./profiles/graphical + ]; + }; + }; +} diff --git a/machines/polysaa/default.nix b/machines/polysaa/default.nix new file mode 100644 index 0000000..8ec3d89 --- /dev/null +++ b/machines/polysaa/default.nix @@ -0,0 +1,60 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ + config, + lib, + pkgs, + modulesPath, + ... +}: { + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = ["xhci_pci" "thunderbolt" "nvme" "usbhid" "usb_storage" "sd_mod"]; + boot.initrd.kernelModules = ["dm-snapshot"]; + boot.initrd.luks.devices.cryptroot.device = "/dev/disk/by-uuid/c75f2769-d32f-4eed-9237-ece7e783fec3"; + boot.kernelModules = ["kvm-intel"]; + boot.extraModulePackages = []; + boot.loader.systemd-boot.enable = true; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/b1e8dc07-481a-4248-84ec-12a3083c7386"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/6B09-29A2"; + fsType = "vfat"; + options = ["fmask=0022" "dmask=0022"]; + }; + + swapDevices = [ + {device = "/dev/disk/by-uuid/77ed2d48-365d-4a61-8ada-509e8b7a744c";} + ]; + + networking.hostName = "polysaa"; + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp0s13f0u1u2.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + + hardware.graphics = { + enable = true; + extraPackages = with pkgs; [ + vpl-gpu-rt + vaapiIntel + intel-media-driver + ]; + }; + boot.kernelParams = ["i915.force_probe=7d45"]; + + system.stateVersion = "24.11"; +} diff --git a/profiles/basic/default.nix b/profiles/basic/default.nix new file mode 100644 index 0000000..35ecdb3 --- /dev/null +++ b/profiles/basic/default.nix @@ -0,0 +1,76 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). +{ + config, + lib, + pkgs, + ... +}: { + imports = [ + ./locale.nix + ]; + + nix.settings.experimental-features = ["nix-command" "flakes"]; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # 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.networkmanager.ensureProfiles.profiles = with builtins; + lib.concatMapAttrs + (fname: _: import (./networks + "/${fname}")) + (lib.filterAttrs (fname: _: lib.hasSuffix ".nix" fname) (readDir ./networks)); + + # 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"; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.mysaa = { + isNormalUser = true; + extraGroups = ["wheel"]; # Enable ‘sudo’ for the user. + packages = with pkgs; [ + tree + ]; + }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + nano + wget + git + ]; + + # 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; + + # 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; +} diff --git a/profiles/basic/locale.nix b/profiles/basic/locale.nix new file mode 100644 index 0000000..f15ba8d --- /dev/null +++ b/profiles/basic/locale.nix @@ -0,0 +1,68 @@ +{ + config, + lib, + pkgs, + modulePath, + ... +}: { + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + console.keyMap = "fr-bepo"; + + i18n.inputMethod = { + enable = true; + type = "fcitx5"; + fcitx5.addons = with pkgs; [fcitx5-gtk fcitx5-mozc]; + fcitx5.waylandFrontend = true; + fcitx5.plasma6Support = true; + fcitx5.settings.inputMethod = { + "Groups/0" = { + "Name" = "RegularTyping"; + "Default Layout" = "fr-bepo"; + "DefaultIM" = "keyboard-fr-bepo"; + }; + "Groups/0/Items/0" = { + "Name" = "keyboard-fr-bepo"; + "Layout" = "fr-bepo"; + }; + "Groups/0/Items/1" = { + "Name" = "keyboard-fr"; + "Layout" = "fr"; + }; + "Groups/0/Items/2" = { + "Name" = "mozc"; + "Layout" = "fr-bepo"; + }; + }; + fcitx5.settings.globalOptions = { + "[Hotkey]" = {"EnumerateWithTriggerKeys" = true;}; + "[Hotkey/TriggerKeys]" = {"0" = "Control+Shift+K";}; + "[Behaviour]" = { + "ActiveByDefault" = true; + }; + }; + }; + services.xserver.desktopManager.runXdgAutostartIfNone = true; + + environment.sessionVariables = rec { + XMODIFIERS = "@im=fcitx"; + }; + + # Keyboard layout for login manager + services.xserver.xkb.layout = "fr"; + services.xserver.xkb.variant = "bepo"; + + services.keyd = { + enable = true; + keyboards = { + default = { + ids = ["*"]; + settings = { + main = { + "f23+leftshift+leftmeta" = "layer(control)"; + }; + }; + }; + }; + }; +} diff --git a/profiles/basic/networks/eduroam.nix b/profiles/basic/networks/eduroam.nix new file mode 100644 index 0000000..52fc7f2 --- /dev/null +++ b/profiles/basic/networks/eduroam.nix @@ -0,0 +1,71 @@ +{ + eduroam-IPv6only = { + "802-1x" = { + anonymous-identity = "anonymous@ens-lyon.fr"; + ca-cert = "/usr/share/ca-certificates/mozilla/USERTrust_RSA_Certification_Authority.crt"; + domain-suffix-match = "ens-lyon.fr"; + eap = "peap"; + identity = "savrillo@ens-lyon.fr"; + password-flags = "1"; + phase2-auth = "mschapv2"; + }; + connection = { + id = "eduroam-IPv6only"; + interface-name = "wlp0s20f3"; + permissions = "user:mysaa:;"; + type = "wifi"; + uuid = "547de9c2-ff34-4bbe-bb3f-f5e8dbec032c"; + }; + ipv4 = { + method = "auto"; + }; + ipv6 = { + addr-gen-mode = "1"; + may-fail = "false"; + method = "auto"; + }; + proxy = {}; + wifi = { + mode = "infrastructure"; + ssid = "eduroam-IPv6only"; + }; + wifi-security = { + auth-alg = "open"; + key-mgmt = "wpa-eap"; + }; + }; + eduroam = { + "802-1x" = { + anonymous-identity = "anonymous@ens-lyon.fr"; + ca-cert = "/etc/ssl/certs/USERTrust_RSA_Certification_Authority.pem"; + domain-suffix-match = "ens-lyon.fr"; + eap = "peap"; + identity = "savrillo@ens-lyon.fr"; + password-flags = "1"; + phase2-auth = "mschapv2"; + }; + connection = { + id = "eduroam"; + interface-name = "wlp0s20f3"; + permissions = "user:mysaa:;"; + type = "wifi"; + uuid = "d2af0c3b-b464-480d-8cd2-2a04705d063f"; + }; + ipv4 = { + method = "auto"; + }; + ipv6 = { + addr-gen-mode = "1"; + method = "auto"; + }; + proxy = {}; + wifi = { + mode = "infrastructure"; + ssid = "eduroam"; + }; + wifi-security = { + auth-alg = "open"; + key-mgmt = "wpa-eap"; + }; + }; +} diff --git a/profiles/basic/networks/manglieu.nix b/profiles/basic/networks/manglieu.nix new file mode 100644 index 0000000..6cf7fba --- /dev/null +++ b/profiles/basic/networks/manglieu.nix @@ -0,0 +1,30 @@ +{ + netplan-NM-b4d21f0e-9390-409e-9038-81f46d9d80a4-Livebox-bas = { + connection = { + id = "Livebox-bas"; + interface-name = "wlp0s20f3"; + permissions = "user:mysaa:;"; + type = "wifi"; + uuid = "b4d21f0e-9390-409e-9038-81f46d9d80a4"; + }; + ipv4 = { + method = "auto"; + }; + ipv6 = { + addr-gen-mode = "default"; + method = "auto"; + }; + proxy = {}; + wifi = { + mode = "infrastructure"; + ssid = "Livebox-bas"; + }; + wifi-security = { + auth-alg = "open"; + key-mgmt = "wpa-psk"; + leap-password-flags = "1"; + psk-flags = "1"; + wep-key-flags = "1"; + }; + }; +} diff --git a/profiles/graphical/default.nix b/profiles/graphical/default.nix new file mode 100644 index 0000000..fa8b8ad --- /dev/null +++ b/profiles/graphical/default.nix @@ -0,0 +1,33 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). +{ + config, + lib, + pkgs, + ... +}: { + imports = [ + ../basic + ./packages.nix + ]; + + # Enable the X11 windowing system. + services.xserver.enable = true; + services.displayManager.sddm.enable = true; + services.desktopManager.plasma6.enable = true; + nixpkgs.config.allowUnfree = true; + services.xserver.videoDrivers = ["displaylink" "modesetting"]; + + # Enable CUPS to print documents. + # services.printing.enable = true; + + # Enable sound. + services.pipewire = { + enable = true; + pulse.enable = true; + }; + + # Enable touchpad support (enabled default in most desktopManager). + # services.libinput.enable = true; +} diff --git a/profiles/graphical/packages.nix b/profiles/graphical/packages.nix new file mode 100644 index 0000000..a8e2c47 --- /dev/null +++ b/profiles/graphical/packages.nix @@ -0,0 +1,21 @@ +{ + config, + lib, + pkgs, + ... +}: { + users.users.mysaa.packages = with pkgs; [ + firefox + vlc + (vscode-with-extensions.override { + vscode = vscodium; + vscodeExtensions = with vscode-marketplace; [ + maximedenes.vscoq + myriad-dreamin.tinymist + vmware.vscode-boot-dev-pack + ms-python.python + edwinkofler.vscode-hyperupcall-pack-java + ]; + }) + ]; +}