From 4ac3450ec501a479f7df7a945dc8dc51e8bc1633 Mon Sep 17 00:00:00 2001 From: Superredstone Date: Mon, 5 May 2025 22:05:32 +0200 Subject: [PATCH] Restructured how the config is managed --- Makefile | 3 + configuration.nix => configuration.nix.bak | 0 ...tion.nix => hardware-configuration.nix.bak | 0 lib/mksystem.nix | 8 +- machines/hardware/katana.nix | 43 ++++++ machines/katana.nix | 4 + modules/nix-config/default.nix | 137 ++++++++++++++++++ 7 files changed, 191 insertions(+), 4 deletions(-) rename configuration.nix => configuration.nix.bak (100%) rename hardware-configuration.nix => hardware-configuration.nix.bak (100%) create mode 100644 machines/hardware/katana.nix create mode 100644 modules/nix-config/default.nix diff --git a/Makefile b/Makefile index 0350a7a..98725d2 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ HOSTNAME ?= $(hostname) +all: + echo "No command provided" + switch: sudo nixos-rebuild switch --flake ".#${HOSTNAME}" diff --git a/configuration.nix b/configuration.nix.bak similarity index 100% rename from configuration.nix rename to configuration.nix.bak diff --git a/hardware-configuration.nix b/hardware-configuration.nix.bak similarity index 100% rename from hardware-configuration.nix rename to hardware-configuration.nix.bak diff --git a/lib/mksystem.nix b/lib/mksystem.nix index 880b94f..d5791b1 100644 --- a/lib/mksystem.nix +++ b/lib/mksystem.nix @@ -32,9 +32,9 @@ let # The config files for this system. nixConfig = ../modules/nix-config/default.nix; machineConfig = ../machines/${name}.nix; - OSConfig = ../modules/${if isDarwin then "darwin" else "nixos"}.nix; - HMConfig = ../modules/home-manager.nix; - systemPackages = ../modules/packages.nix; + # OSConfig = ../modules/${if isDarwin then "darwin" else "nixos"}.nix; + HMConfig = ../home; + # systemPackages = ../modules/packages.nix; # TODO: make this cleaner nix-homebrew = lib.optionalAttrs isDarwin inputs.nix-homebrew.darwinModules.nix-homebrew; nix-homebrew-config = lib.optionalAttrs isDarwin { @@ -85,7 +85,7 @@ systemFunc { nix-homebrew nix-homebrew-config systemPackages - OSConfig + # OSConfig # TODO: make user config & home-manager optional home-manager.home-manager { diff --git a/machines/hardware/katana.nix b/machines/hardware/katana.nix new file mode 100644 index 0000000..0295997 --- /dev/null +++ b/machines/hardware/katana.nix @@ -0,0 +1,43 @@ +# 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 = [ "vmd" "xhci_pci" "nvme" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/fcad34c3-e876-44ad-a1d0-a775c936efbf"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."luks-e7fe6c3f-b251-40bf-b053-493097907383".device = "/dev/disk/by-uuid/e7fe6c3f-b251-40bf-b053-493097907383"; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/78EA-8347"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/6a9710ed-3f74-40f3-8e3e-e1afaf4cb118"; } + ]; + + # 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.enp3s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlo1.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/machines/katana.nix b/machines/katana.nix index facb35d..8b2c919 100644 --- a/machines/katana.nix +++ b/machines/katana.nix @@ -1,4 +1,8 @@ { ... }: { + imports = [ + ./hardware/katana.nix + ]; + system.stateVersion = "24.05"; # Did you read the comment? } diff --git a/modules/nix-config/default.nix b/modules/nix-config/default.nix new file mode 100644 index 0000000..b5a3d0a --- /dev/null +++ b/modules/nix-config/default.nix @@ -0,0 +1,137 @@ +{ pkgs, ... }: +{ + nix.gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 1w"; + }; + + # Remove old gtkrc file, otherwise it will not work + system.userActivationScripts = { + removeConflictingFiles = { + text = '' + rm -f /home/r3ddy/.gtkrc-2.0.backup + ''; + }; + }; + + networking.hostName = "nixos"; # Define your hostname. + + networking.networkmanager.enable = true; + networking.firewall.allowedUDPPorts = [ 25565 ]; + networking.firewall.allowedTCPPorts = [ 25565 ]; + hardware.bluetooth.enable = true; + hardware.bluetooth.powerOnBoot = true; + + time.timeZone = "Europe/Rome"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "it_IT.UTF-8"; + LC_IDENTIFICATION = "it_IT.UTF-8"; + LC_MEASUREMENT = "it_IT.UTF-8"; + LC_MONETARY = "it_IT.UTF-8"; + LC_NAME = "it_IT.UTF-8"; + LC_NUMERIC = "it_IT.UTF-8"; + LC_PAPER = "it_IT.UTF-8"; + LC_TELEPHONE = "it_IT.UTF-8"; + LC_TIME = "it_IT.UTF-8"; + }; + + environment.sessionVariables = { + NIXOS_OZONE_WL = "1"; # Use Wayland when possible (this does not seem to work) + ELECTRON_OZONE_PLATFORM_HINT = "wayland"; + GOPATH = "$HOME/.go"; + }; + + + # Enable sound with pipewire. + services.pulseaudio.enable = false; + security.rtkit.enable = true; + + programs.fish.enable = true; # This must be true before initializing my user + users.users.r3ddy = { + isNormalUser = true; + description = "Patrick Canal"; + extraGroups = [ "networkmanager" "wheel" "docker" ]; + shell = pkgs.fish; + }; + + fonts.packages = with pkgs; [ + nerd-fonts.jetbrains-mono + ]; + + nixpkgs.config.allowUnfree = true; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + environment.systemPackages = with pkgs; [ + # CLI utils + appimage-run + btop + busybox + distrobox + docker + fish + fzf + git + gnumake + htop + jq + killall + md2pdf + nmap + python3 + ripgrep + tree + unzip + wget + wl-clipboard + xdotool + xorg.xwininfo + yad + zip + zoxide + zulu + + # Man pages + man-pages + + vim # The only and one great editor + # neovim # The only and one great editor improved even further + + # Video card + vulkan-tools + + # Gaming + dolphin-emu + heroic + mangohud + prismlauncher + steam + vesktop + + # GUI applications + baobab + brave + kdePackages.xdg-desktop-portal-kde + kitty + libresprite + mpv + nextcloud-client + spotube + telegram-desktop + ]; + + programs.steam.enable = true; + programs.steam.remotePlay.openFirewall = true; + virtualisation.podman.enable = true; + virtualisation.podman.dockerCompat = true; + + programs.virt-manager.enable = true; + users.groups.libvirtd.members = ["r3ddy"]; + virtualisation.libvirtd.enable = true; + virtualisation.spiceUSBRedirection.enable = true; +}