From 4afe64268419261d1a470539d21ca0b94880b4f5 Mon Sep 17 00:00:00 2001 From: Ivan Bushchik Date: Tue, 22 Aug 2023 19:39:11 +0300 Subject: [PATCH] Refactor every role to have .enable option NOTE: any config other than stella will not be working for a while Signed-off-by: Ivan Bushchik --- common/laptop.nix | 28 ++-- common/locale.nix | 2 +- common/security.nix | 2 - common/user.nix | 2 +- flake.nix | 17 +-- machines/stella/configuration.nix | 20 --- roles/design.nix | 19 ++- roles/devel.nix | 27 +++- roles/gaming.nix | 37 +++--- roles/graphical.nix | 213 +++++++++++++++--------------- roles/latex.nix | 15 ++- roles/virtualisation.nix | 15 ++- roles/yggdrasil-client.nix | 23 ++-- 13 files changed, 219 insertions(+), 201 deletions(-) delete mode 100644 machines/stella/configuration.nix diff --git a/common/laptop.nix b/common/laptop.nix index 02b915f..f988a98 100644 --- a/common/laptop.nix +++ b/common/laptop.nix @@ -1,14 +1,22 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: -{ - environment.systemPackages = with pkgs; [ - powertop - lm_sensors - ]; +let + cfg = config.my.laptop; +in { + options = { + my.laptop.enable = lib.mkEnableOption "Laptop-specific configuration"; + }; - hardware.bluetooth.enable = true; - services.blueman.enable = true; + config = lib.mkIf (cfg.enable) { + environment.systemPackages = with pkgs; [ + powertop + lm_sensors + ]; - services.tlp.enable = true; - services.upower.enable = true; + hardware.bluetooth.enable = true; + services.blueman.enable = true; + + services.tlp.enable = true; + services.upower.enable = true; + }; } diff --git a/common/locale.nix b/common/locale.nix index 418502d..c9300f4 100644 --- a/common/locale.nix +++ b/common/locale.nix @@ -5,7 +5,7 @@ i18n.defaultLocale = "ru_RU.UTF-8"; console = { - font = "${pkgs.terminus_font}/share/consolefonts/ter-u16b.psf.gz"; + font = "${pkgs.terminus_font}/share/consolefonts/ter-u24b.psf.gz"; keyMap = "us"; packages = with pkgs; [ terminus_font ]; }; diff --git a/common/security.nix b/common/security.nix index db32a1c..8a12a98 100644 --- a/common/security.nix +++ b/common/security.nix @@ -13,9 +13,7 @@ enable = true; killUnconfinedConfinables = true; }; - allowUserNamespaces = true; - }; boot.kernel.sysctl = { diff --git a/common/user.nix b/common/user.nix index e6ccb48..78bf1af 100644 --- a/common/user.nix +++ b/common/user.nix @@ -14,7 +14,7 @@ in rec { cargo rustc neofetch - gitFull + htop ]; shell = pkgs.zsh; openssh.authorizedKeys.keys = [ diff --git a/flake.nix b/flake.nix index 51075b3..edf06b3 100644 --- a/flake.nix +++ b/flake.nix @@ -18,22 +18,7 @@ system = "x86_64-linux"; modules = [ home-manager.nixosModules.home-manager - ./common/base.nix - ./common/laptop.nix - ./common/locale.nix - ./common/networking.nix - ./common/remote-access.nix - ./common/security.nix - ./common/user.nix - ./roles/design.nix - ./roles/devel.nix - ./roles/gaming.nix - ./roles/graphical.nix - ./roles/latex.nix - ./roles/virtualisation.nix - ./roles/yggdrasil-client.nix - ./machines/stella/configuration.nix - ./machines/stella/hardware.nix + ./machines/stella ]; }; diff --git a/machines/stella/configuration.nix b/machines/stella/configuration.nix deleted file mode 100644 index 3bb15f5..0000000 --- a/machines/stella/configuration.nix +++ /dev/null @@ -1,20 +0,0 @@ - -{ config, pkgs, ... }: - -{ - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - networking.hostName = "stella"; - - services.xserver.videoDrivers=["amdgpu"]; - boot.initrd.kernelModules=["amdgpu"]; - - powerManagement = { - enable = true; - cpuFreqGovernor = "performance"; - }; - - system.stateVersion = "23.05"; -} - diff --git a/roles/design.nix b/roles/design.nix index 4d8487c..c70e039 100644 --- a/roles/design.nix +++ b/roles/design.nix @@ -1,9 +1,14 @@ -{ pkgs, ... }: +{ config, lib, pkgs, ... }: -{ - environment.systemPackages = with pkgs; [ - inkscape - gimp - imagemagick - ]; +let + cfg = config.my.roles.design; +in { + options.my.roles.design.enable = lib.mkEnableOption "Enable design-specific programs"; + config = lib.mkIf (cfg.enable) { + environment.systemPackages = with pkgs; [ + inkscape + gimp + imagemagick + ]; + }; } diff --git a/roles/devel.nix b/roles/devel.nix index 75c6b32..959ce89 100644 --- a/roles/devel.nix +++ b/roles/devel.nix @@ -1,13 +1,15 @@ { config, pkgs, lib, ... }: -{ - config = lib.mkMerge [{ +let + cfg = config.my.roles.devel; +in { + options.my.roles.devel.enable = lib.mkEnableOption "Enable tools for development programs"; + config = lib.mkIf (cfg.enable) ( lib.mkMerge [{ nixpkgs.config.allowUnfree = true; environment.systemPackages = with pkgs; [ rustc cargo rustup - vscode clang llvm lld @@ -16,10 +18,23 @@ autoconf meson ninja + picocom + screen ]; } - + # Architecture-specific packages and configuration (lib.mkIf (!pkgs.stdenv.isAarch64) {boot.binfmt.emulatedSystems = [ "aarch64-linux" ];}) - (lib.mkIf (!pkgs.stdenv.isx86_64) {boot.binfmt.emulatedSystems = [ "x86_64-linux" ];}) - ]; + (lib.mkIf (!pkgs.stdenv.isx86_64) {boot.binfmt.emulatedSystems = [ "x86_64-linux" "i686-linux" ];}) + # Remove CLion from builds while I'm semi-online + /*(lib.mkIf (pkgs.stdenv.isx86_64) { + environment.systemPackages = with pkgs; [ + jetbrains.clion + ]; + })*/ + (lib.mkIf (pkgs.stdenv.isx86_64 || pkgs.stdenv.isAarch64 || pkgs.stdenv.isAarch32) { + environment.systemPackages = with pkgs; [ + vscode + ]; + }) + ]); } \ No newline at end of file diff --git a/roles/gaming.nix b/roles/gaming.nix index 6e1a515..b3f2b24 100644 --- a/roles/gaming.nix +++ b/roles/gaming.nix @@ -1,19 +1,22 @@ +{ config, pkgs, lib, ... }: -{ config, pkgs, ... }: - -{ - nixpkgs.config.allowUnfree = true; - hardware.opengl.driSupport32Bit = true; - services.pipewire.alsa.support32Bit = true; - programs.steam.enable = true; - environment.systemPackages = with pkgs; [ - prismlauncher - steam - wineWowPackages.stable - wine - (wine.override { wineBuild = "wine64"; }) - wineWowPackages.staging - winetricks - wineWowPackages.waylandFull - ]; +let + cfg = config.my.roles.gaming; +in { + options.my.roles.gaming.enable = lib.mkEnableOption "Enable wine & steam"; + config = lib.mkIf (cfg.enable) { + nixpkgs.config.allowUnfree = true; + hardware.opengl.driSupport32Bit = true; + services.pipewire.alsa.support32Bit = true; + programs.steam.enable = true; + environment.systemPackages = with pkgs; [ + steam + wineWowPackages.stable + wine + (wine.override { wineBuild = "wine64"; }) + wineWowPackages.staging + winetricks + wineWowPackages.waylandFull + ]; + }; } \ No newline at end of file diff --git a/roles/graphical.nix b/roles/graphical.nix index 476b344..43fd455 100644 --- a/roles/graphical.nix +++ b/roles/graphical.nix @@ -1,117 +1,122 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: -{ - environment.systemPackages = with pkgs; [ - firefox - alacritty - pavucontrol - bottom - mpv - glib - ffmpeg - cinnamon.nemo - usbmuxd - telegram-desktop - keepassxc - ]; - - services.greetd = { - enable = true; - vt = 7; - settings = { - default_session = { - command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd sway"; - user = "greeter"; - }; - }; - }; - programs.sway = { - enable = true; - extraPackages = with pkgs; [ - waybar - grim - slurp - wf-recorder - sway-launcher-desktop - swaybg - swayidle - swaylock - poweralertd - kanshi - libsForQt5.qt5ct - mako - brightnessctl - wdisplays +let + cfg = config.my.roles.graphical; +in { + options.my.roles.graphical.enable = lib.mkEnableOption "Enable GUI"; + config = lib.mkIf (cfg.enable) { + environment.systemPackages = with pkgs; [ + firefox + alacritty + pavucontrol + bottom + mpv + glib + ffmpeg + cinnamon.nemo + usbmuxd + telegram-desktop + keepassxc ]; - wrapperFeatures.gtk = true; - }; - xdg.portal = { - enable = true; - wlr.enable = true; - }; - services.pipewire = { - enable = true; - alsa.enable = true; - pulse.enable = true; - alsa.support32Bit = true; - jack.enable = true; - }; - - qt = { - enable = true; - platformTheme = "gtk2"; - style = "gtk2"; - }; - - services.dbus.enable = true; - - fonts.packages = with pkgs; [ - noto-fonts - noto-fonts-cjk - noto-fonts-cjk-sans - noto-fonts-cjk-serif - noto-fonts-emoji - jetbrains-mono - font-awesome - #google-fonts - liberation_ttf - open-sans - roboto - roboto-mono - kochi-substitute - ]; - - home-manager.users.ivabus = { - gtk = { + services.greetd = { enable = true; - theme = { - name = "Catppuccin-Macchiato-Standard-Blue-dark"; - package = pkgs.catppuccin-gtk.override { - accents = [ "blue" ]; - tweaks = [ "rimless" ]; - size = "standard"; - variant = "macchiato"; + vt = 7; + settings = { + default_session = { + command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd sway"; + user = "greeter"; }; }; - iconTheme = { - name = "Mint-Y-Blue"; - package = pkgs.cinnamon.mint-y-icons; + }; + programs.sway = { + enable = true; + extraPackages = with pkgs; [ + waybar + grim + slurp + wf-recorder + sway-launcher-desktop + swaybg + swayidle + swaylock + poweralertd + kanshi + libsForQt5.qt5ct + mako + brightnessctl + wdisplays + ]; + wrapperFeatures.gtk = true; + }; + + xdg.portal = { + enable = true; + wlr.enable = true; + }; + services.pipewire = { + enable = true; + alsa.enable = true; + pulse.enable = true; + alsa.support32Bit = true; + jack.enable = true; + }; + + qt = { + enable = true; + platformTheme = "gtk2"; + style = "gtk2"; + }; + + services.dbus.enable = true; + + fonts.packages = with pkgs; [ + noto-fonts + noto-fonts-cjk + noto-fonts-cjk-sans + noto-fonts-cjk-serif + noto-fonts-emoji + jetbrains-mono + font-awesome + #google-fonts + liberation_ttf + open-sans + roboto + roboto-mono + kochi-substitute + ]; + + home-manager.users.ivabus = { + gtk = { + enable = true; + theme = { + name = "Catppuccin-Macchiato-Standard-Blue-dark"; + package = pkgs.catppuccin-gtk.override { + accents = [ "blue" ]; + tweaks = [ "rimless" ]; + size = "standard"; + variant = "macchiato"; + }; + }; + iconTheme = { + name = "Mint-Y-Blue"; + package = pkgs.cinnamon.mint-y-icons; + }; + cursorTheme = { + name = "Catppuccin-Macchiato-Dark-Cursors"; + package = pkgs.catppuccin-cursors.macchiatoDark; + }; + font = { + name = "Ubuntu"; + size = 9; + package = pkgs.ubuntu_font_family; + }; }; - cursorTheme = { + home.pointerCursor = { name = "Catppuccin-Macchiato-Dark-Cursors"; package = pkgs.catppuccin-cursors.macchiatoDark; + x11.defaultCursor = "Catppuccin-Macchiato-Dark-Cursors"; }; - font = { - name = "Ubuntu"; - size = 9; - package = pkgs.ubuntu_font_family; - }; - }; - home.pointerCursor = { - name = "Catppuccin-Macchiato-Dark-Cursors"; - package = pkgs.catppuccin-cursors.macchiatoDark; - x11.defaultCursor = "Catppuccin-Macchiato-Dark-Cursors"; }; }; } \ No newline at end of file diff --git a/roles/latex.nix b/roles/latex.nix index 4607602..a2fc120 100644 --- a/roles/latex.nix +++ b/roles/latex.nix @@ -1,7 +1,12 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: -{ - environment.systemPackages = with pkgs; [ - texlive.combined.scheme-full - ]; +let + cfg = config.my.roles.latex; +in { + options.my.roles.latex.enable = lib.mkEnableOption "Enable latex stuff"; + config = lib.mkIf (cfg.enable){ + environment.systemPackages = with pkgs; [ + texlive.combined.scheme-full + ]; + }; } \ No newline at end of file diff --git a/roles/virtualisation.nix b/roles/virtualisation.nix index 2353af5..239ebf5 100644 --- a/roles/virtualisation.nix +++ b/roles/virtualisation.nix @@ -1,5 +1,14 @@ -{ pkgs, ... }: +{ pkgs, config, lib, ... }: -{ - virtualisation.libvirtd.enable = true; +let + cfg = config.my.roles.virtualisation; +in { + options.my.roles.virtualisation.enable = lib.mkEnableOption "Enable tools for virtualisation"; + config = lib.mkIf (cfg.enable) { + virtualisation.libvirtd.enable = true; + environment.systemPackages = with pkgs; [ + qemu_full + qemu-utils + ]; + }; } \ No newline at end of file diff --git a/roles/yggdrasil-client.nix b/roles/yggdrasil-client.nix index 10b35a2..8b9aa18 100644 --- a/roles/yggdrasil-client.nix +++ b/roles/yggdrasil-client.nix @@ -1,13 +1,18 @@ -{ ... }: +{ config, lib, ... }: -{ - services.yggdrasil = { - enable = true; - persistentKeys = true; - settings = { - Peers = [ - "tls://ygg.iva.bz:50002" - ]; +let + cfg = config.my.roles.yggdrasil-client; +in { + options.my.roles.yggdrasil-client.enable = lib.mkEnableOption "Enable yggdrasil"; + config = lib.mkIf (cfg.enable) { + services.yggdrasil = { + enable = true; + persistentKeys = true; + settings = { + Peers = [ + "tls://ygg.iva.bz:50002" + ]; + }; }; }; } \ No newline at end of file