From e9461244784a84185a3ab53101c44dc392baa15c Mon Sep 17 00:00:00 2001 From: matt1432 Date: Wed, 18 Oct 2023 13:50:00 -0400 Subject: [PATCH] feat: add global variables for nix configs --- common/default.nix | 19 +++++++++++++++++-- common/hostvars.nix | 21 +++++++++++++++++++++ hosts/binto/configuration.nix | 6 +++++- hosts/wim/configuration.nix | 6 ++++++ hosts/wim/home/hyprland.nix | 5 ++--- hosts/wim/home/theme.nix | 10 +++++----- hosts/wim/modules/dotfiles.nix | 2 +- hosts/wim/vars.nix | 3 --- modules/alacritty.nix | 4 ++-- 9 files changed, 59 insertions(+), 17 deletions(-) create mode 100644 common/hostvars.nix delete mode 100644 hosts/wim/vars.nix diff --git a/common/default.nix b/common/default.nix index ae7347b..e159da1 100644 --- a/common/default.nix +++ b/common/default.nix @@ -1,10 +1,20 @@ -{ config, home-manager, lib, nixpkgs, nur, nix-melt, nurl, pkgs, ... }: { - +{ config +, home-manager +, lib +, nixpkgs +, nur +, nix-melt +, nurl +, pkgs +, ... +}: { imports = [ home-manager.nixosModules.default ./modules/programs.nix ./modules/locale.nix ./overlays + + ./hostvars.nix ]; nixpkgs.config.allowUnfree = true; @@ -38,6 +48,11 @@ ./modules/bash ./modules/git ./modules/neovim + + ./hostvars.nix + ({ osConfig, ... }: { + services.hostvars = osConfig.services.hostvars; + }) ]; home.packages = [ diff --git a/common/hostvars.nix b/common/hostvars.nix new file mode 100644 index 0000000..6eaa1c1 --- /dev/null +++ b/common/hostvars.nix @@ -0,0 +1,21 @@ +{ lib, ... }: { + options.services.hostvars = with lib; { + username = mkOption { + description = '' + Username that was defined at the initial setup process + ''; + type = types.nullOr types.str; + }; + + configDir = mkOption { + description = '' + The path to where most of the hosts' configs are in the .nix folder + ''; + type = types.nullOr types.str; + }; + + fontSize = mkOption { + type = types.nullOr types.float; + }; + }; +} diff --git a/hosts/binto/configuration.nix b/hosts/binto/configuration.nix index 4a6aec5..0cbfc64 100644 --- a/hosts/binto/configuration.nix +++ b/hosts/binto/configuration.nix @@ -10,6 +10,11 @@ ./modules/nix-gaming.nix ]; + services.hostvars = { + username = "matt"; + fontSize = 10; + }; + networking = { hostName = "binto"; networkmanager.enable = true; @@ -75,7 +80,6 @@ ../../modules/dconf.nix ../../modules/firefox ]; - programs.alacritty.settings.font.size = 10; home.stateVersion = "23.11"; }; diff --git a/hosts/wim/configuration.nix b/hosts/wim/configuration.nix index 84acd56..6c39f4d 100644 --- a/hosts/wim/configuration.nix +++ b/hosts/wim/configuration.nix @@ -13,6 +13,12 @@ ./modules/security.nix ]; + services.hostvars = { + username = "matt"; + configDir = "/home/matt/.nix/hosts/wim/config"; + fontSize = 12.5; + }; + users.users.matt = { isNormalUser = true; extraGroups = [ "wheel" "input" "uinput" "adm" "mlocate" "video" "libvirtd" ]; diff --git a/hosts/wim/home/hyprland.nix b/hosts/wim/home/hyprland.nix index fd809d0..ad96c97 100644 --- a/hosts/wim/home/hyprland.nix +++ b/hosts/wim/home/hyprland.nix @@ -1,13 +1,12 @@ { pkgs, config, hyprland, hyprgrass, ags, nixpkgs-wayland, ... }: let waypkgs = nixpkgs-wayland.packages.x86_64-linux; - configDir = (import ../vars.nix).configDir; + configDir = config.services.hostvars.configDir; symlink = config.lib.file.mkOutOfStoreSymlink; gset = pkgs.gsettings-desktop-schemas; polkit = pkgs.plasma5Packages.polkit-kde-agent; -in -{ +in { imports = [ ags.homeManagerModules.default ]; diff --git a/hosts/wim/home/theme.nix b/hosts/wim/home/theme.nix index 67110a5..2db2cd7 100644 --- a/hosts/wim/home/theme.nix +++ b/hosts/wim/home/theme.nix @@ -1,5 +1,5 @@ -{ pkgs, lib, ... }: let - font-size = 12; +{ pkgs, lib, config, ... }: let + fontSize = config.services.hostvars.fontSize; dracula-xresources = pkgs.fetchFromGitHub { owner = "dracula"; repo = "xresources"; @@ -35,7 +35,7 @@ in font = { name = "Sans Serif"; - size = font-size; + size = fontSize; }; }; @@ -53,8 +53,8 @@ in xdg.configFile = let qtconf = '' [Fonts] - fixed="Sans Serif,${lib.strings.floatToString font-size},-1,5,50,0,0,0,0,0" - general="Sans Serif,${lib.strings.floatToString font-size},-1,5,50,0,0,0,0,0" + fixed="Sans Serif,${lib.strings.floatToString fontSize},-1,5,50,0,0,0,0,0" + general="Sans Serif,${lib.strings.floatToString fontSize},-1,5,50,0,0,0,0,0" [Appearance] icon_theme=Flat-Remix-Violet-Dark diff --git a/hosts/wim/modules/dotfiles.nix b/hosts/wim/modules/dotfiles.nix index dcca048..37ceccf 100644 --- a/hosts/wim/modules/dotfiles.nix +++ b/hosts/wim/modules/dotfiles.nix @@ -1,5 +1,5 @@ { config, pkgs, ... }: let - configDir = (import ../vars.nix).configDir; + configDir = config.services.hostvars.configDir; symlink = config.lib.file.mkOutOfStoreSymlink; in { diff --git a/hosts/wim/vars.nix b/hosts/wim/vars.nix deleted file mode 100644 index 627cd36..0000000 --- a/hosts/wim/vars.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ - configDir = "/home/matt/.nix/hosts/wim/config"; -} diff --git a/modules/alacritty.nix b/modules/alacritty.nix index 8438df2..00877c4 100644 --- a/modules/alacritty.nix +++ b/modules/alacritty.nix @@ -1,6 +1,6 @@ # Home-manager module -{ lib, ... }: { +{ lib, config, ... }: { programs.alacritty = { enable = true; settings = { @@ -38,7 +38,7 @@ family = "JetBrainsMono Nerd Font"; style = "Italic"; }; - size = lib.mkDefault 12.5; + size = config.services.hostvars.fontSize; }; # https://github.com/dracula/alacritty/blob/05faff15c0158712be87d200081633d9f4850a7d/dracula.yml