From 2830d981928aa6a55f701c9a65fc0e9ca30f5909 Mon Sep 17 00:00:00 2001 From: randomuser Date: Fri, 7 Jul 2023 23:09:54 -0500 Subject: [PATCH] make changes to have a more modular config --- configuration.nix | 106 ++-------------- ...-manager.nix => hardware-configuration.nix | 0 virtbox.nix | 117 ++++++++++++++++++ 3 files changed, 126 insertions(+), 97 deletions(-) rename hardware-config/qemu-virt-manager.nix => hardware-configuration.nix (100%) create mode 100644 virtbox.nix diff --git a/configuration.nix b/configuration.nix index ffc3214..324012b 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,23 +1,16 @@ { config, pkgs, ... }: let - home-manager = builtins.fetchTarball { - url = "https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz"; - sha256 = "0dfshsgj93ikfkcihf4c5z876h4dwjds998kvgv7sqbfv0z6a4bc"; - }; hostname = "virtbox"; in { imports = [ - (import "./hardware-config/${hostname}.nix") - (import "${home-manager}/nixos") + ./hardware-configuration.nix # include the results of the hardware scan + ./virtbox.nix + ./netbox.nix ]; - boot.loader.grub.enable = true; - boot.loader.grub.device = "/dev/vda"; - - networking.hostName = hostname; # Define your hostname. networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. time.timeZone = "America/Chicago"; @@ -28,100 +21,19 @@ in keyMap = "us"; }; - services.xserver = { - enable = true; - libinput.enable = true; - layout = "us"; - - # we're going to be pulling a sneaky - # we don't actually use startx, it just gets lightdm out of the way - displayManager.startx.enable = true; - }; - - sound.enable = true; - hardware.pulseaudio.enable = true; - environment.systemPackages = with pkgs; [ neovim curl htop git - sx - - (pkgs.callPackage ./builds/utils.nix {}) ]; - users.users.usr = { - isNormalUser = true; - extraGroups = [ "wheel" ]; - packages = with pkgs; [ - firefox - tree - bspwm - sxhkd - ]; - }; - - system.activationScripts.test-script.text = '' - #!${pkgs.bash}/bin/bash - - if [ "$(${pkgs.coreutils}/bin/whoami)" = "usr"]; then - ${pkgs.coreutils}/bin/mkdir -p /home/usr/git - ${pkgs.git}/bin/git https://git.beepboop.systems/rndusr/dot /home/usr/git/dot - fi - ''; - - home-manager.users.usr.home = { - stateVersion = "23.05"; - - file = { - ".config/bash" = { - source = ./config/bash; - recursive = true; - }; - ".config/bspwm" = { - source = ./config/bspwm; - recursive = true; - }; - ".config/git" = { - source = ./config/git; - recursive = true; - }; - ".config/htop" = { - source = ./config/htop; - recursive = true; - }; - ".config/nvim" = { - source = ./config/nvim; - recursive = true; - }; - ".config/python" = { - source = ./config/python; - recursive = true; - }; - ".config/sx" = { - source = ./config/sx; - recursive = true; - }; - ".config/sxhkd" = { - source = ./config/sxhkd; - recursive = true; - }; - ".config/tridactyl" = { - source = ./config/tridactyl; - recursive = true; - }; - ".config/zathura" = { - source = ./config/zathura; - recursive = true; - }; - ".local/share/wallpapers" = { - source = ./wallpapers; - recursive = true; - }; - }; - }; - system.copySystemConfiguration = true; system.stateVersion = "23.05"; # don't change this, lol + + # branch and enable different capabilities based on the system + + lib.mkIf hostname == "virtbox" { + services.virtbox.enable = true; + }; } diff --git a/hardware-config/qemu-virt-manager.nix b/hardware-configuration.nix similarity index 100% rename from hardware-config/qemu-virt-manager.nix rename to hardware-configuration.nix diff --git a/virtbox.nix b/virtbox.nix new file mode 100644 index 0000000..05d75a9 --- /dev/null +++ b/virtbox.nix @@ -0,0 +1,117 @@ +{ config, pkgs, ...}: + +with lib; +let + cfg = config.services.virtbox; + home-manager = builtins.fetchTarball { + url = "https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz"; + sha256 = "0dfshsgj93ikfkcihf4c5z876h4dwjds998kvgv7sqbfv0z6a4bc"; + }; +in { + options.serviecs.virtbox = { + enable = mkEnableOption "virtbox configs"; + }; + + imports = [ + (import "${home-manager}/nixos") + ]; + + config = mkIf cfg.enable { + boot.loader.grub.enable = true; + boot.loader.grub.device = "/dev/vda"; + + networking.hostName = "virtbox"; + + services.xserver = { + enable = true; + libinput.enable = true; + layout = "us"; + + # we're going to be pulling a sneaky + # we don't actually use startx, it just gets lightdm out of the way + displayManager.startx.enable = true; + }; + + sound.enable = true; + hardware.pulseaudio.enable = true; + + environment.systemPackages = with pkgs; [ + sx + + (pkgs.callPackage ./builds/utils.nix {}) + ]; + + users.users.usr = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + packages = with pkgs; [ + firefox + tree + bspwm + sxhkd + ]; + }; + + + # honking impure, but who's counting anyway? + system.activationScripts.test-script.text = '' + #!${pkgs.bash}/bin/bash + + if [ "$(${pkgs.coreutils}/bin/whoami)" = "usr"]; then + ${pkgs.coreutils}/bin/mkdir -p /home/usr/git + ${pkgs.git}/bin/git https://git.beepboop.systems/rndusr/dot /home/usr/git/dot + fi + ''; + + home-manager.users.usr.home = { + stateVersion = "23.05"; + + file = { + ".config/bash" = { + source = ./config/bash; + recursive = true; + }; + ".config/bspwm" = { + source = ./config/bspwm; + recursive = true; + }; + ".config/git" = { + source = ./config/git; + recursive = true; + }; + ".config/htop" = { + source = ./config/htop; + recursive = true; + }; + ".config/nvim" = { + source = ./config/nvim; + recursive = true; + }; + ".config/python" = { + source = ./config/python; + recursive = true; + }; + ".config/sx" = { + source = ./config/sx; + recursive = true; + }; + ".config/sxhkd" = { + source = ./config/sxhkd; + recursive = true; + }; + ".config/tridactyl" = { + source = ./config/tridactyl; + recursive = true; + }; + ".config/zathura" = { + source = ./config/zathura; + recursive = true; + }; + ".local/share/wallpapers" = { + source = ./wallpapers; + recursive = true; + }; + }; + }; + }; +}