diff --git a/disko/btrfs-legacy.nix b/disko/btrfs-legacy.nix deleted file mode 100644 index a2880bc..0000000 --- a/disko/btrfs-legacy.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ mainDisk, ... }: - -{ - disk.main = { - device = mainDisk; - type = "disk"; - - content = { - type = "gpt"; - partitions = { - MBR = { - size = "1M"; - type = "EF02"; - }; - root = { - size = "100%"; - content = { - type = "btrfs"; - extraArgs = [ "-f" ]; - subvolumes = { - "@root" = { mountpoint = "/"; }; - "@nix" = { mountpoint = "/nix"; }; - "@var" = { mountpoint = "/var"; }; - "@docker" = { mountpoint = "/var/lib/docker"; }; - "@home" = { mountpoint = "/home"; }; - "@snapshots" = { mountpoint = "/.snapshots"; }; - }; - }; - }; - }; - }; - }; -} - diff --git a/disko/isengard/btrfs-legacy.nix b/disko/isengard/btrfs-legacy.nix new file mode 100644 index 0000000..ca89925 --- /dev/null +++ b/disko/isengard/btrfs-legacy.nix @@ -0,0 +1,36 @@ +{ ... }: + +{ + disko.devices = { + disk.main = { + device = "/dev/sda"; + type = "disk"; + + content = { + type = "gpt"; + partitions = { + MBR = { + size = "1M"; + type = "EF02"; + }; + root = { + size = "100%"; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "@root" = { mountpoint = "/"; }; + "@nix" = { mountpoint = "/nix"; }; + "@var" = { mountpoint = "/var"; }; + "@docker" = { mountpoint = "/var/lib/docker"; }; + "@home" = { mountpoint = "/home"; }; + "@snapshots" = { mountpoint = "/.snapshots"; }; + }; + }; + }; + }; + }; + }; + }; +} + diff --git a/disko/palantir/lvm.nix b/disko/palantir/lvm.nix new file mode 100644 index 0000000..4afd88e --- /dev/null +++ b/disko/palantir/lvm.nix @@ -0,0 +1,92 @@ +{...}: + +let + disks = [ + "/dev/disk/by-id/ata-WDC_WDS120G2G0A-00JH30_184377804456" + "/dev/disk/by-id/ata-KINGSTON_SA400S37120G_50026B7783176055" + ]; +in +{ + disko.devices = { + disk = { + ssd0 = { + type = "disk"; + device = builtins.elemAt disks 0; + content = { + type = "gpt"; + partitions = { + bios_grub = { + size = "2M"; + type = "EF02"; + }; + + pv = { + size = "100%"; + content = { + type = "lvm_pv"; + vg = "mainpool"; + }; + }; + }; + }; + }; + + ssd1 = { + type = "disk"; + device = builtins.elemAt disks 1; + content = { + type = "gpt"; + partitions = { + pv = { + size = "100%"; + content = { + type = "lvm_pv"; + vg = "mainpool"; + }; + }; + }; + }; + }; + }; + + lvm_vg = { + mainpool = { + type = "lvm_vg"; + lvs = { + root = { + size = "30G"; + lvm_type = "raid0"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + mountOptions = [ "noatime" ]; + }; + }; + + nix = { + size = "50G"; + lvm_type = "raid0"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/nix"; + mountOptions = [ "noatime" ]; + }; + }; + + games = { + size = "100%FREE"; + lvm_type = "raid0"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/games"; + mountOptions = [ "noatime" ]; + }; + }; + }; + }; + }; + }; +} \ No newline at end of file diff --git a/disko/palantir/simple-efi-gpt.nix b/disko/palantir/simple-efi-gpt.nix new file mode 100644 index 0000000..692591d --- /dev/null +++ b/disko/palantir/simple-efi-gpt.nix @@ -0,0 +1,38 @@ +{ ... }: + +{ + disko.devices = { + disk.main = { + device = "/dev/sda"; + type = "disk"; + + content = { + type = "gpt"; + partitions = { + ESP = { + name = "ESP"; + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + + root = { + name = "root"; + size = "100%"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + }; + }; + }; + }; + }; +} + diff --git a/disko/simple-efi-gpt.nix b/disko/simple-efi-gpt.nix deleted file mode 100644 index d543e38..0000000 --- a/disko/simple-efi-gpt.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ mainDisk, ... }: - -{ - disk.main = { - device = mainDisk; - type = "disk"; - - content = { - type = "gpt"; - partitions = { - ESP = { - name = "ESP"; - size = "512M"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; - }; - - root = { - name = "root"; - size = "100%"; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; - }; - }; - }; - }; - }; -} - diff --git a/flake.nix b/flake.nix index 8853e88..10127e8 100644 --- a/flake.nix +++ b/flake.nix @@ -14,7 +14,6 @@ # options system = "x86_64-linux"; release = "25.11"; - mainDisk = "/dev/sda"; myUser = "victor"; # helper @@ -23,27 +22,22 @@ nixosConfigurations = { isengard = lib.nixosSystem { inherit system; - specialArgs = { inherit release mainDisk myUser disko; }; + specialArgs = { inherit release myUser disko; }; modules = [ ./hosts/isengard.nix ./modules/base.nix - ./modules/docker.nix - ] - ++ lib.optional (builtins.pathExists ./hardware-configuration.nix) ./hardware-configuration.nix; + ]; }; palantir = lib.nixosSystem { inherit system; - specialArgs = { inherit release mainDisk myUser disko; }; + specialArgs = { inherit release myUser disko; }; modules = [ ./hosts/palantir.nix ./modules/base.nix - ./modules/plasma.nix - ./modules/gaming.nix home-manager.nixosModules.home-manager ./modules/home.nix - ] - ++ lib.optional (builtins.pathExists ./hardware-configuration.nix) ./hardware-configuration.nix; + ]; }; }; }; diff --git a/hosts/isengard.nix b/hosts/isengard.nix index 76f79d1..915db18 100644 --- a/hosts/isengard.nix +++ b/hosts/isengard.nix @@ -1,41 +1,21 @@ -{ config, pkgs, myUser, release, disko, mainDisk, ... }: +{ config, pkgs, myUser, release, disko, ... }: { - networking.hostName = "isengard"; - + # Imports imports = [ - disko.nixosModules.disko + disko.nixosModules.disko ../disko/isengard/btrfs-legacy.nix + + ../modules/docker.nix ]; - disko.devices = import ../disko/btrfs-legacy.nix { - inherit mainDisk; - }; + # Disks boot.loader = { grub.enable = true; }; - time.timeZone = "Europe/Bucharest"; - - programs.zsh.enable = true; - users.defaultUserShell = pkgs.zsh; - - users.users.${myUser} = { - isNormalUser = true; - extraGroups = [ "wheel" ]; - openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOiNyGO4RAxSdxvn2ZIBZ2Ze4iVVMrBNmu/V9JO70PoT victor@battleship" - ]; - }; - - users.users.root.openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOiNyGO4RAxSdxvn2ZIBZ2Ze4iVVMrBNmu/V9JO70PoT victor@battleship" - ]; - + # Networking + networking.hostName = "isengard"; networking.useDHCP = true; - - services.openssh = { - enable = true; - settings.PasswordAuthentication = false; - }; + time.timeZone = "Europe/Bucharest"; system.stateVersion = release; } diff --git a/hosts/palantir.nix b/hosts/palantir.nix index 1cdd11c..da75c48 100644 --- a/hosts/palantir.nix +++ b/hosts/palantir.nix @@ -1,54 +1,45 @@ -{ config, pkgs, myUser, release, disko, mainDisk, ... }: +{ config, pkgs, myUser, release, disko, ... }: { - networking.hostName = "palantir"; - + # Imports imports = [ - disko.nixosModules.disko + disko.nixosModules.disko ../disko/palantir/lvm.nix + + ../modules/nvidia.nix + ../modules/plasma.nix + ../modules/gaming.nix ]; - disko.devices = import ../disko/simple-efi-gpt.nix { - inherit mainDisk; - }; + # Disks + boot.initrd.services.lvm.enable = true; boot.loader = { systemd-boot.enable = true; efi.canTouchEfiVariables = true; }; + # Networking + networking.hostName = "palantir"; + networking.useDHCP = true; time.timeZone = "Europe/Vienna"; - users.users.${myUser} = { - isNormalUser = true; - extraGroups = [ - "wheel" - "video" - "render" - "input" - ]; - shell = pkgs.zsh; - openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOiNyGO4RAxSdxvn2ZIBZ2Ze4iVVMrBNmu/V9JO70PoT victor@battleship" - ]; + ## Autologin + services = { + getty.autologinUser = myUser; + displayManager.autoLogin = { + enable = true; + user = myUser; + }; }; - users.users.root.openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOiNyGO4RAxSdxvn2ZIBZ2Ze4iVVMrBNmu/V9JO70PoT victor@battleship" - ]; - - networking.useDHCP = true; - - services.openssh = { - enable = true; - settings.PasswordAuthentication = false; - }; - - fileSystems."/games" = { - device = "/dev/disk/by-uuid/90bea801-2b8a-40db-8862-ccc55f2b2262"; - fsType = "ext4"; - options = [ - "nofail" # Prevent system from failing if this drive doesn't mount - ]; - }; + # Mounts + #fileSystems."/games" = { + # device = "/dev/disk/by-uuid/90bea801-2b8a-40db-8862-ccc55f2b2262"; + # fsType = "ext4"; + # options = [ + # "nofail" # Prevent system from failing if this drive doesn't mount + # ]; + #}; + # Release system.stateVersion = release; } diff --git a/modules/base.nix b/modules/base.nix index 1921188..b1cf5ed 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -1,36 +1,38 @@ -{ config, pkgs, mainDisk, lib, ... }: +{ config, pkgs, lib, myUser, ... }: -let - cfg = config.my.allowUnfree; -in { - options = { - my.allowUnfree.names = lib.mkOption { - type = lib.types.listOf lib.types.str; - default = []; - description = "Package names allowed by allowUnfreePredicate"; - }; + nix.settings = { + experimental-features = [ "nix-command" "flakes" ]; + auto-optimise-store = true; }; - config = { - nix.settings = { - experimental-features = [ "nix-command" "flakes" ]; - auto-optimise-store = true; - }; - programs.zsh.enable = true; - environment.systemPackages = with pkgs; [ - git - curl - htop - tmux - killall - neovim - pciutils - progress + programs.zsh.enable = true; + users.defaultUserShell = pkgs.zsh; + environment.systemPackages = with pkgs; [ + git + curl + htop + tmux + killall + neovim + progress + ]; + + # SSH + users.users.${myUser} = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOiNyGO4RAxSdxvn2ZIBZ2Ze4iVVMrBNmu/V9JO70PoT victor@battleship" ]; - - nixpkgs.config.allowUnfreePredicate = - pkg: builtins.elem (lib.getName pkg) cfg.names; }; - + + users.users.root.openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOiNyGO4RAxSdxvn2ZIBZ2Ze4iVVMrBNmu/V9JO70PoT victor@battleship" + ]; + + services.openssh = { + enable = true; + settings.PasswordAuthentication = false; + }; } diff --git a/modules/docker.nix b/modules/docker.nix index 05ecc0d..178cba4 100644 --- a/modules/docker.nix +++ b/modules/docker.nix @@ -3,11 +3,6 @@ { users.users.${myUser}.extraGroups = [ "docker" ]; - virtualisation.docker = { - storageDriver = "btrfs"; - rootless = { - enable = true; - setSocketVariable = true; - }; - }; + virtualisation.docker.enable = true; + virtualisation.docker.storageDriver = "btrfs"; } diff --git a/modules/gaming.nix b/modules/gaming.nix index 0e2cab1..f783e82 100644 --- a/modules/gaming.nix +++ b/modules/gaming.nix @@ -1,42 +1,16 @@ { config, pkgs, myUser, release, lib, ... }: { - my.allowUnfree.names = lib.mkAfter [ - "steam" - "steam-unwrapped" - "cuda-merged" - "cuda_cuobjdump" - "cuda_gdb" - "cuda_nvcc" - "cuda_nvdisasm" - "cuda_nvprune" - "cuda_cccl" - "cuda_cudart" - "cuda_cupti" - "cuda_cuxxfilt" - "cuda_nvml_dev" - "cuda_nvrtc" - "cuda_nvtx" - "cuda_profiler_api" - "cuda_sanitizer_api" - "libcublas" - "libcufft" - "libcurand" - "libcusolver" - "libnvjitlink" - "libcusparse" - "libnpp" - "cudnn" - ]; - - nixpkgs.config.cudaSupport = true; + # Groups for sunshine + users.users.${myUser}.extraGroups = [ + "wheel" + "video" + "render" + "input" + ]; + # Sunshine game stream services = { - getty.autologinUser = "victor"; - displayManager.autoLogin = { - enable = true; - user = "victor"; - }; sunshine = { enable = true; autoStart = true; @@ -54,7 +28,7 @@ enable = true; }; - environment.systemPackages = with pkgs; [ + environment.systemPackages = with pkgs; [ ffmpeg zeroad ]; diff --git a/modules/nvidia.nix b/modules/nvidia.nix new file mode 100644 index 0000000..70f5178 --- /dev/null +++ b/modules/nvidia.nix @@ -0,0 +1,13 @@ +{ config, lib, ... }: + +{ + nixpkgs.config.allowUnfree = true; # Cuz nvidia drivers and stuff + nixpkgs.config.cudaSupport = true; + hardware.graphics.enable = true; + services.xserver.videoDrivers = [ "nvidia" ]; + hardware.nvidia = { + modesetting.enable = true; + open = false; + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; +} \ No newline at end of file diff --git a/modules/plasma.nix b/modules/plasma.nix index 64fee87..a78c6d4 100644 --- a/modules/plasma.nix +++ b/modules/plasma.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: +{ config, pkgs, ... }: { services = { @@ -16,18 +16,6 @@ environment.systemPackages = with pkgs; [ librewolf + pciutils ]; - - # Nvidia - my.allowUnfree.names = lib.mkAfter [ - "nvidia-x11" - "nvidia-settings" - ]; - hardware.graphics.enable = true; - services.xserver.videoDrivers = [ "nvidia" ]; - hardware.nvidia = { - modesetting.enable = true; - open = false; - package = config.boot.kernelPackages.nvidiaPackages.stable; - }; }