From 34b0bb8df42194a0ea433592e3cac27546f0af4e Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Wed, 2 Oct 2024 21:29:37 -0500 Subject: modularize conf and stuff --- configuration.nix | 174 +------------------------------------ flake.nix | 1 + home.nix | 3 - modules/awesome.nix | 9 ++ modules/cups.nix | 9 ++ modules/default.nix | 32 +++++++ modules/doas.nix | 16 ++++ modules/docker.nix | 17 ++++ modules/grub.nix | 26 ++++++ modules/home-manager/arkenfox | 1 - modules/hosts.nix | 5 ++ modules/localization.nix | 5 ++ modules/nix.nix | 11 +++ modules/pipewire.nix | 12 +++ modules/software/default.nix | 23 +++++ modules/software/desktop-extra.nix | 17 ++++ modules/software/desktop.nix | 22 +++++ modules/software/dev-extra.nix | 16 ++++ modules/software/dev.nix | 23 +++++ modules/software/utils.nix | 30 +++++++ modules/wifi.nix | 10 +++ modules/x11/default.nix | 30 +++++++ modules/x11/xinit-startx-xdg.patch | 14 +++ todo | 22 +++++ xinit-startx-xdg.patch | 14 --- 25 files changed, 351 insertions(+), 191 deletions(-) create mode 100644 modules/awesome.nix create mode 100644 modules/cups.nix create mode 100644 modules/default.nix create mode 100644 modules/doas.nix create mode 100644 modules/docker.nix create mode 100644 modules/grub.nix delete mode 160000 modules/home-manager/arkenfox create mode 100644 modules/hosts.nix create mode 100644 modules/localization.nix create mode 100644 modules/nix.nix create mode 100644 modules/pipewire.nix create mode 100644 modules/software/default.nix create mode 100644 modules/software/desktop-extra.nix create mode 100644 modules/software/desktop.nix create mode 100644 modules/software/dev-extra.nix create mode 100644 modules/software/dev.nix create mode 100644 modules/software/utils.nix create mode 100644 modules/wifi.nix create mode 100644 modules/x11/default.nix create mode 100644 modules/x11/xinit-startx-xdg.patch create mode 100644 todo delete mode 100644 xinit-startx-xdg.patch diff --git a/configuration.nix b/configuration.nix index 02cd660..fecb7e6 100644 --- a/configuration.nix +++ b/configuration.nix @@ -10,82 +10,7 @@ ./hardware-configuration.nix ]; - nix.settings = { - experimental-features = [ "nix-command" "flakes" ]; - use-xdg-base-directories = true; - }; - nix.gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 30d"; - }; - - # Use the GRUB 2 boot loader. - boot.loader.grub.enable = true; - # boot.loader.grub.efiSupport = true; - # boot.loader.grub.efiInstallAsRemovable = true; - # boot.loader.efi.efiSysMountPoint = "/boot/efi"; - # Define on which hard drive you want to install Grub. - boot.loader.grub.device = "/dev/sda"; # or "nodev" for efi only - # networking.hostName = "nixos"; # Define your hostname. - # 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. - - # Set your time zone. - time.timeZone = "America/Chicago"; - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - # console = { - # font = "Lat2-Terminus16"; - # keyMap = "us"; - # useXkbConfig = true; # use xkb.options in tty. - # }; - - # Enable the X11 windowing system. - services.xserver.enable = true; - services.xserver.displayManager.startx.enable = true; - services.xserver.windowManager.awesome.enable = true; - - - - - # Configure keymap in X11 - services.xserver.xkb.layout = "us"; - # services.xserver.xkb.options = "eurosign:e,caps:escape"; - - # Enable CUPS to print documents. - # services.printing.enable = true; - - # Enable sound. - # hardware.pulseaudio.enable = true; - # OR - services.pipewire = { - enable = true; - pulse.enable = true; - }; - - # Enable touchpad support (enabled default in most desktopManager). - services.libinput.enable = true; - - #nixpkgs.overlays = [ - # # startx xdg patch - # (final: prev: { - # xorg.xinit = prev.xorg.xinit.overrideAttrs (old: { - # # Apply the patch - # patches = old.patches or [] ++ [ - # ./startx-xdg.patch - # ]; - # }); - # }) - #]; - # Define a user account. Don't forget to set a password with ‘passwd’. users.users.timmy = { @@ -93,104 +18,9 @@ isNormalUser = true; extraGroups = [ "wheel" "docker" ]; # Enable ‘sudo’ for the user. packages = with pkgs; [ - firefox - tree - alacritty - arandr - cups - dmenu - geeqie - #gimp - #inkscape - #keepassxc - mpv - pavucontrol - pcmanfm - #qbittorrent - #qdirstat - redshift - sxiv - #syncthing - #virt-manager - zathura - #additional dev tools - #android-tools - #cargo - #hugo - #python-pip - #wireguard-tools - python3 ]; }; - programs.zsh.enable = true; - users.defaultUserShell = pkgs.zsh; - - programs.dconf.enable = true; # For home-manager to configure gtk - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - home-manager - neovim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - wget - light - dash # TODO should be default /bin/sh - ddcutil # TODO - entr - jq - lm_sensors - nmap - openssl - pv - rsync - sassc - sslscan - stress - wget - xxHash - htop - fastfetch - p7zip - gcc - gnumake - powertop - smartmontools - testdisk - uhubctl - xcape - xwallpaper - screen - tmux - scrot - xorg.setxkbmap - unclutter - xclip - xdotool - xorg.xinput - xorg.xkill - xorg.xrandr - xorg.xset - zsh - docker-compose - git - (xorg.xinit.overrideAttrs (old: rec { - patches = [ - ./xinit-startx-xdg.patch - ]; - })) - ]; - - security.doas.enable = true; - #security.sudo.enable = false; - security.doas.extraRules = [{ - groups = ["wheel"]; - keepEnv = true; - noPass = true; - }]; - - virtualisation.docker.enable = true; - virtualisation.docker.storageDriver = "btrfs"; # TODO this does not function boot.initrd.systemd.extraBin = { @@ -198,10 +28,9 @@ vim = "${pkgs.neovim}/bin/nvim"; }; - # Some programs need SUID wrappers, can be configured further or are # started in user sessions. - programs.mtr.enable = true; + #programs.mtr.enable = true; # programs.gnupg.agent = { # enable = true; # enableSSHSupport = true; @@ -210,7 +39,6 @@ # List services that you want to enable: # Enable the OpenSSH daemon. - services.openssh.enable = true; # Open ports in the firewall. # networking.firewall.allowedTCPPorts = [ ... ]; diff --git a/flake.nix b/flake.nix index 21e4a74..1108ba0 100644 --- a/flake.nix +++ b/flake.nix @@ -27,6 +27,7 @@ specialArgs = { inherit inputs; }; modules = [ ./configuration.nix + ./modules ]; }; diff --git a/home.nix b/home.nix index e0793e1..f34d6c0 100644 --- a/home.nix +++ b/home.nix @@ -4,8 +4,6 @@ homeDirectory = "/home/timmy"; stateVersion = "24.05"; activation = { - # TODO TODO - #cloneRepos = lib.hm.dag.entryAfter ["writeBoundary" "installPackages"] ''${builtins.readFile ./home-config/activate-scripts/clone-repos.sh}''; cloneRepos = lib.hm.dag.entryAfter ["writeBoundary"] '' export PATH="${config.home.path}/bin:$PATH" ${builtins.readFile ./home-config/activation-scripts/clone-repos.sh} @@ -55,7 +53,6 @@ "0100"."0104"."browser.newtabpage.enabled".enable = false; }; settings = { - # checkdefaultbrowser "toolkit.legacyUserProfileCustomizations.stylesheets" = true; "browser.compactmode.show" = true; "browser.uidensity" = 1; # Compact diff --git a/modules/awesome.nix b/modules/awesome.nix new file mode 100644 index 0000000..4db5230 --- /dev/null +++ b/modules/awesome.nix @@ -0,0 +1,9 @@ +{ lib, config, ... }: { + options = { + xserver.awesome.enable = lib.mkEnableOption "enables awesomewm"; + }; + + config = lib.mkIf config.xserver.awesome.enable { + services.xserver.windowManager.awesome.enable = true; + }; +} diff --git a/modules/cups.nix b/modules/cups.nix new file mode 100644 index 0000000..39f8434 --- /dev/null +++ b/modules/cups.nix @@ -0,0 +1,9 @@ +{ lib, config, ... }: { + options = { + cups.enable = lib.mkEnableOption "enables printing"; + }; + + config = lib.mkIf config.cups.enable { + services.printing.enable = true; + }; +} diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..1f878d9 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,32 @@ +{ lib, ... }: { + imports = [ + ./awesome.nix + ./cups.nix + ./doas.nix + ./docker.nix + ./grub.nix + ./hosts.nix + ./localization.nix + ./nix.nix + ./pipewire.nix + ./software.nix + ./wifi.nix + ./x11 + ]; + + cups.enable = lib.mkDefault true; + doas.enable = lib.mkDefault true; + docker = { + enable = lib.mkDefault true; + btrfsSupport = lib.mkDefault true; + }; + grub = { + enable = lib.mkDefault true; + mode = lib.mkDefault "bios"; + biosDevice = lib.mkDefault "/dev/sda"; + }; + pipewire.enable = lib.mkDefault true; + wifi.enable = lib.mkDefault true; + xserver.awesome.enable = lib.mkDefault true; + xserver.enable = lib.mkDefault true; +} diff --git a/modules/doas.nix b/modules/doas.nix new file mode 100644 index 0000000..2af324e --- /dev/null +++ b/modules/doas.nix @@ -0,0 +1,16 @@ +{ lib, config, ... }: { + options = { + doas.enable = lib.mkEnableOption "enables doas"; + sudo.enable = lib.mkEnableOption "enables sudo"; + }; + + config = lib.mkIf config.doas.enable { + security.doas.enable = true; + security.sudo.enable = config.sudo.enable; + security.doas.extraRules = [{ + groups = ["wheel"]; + keepEnv = true; + noPass = true; + }]; + }; +} diff --git a/modules/docker.nix b/modules/docker.nix new file mode 100644 index 0000000..d4b6272 --- /dev/null +++ b/modules/docker.nix @@ -0,0 +1,17 @@ +{ pkgs, lib, config, ... }: { + options = { + docker.enable = lib.mkEnableOption "enables docker"; + docker.btrfsSupport = lib.mkEnableOption "changes docker storageDriver to btrfs"; + }; + + config = lib.mkIf config.docker.enable { + virtualisation.docker = { + enable = true; + storageDriver = lib.mkIf config.docker.btrfsSupport "btrfs"; + }; + + environment.systemPackages = with pkgs; [ + docker-compose + ]; + }; +} diff --git a/modules/grub.nix b/modules/grub.nix new file mode 100644 index 0000000..47227d1 --- /dev/null +++ b/modules/grub.nix @@ -0,0 +1,26 @@ +{ lib, config, ... }: { + options = { + grub.enable = lib.mkEnableOption "enables docker"; + grub.mode = lib.mkOption { + type = lib.types.enum [ "efi" "bios" ]; + default = "efi"; + description = "grub mode efi or bios"; + }; + grub.biosDevice = lib.mkOption { + type = lib.types.str; + description = "device to install grub on"; + }; + }; + + config = lib.mkIf config.grub.enable { + boot.loader = { + grub = { + enable = true; + efiSupport = config.grub.mode == "efi"; + efiInstallAsRemovable = config.grub.mode == "efi"; + device = if config.grub.mode == "bios" then config.grub.biosDevice else "nodev"; + }; + efi.efiSysMountPoint = "/boot/efi"; + }; + }; +} diff --git a/modules/home-manager/arkenfox b/modules/home-manager/arkenfox deleted file mode 160000 index 72addd9..0000000 --- a/modules/home-manager/arkenfox +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 72addd96455cce49c0c8524c53aecd02cf20adec diff --git a/modules/hosts.nix b/modules/hosts.nix new file mode 100644 index 0000000..17e9cac --- /dev/null +++ b/modules/hosts.nix @@ -0,0 +1,5 @@ +{ + networking.extraHosts = '' + 192.168.1.30 localgit + ''; +} diff --git a/modules/localization.nix b/modules/localization.nix new file mode 100644 index 0000000..8313f07 --- /dev/null +++ b/modules/localization.nix @@ -0,0 +1,5 @@ +{ + time.timeZone = "America/Chicago"; + i18n.defaultLocale = "en_US.UTF-8"; + services.xserver.xkb.layout = "us"; +} diff --git a/modules/nix.nix b/modules/nix.nix new file mode 100644 index 0000000..ff8dd28 --- /dev/null +++ b/modules/nix.nix @@ -0,0 +1,11 @@ +{ + nix.settings = { + experimental-features = [ "nix-command" "flakes" ]; + use-xdg-base-directories = true; + }; + nix.gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 30d"; + }; +} diff --git a/modules/pipewire.nix b/modules/pipewire.nix new file mode 100644 index 0000000..fd97d42 --- /dev/null +++ b/modules/pipewire.nix @@ -0,0 +1,12 @@ +{ lib, config, ... }: { + options = { + pipewire.enable = lib.mkEnableOption "enables pipewire"; + }; + + config = lib.mkIf config.pipewire.enable { + services.pipewire = { + enable = true; + pulse.enable = true; + }; + }; +} diff --git a/modules/software/default.nix b/modules/software/default.nix new file mode 100644 index 0000000..0ceef7f --- /dev/null +++ b/modules/software/default.nix @@ -0,0 +1,23 @@ +{ lib, ... }: { + imports = [ + ./desktop.nix + ./desktop-extra.nix + ./dev.nix + ./dev-extra.nix + ./utils.nix + ]; + + software = { + desktop = { + enable = lib.mkDefault true; + extra.enable = lib.mkDefault false; + }; + dev = { + enable = lib.mkDefault true; + extra.enable = lib.mkDefault false; + }; + utils = { + enable = lib.mkDefault true; + }; + }; +} diff --git a/modules/software/desktop-extra.nix b/modules/software/desktop-extra.nix new file mode 100644 index 0000000..5347696 --- /dev/null +++ b/modules/software/desktop-extra.nix @@ -0,0 +1,17 @@ +{ pkgs, lib, config, ... }: { + options = { + software.desktop.extra.enable = lib.mkEnableOption "enables extra desktop apps"; + }; + + config = lib.mkIf config.software.desktop.extra.enable { + environment.systemPackages = with pkgs; [ + geeqie + gimp + inkscape + qbittorrent + qdirstat + ungoogled-chromium + virt-manager + ]; + }; +} diff --git a/modules/software/desktop.nix b/modules/software/desktop.nix new file mode 100644 index 0000000..195d742 --- /dev/null +++ b/modules/software/desktop.nix @@ -0,0 +1,22 @@ +{ pkgs, lib, config, ... }: { + options = { + software.desktop.enable = lib.mkEnableOption "enables desktop apps"; + }; + + config = lib.mkIf config.software.desktop.enable { + programs.dconf.enable = true; # For home-manager to configure gtk + + environment.systemPackages = with pkgs; [ + alacritty + arandr + dmenu + firefox + mpv + pavucontrol + pcmanfm + redshift + sxiv + zathura + ]; + }; +} diff --git a/modules/software/dev-extra.nix b/modules/software/dev-extra.nix new file mode 100644 index 0000000..259ae98 --- /dev/null +++ b/modules/software/dev-extra.nix @@ -0,0 +1,16 @@ +{ pkgs, lib, config, ... }: { + options = { + software.dev.enable = lib.mkEnableOption "enables dev apps"; + }; + + config = lib.mkIf config.software.dev.extra.enable { + environment.systemPackages = with pkgs; [ + android-tools + cargo + hugo + #python-pip + uhubctl + wireguard-tools + ]; + }; +} diff --git a/modules/software/dev.nix b/modules/software/dev.nix new file mode 100644 index 0000000..b0dabcc --- /dev/null +++ b/modules/software/dev.nix @@ -0,0 +1,23 @@ +{ pkgs, lib, config, ... }: { + options = { + software.dev.enable = lib.mkEnableOption "enables dev apps"; + }; + + config = lib.mkIf config.software.dev.enable { + environment.systemPackages = with pkgs; [ + dash # TODO should be default /bin/sh + entr + gcc + git + gnumake + jq + lm_sensors + nmap + openssl + python3 + sassc + sslscan + wget + ]; + }; +} diff --git a/modules/software/utils.nix b/modules/software/utils.nix new file mode 100644 index 0000000..1efdb18 --- /dev/null +++ b/modules/software/utils.nix @@ -0,0 +1,30 @@ +{ pkgs, lib, config, ... }: { + options = { + software.utils.enable = lib.mkEnableOption "enables dev apps"; + }; + + config = lib.mkIf config.software.utils.enable { + programs.zsh.enable = true; + users.defaultUserShell = pkgs.zsh; + services.openssh.enable = true; + + environment.systemPackages = with pkgs; [ + ddcutil # TODO + fastfetch + htop + light + neovim + p7zip + powertop + pv + rsync + screen + scrot + smartmontools + stress + testdisk + tmux + xxHash + ]; + }; +} diff --git a/modules/wifi.nix b/modules/wifi.nix new file mode 100644 index 0000000..54f9089 --- /dev/null +++ b/modules/wifi.nix @@ -0,0 +1,10 @@ +{ pkgs, lib, config, ... }: { + options = { + wifi.enable = lib.mkEnableOption "enables wifi"; + }; + + config = lib.mkIf config.wifi.enable { + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + }; +} diff --git a/modules/x11/default.nix b/modules/x11/default.nix new file mode 100644 index 0000000..8fa1d27 --- /dev/null +++ b/modules/x11/default.nix @@ -0,0 +1,30 @@ +{ pkgs, lib, config, ... }: { + options = { + xserver.enable = lib.mkEnableOption "enables xserver"; + }; + + config = lib.mkIf config.xserver.enable { + services.xserver.enable = true; + services.xserver.displayManager.startx.enable = true; + services.libinput.enable = true; # Enable touchpad support + + environment.systemPackages = with pkgs; [ + unclutter + xcape + xclip + xdotool + xorg.setxkbmap + xorg.xinput + xorg.xkill + xorg.xrandr + xorg.xset + xwallpaper + # Patch startx to be compliant with xdg base dir spec + (xorg.xinit.overrideAttrs (old: rec { + patches = [ + ./xinit-startx-xdg.patch + ]; + })) + ]; + }; +} diff --git a/modules/x11/xinit-startx-xdg.patch b/modules/x11/xinit-startx-xdg.patch new file mode 100644 index 0000000..c1bca97 --- /dev/null +++ b/modules/x11/xinit-startx-xdg.patch @@ -0,0 +1,14 @@ +diff --git a/startx.cpp b/startx.cpp +index dfbebe1..472a1b0 100644 +--- a/startx.cpp ++++ b/startx.cpp +@@ -272,7 +272,7 @@ if [ x"$enable_xauth" = x1 ] ; then + dummy=0 + + XCOMM create a file with auth information for the server. ':0' is a dummy. +- xserverauthfile=$HOME/.serverauth.$$ ++ xserverauthfile="${XAUTHORITY:-$HOME/.Xauthority}" + trap "rm -f '$xserverauthfile'" HUP INT QUIT ILL TRAP BUS TERM + xauth -q -f "$xserverauthfile" << EOF + add :$dummy . $mcookie + diff --git a/todo b/todo new file mode 100644 index 0000000..a8d21fc --- /dev/null +++ b/todo @@ -0,0 +1,22 @@ +wifi nets +wpa supplicant? over nm +ssh keys +install zsh as root +fstab for net shares +shutdownprompt on power button press (handlepowerkey ignore in /etc/systemd/logind.conf) +fix screen turning off when playing video for extended period + +sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target + ^- systemctl restart systemd-logind.service + +autologin +git repo remotes +inputleap for t495 +thunderbird +ff violentmonkey userscripts +printers +pcmanfm config +wireguard + +lowbat +pavolctrld diff --git a/xinit-startx-xdg.patch b/xinit-startx-xdg.patch deleted file mode 100644 index c1bca97..0000000 --- a/xinit-startx-xdg.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/startx.cpp b/startx.cpp -index dfbebe1..472a1b0 100644 ---- a/startx.cpp -+++ b/startx.cpp -@@ -272,7 +272,7 @@ if [ x"$enable_xauth" = x1 ] ; then - dummy=0 - - XCOMM create a file with auth information for the server. ':0' is a dummy. -- xserverauthfile=$HOME/.serverauth.$$ -+ xserverauthfile="${XAUTHORITY:-$HOME/.Xauthority}" - trap "rm -f '$xserverauthfile'" HUP INT QUIT ILL TRAP BUS TERM - xauth -q -f "$xserverauthfile" << EOF - add :$dummy . $mcookie - -- cgit v1.2.3