From 69d199a0b0a2aaedd03faba4b92e2f1420cfb436 Mon Sep 17 00:00:00 2001 From: Random936 Date: Tue, 2 Jul 2024 23:24:16 -0700 Subject: [PATCH] Restructed directories; added second config for nixos-dev vm. --- .../darwin.nix | 0 config/omen.nix | 50 +++++++++++++++++++ nixos/configuration.nix => config/shared.nix | 43 +--------------- config/vm.nix | 21 ++++++++ flake.nix | 10 +++- .../omen.nix | 0 hardware/vm.nix | 31 ++++++++++++ 7 files changed, 111 insertions(+), 44 deletions(-) rename nixos/darwin-configuration.nix => config/darwin.nix (100%) create mode 100644 config/omen.nix rename nixos/configuration.nix => config/shared.nix (65%) create mode 100644 config/vm.nix rename nixos/hardware-configuration.nix => hardware/omen.nix (100%) create mode 100644 hardware/vm.nix diff --git a/nixos/darwin-configuration.nix b/config/darwin.nix similarity index 100% rename from nixos/darwin-configuration.nix rename to config/darwin.nix diff --git a/config/omen.nix b/config/omen.nix new file mode 100644 index 0000000..900d3b2 --- /dev/null +++ b/config/omen.nix @@ -0,0 +1,50 @@ +# 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, inputs, ... }: + +{ + imports = [ + ../hardware/omen.nix + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # Set hostname + networking.hostName = "randomctf"; + + # Enable Nvidia drivers + services.xserver.videoDrivers = [ "nvidia" ]; + hardware.nvidia = { + modesetting.enable = true; + + # Power management is experimental and known to cause issues. + powerManagement.enable = false; + powerManagement.finegrained = false; + open = false; # Don't use open source kernel. + nvidiaSettings = true; + + prime = { + + offload = { + enable = true; + enableOffloadCmd = true; + }; + + intelBusId = "PCI:0:2:0"; + nvidiaBusId = "PCI:1:0:0"; + }; + }; + + # Fix issue with Nvidia display scaling. + services.xserver.dpi = 96; + environment.variables.GDK_SCALE = "0.5"; + + # Enable VMWare Workstation + virtualisation.vmware.host.enable = true; + + system.stateVersion = "24.05"; +} diff --git a/nixos/configuration.nix b/config/shared.nix similarity index 65% rename from nixos/configuration.nix rename to config/shared.nix index 7b9c41d..e179eee 100644 --- a/nixos/configuration.nix +++ b/config/shared.nix @@ -1,23 +1,10 @@ -# 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, inputs, ... }: { - imports = [ - ./hardware-configuration.nix - ]; - # Enable experimental nix features. nix.settings.experimental-features = [ "nix-command" "flakes" ]; - # Bootloader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - # Networking - networking.hostName = "randomctf"; # Define your hostname. networking.wireless.iwd.enable = true; networking.networkmanager = { enable = true; @@ -39,33 +26,6 @@ LC_TIME = "en_US.UTF-8"; }; - # Enable Nvidia drivers - services.xserver.videoDrivers = [ "nvidia" ]; - hardware.nvidia = { - modesetting.enable = true; - - # Power management is experimental and known to cause issues. - powerManagement.enable = false; - powerManagement.finegrained = false; - open = false; # Don't use open source kernel. - nvidiaSettings = true; - - prime = { - - offload = { - enable = true; - enableOffloadCmd = true; - }; - - intelBusId = "PCI:0:2:0"; - nvidiaBusId = "PCI:1:0:0"; - }; - }; - - # Fix issue with Nvidia display scaling. - services.xserver.dpi = 96; - environment.variables.GDK_SCALE = "0.5"; - # Enable the X11 windowing system and i3 window manager. environment.pathsToLink = [ "/libexec" ]; services.xserver = { @@ -131,9 +91,8 @@ services.openssh.enable = true; services.tailscale.enable = true; - # Enable virtualization features + # Enable docker service. virtualisation.docker.enable = true; - virtualisation.vmware.host.enable = true; system.stateVersion = "24.05"; } diff --git a/config/vm.nix b/config/vm.nix new file mode 100644 index 0000000..9f75bd4 --- /dev/null +++ b/config/vm.nix @@ -0,0 +1,21 @@ +# 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, inputs, ... }: + +{ + imports = [ + ../hardware/vm.nix + ]; + + # Bootloader. + boot.loader.grub.enable = true; + boot.loader.grub.device = "/dev/sda"; + boot.loader.grub.useOSProber = true; + + # Set hostname + networking.hostName = "nixos-dev"; + + system.stateVersion = "24.05"; +} diff --git a/flake.nix b/flake.nix index afec4ee..cd40253 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,13 @@ nixosConfigurations.randomctf = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { inherit inputs; }; - modules = [ ./nixos/configuration.nix ]; + modules = [ ./config/shared.nix ./config/omen.nix ]; + }; + + nixosConfigurations.nixos-dev = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ ./config/shared.nix ./config/vm.nix ]; }; homeConfigurations.random = home-manager.lib.homeManagerConfiguration { @@ -32,7 +38,7 @@ system = "aarch64-darwin"; specialArgs = { inherit inputs; }; modules = [ - ./nixos/darwin-configuration.nix + ./config/darwin-configuration.nix home-manager.darwinModules.home-manager { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; diff --git a/nixos/hardware-configuration.nix b/hardware/omen.nix similarity index 100% rename from nixos/hardware-configuration.nix rename to hardware/omen.nix diff --git a/hardware/vm.nix b/hardware/vm.nix new file mode 100644 index 0000000..c9fd506 --- /dev/null +++ b/hardware/vm.nix @@ -0,0 +1,31 @@ +# 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 + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/80be06c6-fafe-43de-a0e5-90464bdd0666"; + fsType = "ext4"; + }; + + swapDevices = [ ]; + + # 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.ens18.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +}