feat: add global variables for nix configs

This commit is contained in:
matt1432 2023-10-18 13:50:00 -04:00
parent 32e2e974ca
commit e946124478
9 changed files with 59 additions and 17 deletions

View file

@ -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 = [ imports = [
home-manager.nixosModules.default home-manager.nixosModules.default
./modules/programs.nix ./modules/programs.nix
./modules/locale.nix ./modules/locale.nix
./overlays ./overlays
./hostvars.nix
]; ];
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
@ -38,6 +48,11 @@
./modules/bash ./modules/bash
./modules/git ./modules/git
./modules/neovim ./modules/neovim
./hostvars.nix
({ osConfig, ... }: {
services.hostvars = osConfig.services.hostvars;
})
]; ];
home.packages = [ home.packages = [

21
common/hostvars.nix Normal file
View file

@ -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;
};
};
}

View file

@ -10,6 +10,11 @@
./modules/nix-gaming.nix ./modules/nix-gaming.nix
]; ];
services.hostvars = {
username = "matt";
fontSize = 10;
};
networking = { networking = {
hostName = "binto"; hostName = "binto";
networkmanager.enable = true; networkmanager.enable = true;
@ -75,7 +80,6 @@
../../modules/dconf.nix ../../modules/dconf.nix
../../modules/firefox ../../modules/firefox
]; ];
programs.alacritty.settings.font.size = 10;
home.stateVersion = "23.11"; home.stateVersion = "23.11";
}; };

View file

@ -13,6 +13,12 @@
./modules/security.nix ./modules/security.nix
]; ];
services.hostvars = {
username = "matt";
configDir = "/home/matt/.nix/hosts/wim/config";
fontSize = 12.5;
};
users.users.matt = { users.users.matt = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" "input" "uinput" "adm" "mlocate" "video" "libvirtd" ]; extraGroups = [ "wheel" "input" "uinput" "adm" "mlocate" "video" "libvirtd" ];

View file

@ -1,13 +1,12 @@
{ pkgs, config, hyprland, hyprgrass, ags, nixpkgs-wayland, ... }: let { pkgs, config, hyprland, hyprgrass, ags, nixpkgs-wayland, ... }: let
waypkgs = nixpkgs-wayland.packages.x86_64-linux; waypkgs = nixpkgs-wayland.packages.x86_64-linux;
configDir = (import ../vars.nix).configDir; configDir = config.services.hostvars.configDir;
symlink = config.lib.file.mkOutOfStoreSymlink; symlink = config.lib.file.mkOutOfStoreSymlink;
gset = pkgs.gsettings-desktop-schemas; gset = pkgs.gsettings-desktop-schemas;
polkit = pkgs.plasma5Packages.polkit-kde-agent; polkit = pkgs.plasma5Packages.polkit-kde-agent;
in in {
{
imports = [ imports = [
ags.homeManagerModules.default ags.homeManagerModules.default
]; ];

View file

@ -1,5 +1,5 @@
{ pkgs, lib, ... }: let { pkgs, lib, config, ... }: let
font-size = 12; fontSize = config.services.hostvars.fontSize;
dracula-xresources = pkgs.fetchFromGitHub { dracula-xresources = pkgs.fetchFromGitHub {
owner = "dracula"; owner = "dracula";
repo = "xresources"; repo = "xresources";
@ -35,7 +35,7 @@ in
font = { font = {
name = "Sans Serif"; name = "Sans Serif";
size = font-size; size = fontSize;
}; };
}; };
@ -53,8 +53,8 @@ in
xdg.configFile = let xdg.configFile = let
qtconf = '' qtconf = ''
[Fonts] [Fonts]
fixed="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 font-size},-1,5,50,0,0,0,0,0" general="Sans Serif,${lib.strings.floatToString fontSize},-1,5,50,0,0,0,0,0"
[Appearance] [Appearance]
icon_theme=Flat-Remix-Violet-Dark icon_theme=Flat-Remix-Violet-Dark

View file

@ -1,5 +1,5 @@
{ config, pkgs, ... }: let { config, pkgs, ... }: let
configDir = (import ../vars.nix).configDir; configDir = config.services.hostvars.configDir;
symlink = config.lib.file.mkOutOfStoreSymlink; symlink = config.lib.file.mkOutOfStoreSymlink;
in in
{ {

View file

@ -1,3 +0,0 @@
{
configDir = "/home/matt/.nix/hosts/wim/config";
}

View file

@ -1,6 +1,6 @@
# Home-manager module # Home-manager module
{ lib, ... }: { { lib, config, ... }: {
programs.alacritty = { programs.alacritty = {
enable = true; enable = true;
settings = { settings = {
@ -38,7 +38,7 @@
family = "JetBrainsMono Nerd Font"; family = "JetBrainsMono Nerd Font";
style = "Italic"; style = "Italic";
}; };
size = lib.mkDefault 12.5; size = config.services.hostvars.fontSize;
}; };
# https://github.com/dracula/alacritty/blob/05faff15c0158712be87d200081633d9f4850a7d/dracula.yml # https://github.com/dracula/alacritty/blob/05faff15c0158712be87d200081633d9f4850a7d/dracula.yml