feat(vars): add hostName and big refactors

This commit is contained in:
matt1432 2023-12-01 14:12:33 -05:00
parent 1fe3920c50
commit 66e3a03d7d
20 changed files with 150 additions and 126 deletions

View file

@ -3,14 +3,14 @@
lib, lib,
nixpkgs, nixpkgs,
nh, nh,
nur,
nix-melt, nix-melt,
nur,
nurl, nurl,
pkgs, pkgs,
... ...
}: { }: {
imports = [ imports = [
./device-vars.nix ./vars.nix
./modules ./modules
./overlays ./overlays
@ -56,22 +56,18 @@
layout = "ca"; layout = "ca";
xkbVariant = "multix"; xkbVariant = "multix";
}; };
}; };
home-manager.users = let home-manager.users = let
user = config.services.device-vars.username;
default = { default = {
imports = [ imports = [
nur.hmModules.nur nur.hmModules.nur
./home ./home
./device-vars.nix # Make the vars be the same on Nix and HM
({osConfig, ...}: { ./vars.nix
services.device-vars = osConfig.services.device-vars; ({osConfig, ...}: {vars = osConfig.vars;})
})
]; ];
home.packages = home.packages =
@ -102,6 +98,6 @@
in { in {
root = default; root = default;
# TODO: make user an array? # TODO: make user an array?
${user} = default; ${config.vars.user} = default;
}; };
} }

View file

@ -1,4 +1,8 @@
{pkgs, config, ...}: { {
pkgs,
config,
...
}: {
programs = { programs = {
fzf = { fzf = {
enable = true; enable = true;

View file

@ -4,30 +4,31 @@
lib, lib,
... ...
}: let }: let
vars = config.services.device-vars; cfg = config.services.locate;
locateGroup = lib.getName config.services.locate.package.name;
locate = "${config.services.locate.package}/bin/locate"; locateGroup = lib.getName cfg.package.name;
updatedb = "${config.services.locate.package}/bin/updatedb";
locate = "${cfg.package}/bin/locate";
updatedb = "${cfg.package}/bin/updatedb";
database = "/var/lib/locate/locatedb"; database = "/var/lib/locate/locatedb";
pruneFS = builtins.concatStringsSep " " config.services.locate.pruneFS; pruneFS = builtins.concatStringsSep " " cfg.pruneFS;
pruneNames = builtins.concatStringsSep " " config.services.locate.pruneNames; pruneNames = builtins.concatStringsSep " " cfg.pruneNames;
prunePaths = builtins.concatStringsSep " " config.services.locate.prunePaths; prunePaths = builtins.concatStringsSep " " cfg.prunePaths;
updatedbBin = '' updatedbBin = ''
${updatedb} -o ${database} --prunefs "${pruneFS}" \ ${updatedb} -o ${database} --prunefs "${pruneFS}" \
--prunepaths "${prunePaths}" --prunenames "${pruneNames}" --prunepaths "${prunePaths}" --prunenames "${pruneNames}"
''; '';
in { in {
users.users.${vars.username}.extraGroups = [ users.users.${config.vars.user}.extraGroups = [
locateGroup locateGroup
]; ];
systemd.services.locate = { systemd.services.locate = {
wantedBy = ["default.target"]; wantedBy = ["default.target"];
serviceConfig = { serviceConfig = {
User = vars.username; User = config.vars.user;
Group = locateGroup; Group = locateGroup;
StateDirectory = "locate"; StateDirectory = "locate";
StateDirectoryMode = "0770"; StateDirectoryMode = "0770";
@ -35,17 +36,13 @@ in {
}; };
}; };
home-manager.users.${vars.username}.imports = [ home-manager.users.${config.vars.user}.programs.bash.shellAliases = {
{ locate = "${pkgs.writeShellScriptBin "lct" ''
programs.bash.shellAliases = { exec ${locate} -d ${database} "$@" 2> >(grep -v "/var/cache/locatedb")
locate = "${pkgs.writeShellScriptBin "lct" '' ''}/bin/lct";
exec ${locate} -d ${database} "$@" 2> >(grep -v "/var/cache/locatedb")
''}/bin/lct";
updatedb = updatedbBin; updatedb = updatedbBin;
}; };
}
];
services.locate = { services.locate = {
enable = true; enable = true;

View file

@ -1,4 +1,8 @@
{neovim-flake, nixpkgs-wayland, ...}: { {
neovim-flake,
nixpkgs-wayland,
...
}: {
imports = [ imports = [
./dracula-theme ./dracula-theme
./regreet ./regreet

View file

@ -1,33 +1,45 @@
{lib, ...}: { {
options.services.device-vars = with lib; { config,
username = mkOption { lib,
...
}: {
options.vars = with lib; {
user = mkOption {
type = types.str;
description = '' description = ''
Username that was defined at the initial setup process Username that was defined at the initial setup process
''; '';
type = types.nullOr types.str; };
hostName = mkOption {
type = types.str;
description = ''
Hostname that was defined at the initial setup process
'';
}; };
configDir = mkOption { configDir = mkOption {
type = types.str;
default = "/home/${config.vars.user}/.nix/devices/${config.vars.hostName}/config";
description = '' description = ''
The path to where most of the devices' configs are in the .nix folder The path to where most of the devices' configs are in the .nix folder
''; '';
type = types.nullOr types.str;
}; };
mainMonitor = mkOption { mainMonitor = mkOption {
type = types.nullOr types.str;
description = '' description = ''
The name of the main monitor used for Hyprland and Regreet The name of the main monitor used for Hyprland and Regreet
''; '';
default = "null"; default = "null";
type = types.nullOr types.str;
}; };
greetdDupe = mkOption { greetdDupe = mkOption {
type = types.nullOr types.bool;
description = '' description = ''
If we should duplicate regreet on all monitors If we should duplicate regreet on all monitors
''; '';
default = true; default = true;
type = types.nullOr types.bool;
}; };
fontSize = mkOption { fontSize = mkOption {

View file

@ -1,4 +1,4 @@
{...}: { {config, ...}: {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
@ -16,15 +16,15 @@
./modules/nvidia.nix ./modules/nvidia.nix
]; ];
services.device-vars = { vars = {
username = "matt"; user = "matt";
configDir = "/home/matt/.nix/devices/binto/config"; hostName = "binto";
mainMonitor = "DP-5"; mainMonitor = "DP-5";
greetdDupe = false; greetdDupe = false;
fontSize = 12.5; fontSize = 12.5;
}; };
users.users.matt = { users.users.${config.vars.user} = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
"wheel" "wheel"
@ -35,23 +35,21 @@
"libvirtd" "libvirtd"
]; ];
}; };
home-manager.users = { home-manager.users.${config.vars.user} = {
matt = { imports = [
imports = [ ../../home/dconf.nix
../../home/dconf.nix ../../home/firefox
../../home/firefox ../../home/hyprland
../../home/hyprland
./home/packages.nix ./home/packages.nix
]; ];
# No touchy # No touchy
home.stateVersion = "23.11"; home.stateVersion = "23.11";
};
}; };
networking = { networking = {
hostName = "binto"; inherit (config.vars) hostName;
networkmanager.enable = true; networkmanager.enable = true;
firewall.enable = false; firewall.enable = false;
}; };

View file

@ -3,8 +3,15 @@
config, config,
... ...
}: let }: let
user = config.services.device-vars.username; hyprland =
hyprland = config.home-manager.users.${user}.wayland.windowManager.hyprland.finalPackage; config
.home-manager
.users
.${config.vars.user}
.wayland
.windowManager
.hyprland
.finalPackage;
in { in {
programs.dconf.enable = true; programs.dconf.enable = true;
@ -21,7 +28,7 @@ in {
settings = { settings = {
initial_session = { initial_session = {
command = "${hyprland}/bin/Hyprland"; command = "${hyprland}/bin/Hyprland";
user = user; user = config.vars.user;
}; };
}; };
}; };

View file

@ -1,4 +1,4 @@
{...}: { {config, ...}: {
imports = [ imports = [
#./hardware-configuration.nix #./hardware-configuration.nix
@ -7,29 +7,28 @@
./modules/headscale.nix ./modules/headscale.nix
]; ];
services.device-vars = { vars = {
username = "matt"; user = "matt";
hostName = "oksys";
}; };
users.users.matt = { users.users.${config.vars.user} = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
"wheel" "wheel"
"adm" "adm"
]; ];
}; };
home-manager.users = { home-manager.users.${config.vars.user} = {
matt = { imports = [];
imports = [];
# No touchy # No touchy
home.stateVersion = "24.05"; home.stateVersion = "24.05";
};
}; };
networking = { networking = {
hostName = "oksys";
networkmanager = { networkmanager = {
inherit (config.vars) hostName;
enable = true; enable = true;
wifi.backend = "wpa_supplicant"; wifi.backend = "wpa_supplicant";
}; };

View file

@ -4,8 +4,6 @@
config, config,
... ...
}: let }: let
user = config.services.device-vars.username;
caddy = caddy-plugins.packages.${pkgs.system}.default; caddy = caddy-plugins.packages.${pkgs.system}.default;
# TODO: use agenix? # TODO: use agenix?
@ -13,7 +11,7 @@
in { in {
imports = [caddy-plugins.nixosModules.default]; imports = [caddy-plugins.nixosModules.default];
environment.systemPackages = [caddy]; environment.systemPackages = [caddy];
users.users.${user}.extraGroups = ["caddy"]; users.users.${config.vars.user}.extraGroups = ["caddy"];
services.caddy = { services.caddy = {
enable = true; enable = true;

View file

@ -5,10 +5,9 @@
... ...
}: let }: let
headscale-flake = headscale.packages.${pkgs.system}.headscale; headscale-flake = headscale.packages.${pkgs.system}.headscale;
user = config.services.device-vars.username;
in { in {
environment.systemPackages = [headscale-flake]; environment.systemPackages = [headscale-flake];
users.users.${user}.extraGroups = ["headscale"]; users.users.${config.vars.user}.extraGroups = ["headscale"];
services.headscale = { services.headscale = {
enable = true; enable = true;

View file

@ -1,10 +1,8 @@
{config, ...}: let {config, ...}: {
user = config.services.device-vars.username;
in {
# https://github.com/MatthewVance/unbound-docker-rpi/issues/4#issuecomment-1001879602 # https://github.com/MatthewVance/unbound-docker-rpi/issues/4#issuecomment-1001879602
boot.kernel.sysctl."net.core.rmem_max" = 1048576; boot.kernel.sysctl."net.core.rmem_max" = 1048576;
users.users.${user}.extraGroups = ["unbound"]; users.users.${config.vars.user}.extraGroups = ["unbound"];
services.unbound = { services.unbound = {
enable = true; enable = true;

View file

@ -1,4 +1,4 @@
{...}: { {config, ...}: {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
@ -15,13 +15,13 @@
./modules/security.nix ./modules/security.nix
]; ];
services.device-vars = { vars = {
username = "matt"; user = "matt";
configDir = "/home/matt/.nix/devices/wim/config"; hostName = "wim";
fontSize = 12.5; fontSize = 12.5;
}; };
users.users.matt = { users.users.${config.vars.user} = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ extraGroups = [
"wheel" "wheel"
@ -32,24 +32,22 @@
"libvirtd" "libvirtd"
]; ];
}; };
home-manager.users = { home-manager.users .${config.vars.user} = {
matt = { imports = [
imports = [ ../../home/dconf.nix
../../home/dconf.nix ../../home/firefox
../../home/firefox ../../home/hyprland
../../home/hyprland
./home/dotfiles.nix ./home/dotfiles.nix
./home/packages.nix ./home/packages.nix
]; ];
# No touchy # No touchy
home.stateVersion = "23.05"; home.stateVersion = "23.05";
};
}; };
networking = { networking = {
hostName = "wim"; inherit (config.vars) hostName;
networkmanager = { networkmanager = {
enable = true; enable = true;
wifi.backend = "wpa_supplicant"; wifi.backend = "wpa_supplicant";

View file

@ -3,7 +3,7 @@
pkgs, pkgs,
... ...
}: let }: let
configDir = config.services.device-vars.configDir; configDir = config.vars.configDir;
symlink = config.lib.file.mkOutOfStoreSymlink; symlink = config.lib.file.mkOutOfStoreSymlink;
in { in {
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
@ -17,7 +17,7 @@ in {
}; };
xdg.configFile = { xdg.configFile = {
"gtklock/config.ini".text = '' "gtklock/config.ini".text = ''
[main] [main]
modules=${builtins.concatStringsSep ";" [ modules=${builtins.concatStringsSep ";" [
"${pkgs.gtklock-powerbar-module}/lib/gtklock/powerbar-module.so" "${pkgs.gtklock-powerbar-module}/lib/gtklock/powerbar-module.so"

View file

@ -3,8 +3,15 @@
config, config,
... ...
}: let }: let
user = config.services.device-vars.username; hyprland =
hyprland = config.home-manager.users.${user}.wayland.windowManager.hyprland.finalPackage; config
.home-manager
.users
.${config.vars.user}
.wayland
.windowManager
.hyprland
.finalPackage;
in { in {
programs.dconf.enable = true; programs.dconf.enable = true;

View file

@ -39,7 +39,7 @@
family = "JetBrainsMono Nerd Font"; family = "JetBrainsMono Nerd Font";
style = "Italic"; style = "Italic";
}; };
size = config.services.device-vars.fontSize; size = config.vars.fontSize;
}; };
# https://github.com/dracula/alacritty/blob/05faff15c0158712be87d200081633d9f4850a7d/dracula.yml # https://github.com/dracula/alacritty/blob/05faff15c0158712be87d200081633d9f4850a7d/dracula.yml

View file

@ -7,11 +7,15 @@
lib, lib,
... ...
}: let }: let
configDir = config.services.device-vars.configDir; # Nix utils
symlink = config.lib.file.mkOutOfStoreSymlink; symlink = config.lib.file.mkOutOfStoreSymlink;
optionals = lib.lists.optionals; optionals = lib.lists.optionals;
# Config stuff
isNvidia = osConfig.hardware.nvidia.modesetting.enable; isNvidia = osConfig.hardware.nvidia.modesetting.enable;
isTouchscreen = osConfig.hardware.sensor.iio.enable; isTouchscreen = osConfig.hardware.sensor.iio.enable;
confPath = "${config.vars.configDir}/hypr/main.conf";
kdeconnect = osConfig.programs.kdeconnect;
gset = pkgs.gsettings-desktop-schemas; gset = pkgs.gsettings-desktop-schemas;
polkit = pkgs.plasma5Packages.polkit-kde-agent; polkit = pkgs.plasma5Packages.polkit-kde-agent;
@ -22,9 +26,10 @@ in {
../wofi ../wofi
]; ];
xdg.configFile = lib.mkIf (configDir != null) { xdg.configFile = with lib;
"hypr/main.conf".source = symlink "${configDir}/hypr/main.conf"; mkIf (pathExists confPath) {
}; "hypr/main.conf".source = symlink confPath;
};
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
enable = true; enable = true;
@ -32,7 +37,7 @@ in {
plugins = plugins =
[] []
++ (optionals (isTouchscreen) [ ++ (optionals isTouchscreen [
hyprgrass.packages.${pkgs.system}.default hyprgrass.packages.${pkgs.system}.default
]); ]);
@ -93,8 +98,8 @@ in {
"swww init --no-cache && swww img -t none ${pkgs.dracula-theme}/wallpapers/waves.png" "swww init --no-cache && swww img -t none ${pkgs.dracula-theme}/wallpapers/waves.png"
"wl-paste --watch cliphist store" "wl-paste --watch cliphist store"
] ]
++ (optionals (osConfig.programs.kdeconnect.enable) [ ++ (optionals (kdeconnect.enable) [
"${osConfig.programs.kdeconnect.package}/libexec/kdeconnectd" "${kdeconnect.package}/libexec/kdeconnectd"
"kdeconnect-indicator" "kdeconnect-indicator"
]) ])
++ (optionals (osConfig.services.gnome.gnome-keyring.enable) [ ++ (optionals (osConfig.services.gnome.gnome-keyring.enable) [
@ -179,7 +184,7 @@ in {
source = source =
[] []
++ optionals (configDir != null) [ ++ optionals (lib.pathExists confPath) [
"~/.config/hypr/main.conf" "~/.config/hypr/main.conf"
]; ];
}; };

View file

@ -4,7 +4,6 @@
config, config,
... ...
}: let }: let
fontSize = config.services.device-vars.fontSize;
dracula-xresources = pkgs.fetchFromGitHub { dracula-xresources = pkgs.fetchFromGitHub {
owner = "dracula"; owner = "dracula";
repo = "xresources"; repo = "xresources";
@ -39,7 +38,7 @@ in {
font = { font = {
name = "Sans Serif"; name = "Sans Serif";
size = fontSize; size = config.vars.fontSize;
}; };
}; };
@ -57,8 +56,8 @@ in {
xdg.configFile = let xdg.configFile = let
qtconf = '' qtconf = ''
[Fonts] [Fonts]
fixed="Sans Serif,${lib.strings.floatToString fontSize},-1,5,50,0,0,0,0,0" fixed="Sans Serif,${lib.strings.floatToString config.vars.fontSize},-1,5,50,0,0,0,0,0"
general="Sans Serif,${lib.strings.floatToString fontSize},-1,5,50,0,0,0,0,0" general="Sans Serif,${lib.strings.floatToString config.vars.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

@ -4,13 +4,12 @@
pkgs, pkgs,
... ...
}: let }: let
vars = config.services.device-vars;
isNvidia = config.hardware.nvidia.modesetting.enable; isNvidia = config.hardware.nvidia.modesetting.enable;
isTouchscreen = config.hardware.sensor.iio.enable; isTouchscreen = config.hardware.sensor.iio.enable;
in { in {
services.upower.enable = true; services.upower.enable = true;
home-manager.users.${vars.username}.imports = [ home-manager.users.${config.vars.user}.imports = [
ags.homeManagerModules.default ags.homeManagerModules.default
({ ({
@ -23,7 +22,7 @@ in {
in { in {
programs.ags = { programs.ags = {
enable = true; enable = true;
configDir = symlink "${vars.configDir}/ags"; configDir = symlink "${config.vars.configDir}/ags";
package = ags.packages.x86_64-linux.default; package = ags.packages.x86_64-linux.default;
extraPackages = [pkgs.libgudev]; extraPackages = [pkgs.libgudev];
}; };

View file

@ -7,17 +7,22 @@
# Nix stuff # Nix stuff
optionals = lib.lists.optionals; optionals = lib.lists.optionals;
isNvidia = config.hardware.nvidia.modesetting.enable; isNvidia = config.hardware.nvidia.modesetting.enable;
vars = config.services.device-vars;
# Executables' paths # Executables' paths
regreetBin = "${lib.getExe config.programs.regreet.package}"; regreetBin = "${lib.getExe config.programs.regreet.package}";
hyprBin = "${config.home-manager.users.${vars.username} hyprBin = "${config
.wayland.windowManager.hyprland.finalPackage}/bin"; .home-manager
.users
.${config.vars.user}
.wayland
.windowManager
.hyprland
.finalPackage}/bin";
# Show Regreet on all monitors # Show Regreet on all monitors
dupeMonitors = pkgs.writeShellScriptBin "dupeMonitors" '' dupeMonitors = pkgs.writeShellScriptBin "dupeMonitors" ''
names=($(${hyprBin}/hyprctl -j monitors | ${pkgs.jq}/bin/jq -r '.[] .name')) names=($(${hyprBin}/hyprctl -j monitors | ${pkgs.jq}/bin/jq -r '.[] .name'))
main="${vars.mainMonitor}" main="${config.vars.mainMonitor}"
if [[ $(echo "$main") == "null" ]]; then if [[ $(echo "$main") == "null" ]]; then
main="''${names[0]}" main="''${names[0]}"
@ -31,8 +36,9 @@
''; '';
# Check if user wants Regreet only on main monitor # Check if user wants Regreet only on main monitor
setupMonitors = if vars.mainMonitor != null && !vars.greetdDupe setupMonitors =
then "${hyprBin}/hyprctl dispatch focusmonitor ${vars.mainMonitor}" if (config.vars.mainMonitor != null && !config.vars.greetdDupe)
then "${hyprBin}/hyprctl dispatch focusmonitor ${config.vars.mainMonitor}"
else "${dupeMonitors}/bin/dupeMonitors"; else "${dupeMonitors}/bin/dupeMonitors";
# Get css for regreet # Get css for regreet

View file

@ -1,6 +1,4 @@
{config, ...}: let {config, ...}: {
vars = config.services.device-vars;
in {
services = { services = {
tailscale = { tailscale = {
enable = true; enable = true;
@ -11,7 +9,7 @@ in {
}; };
}; };
home-manager.users.${vars.username}.programs.bash.shellAliases = { home-manager.users.${config.vars.user}.programs.bash.shellAliases = {
tup = "tailscale up --login-server https://headscale.nelim.org"; tup = "tailscale up --login-server https://headscale.nelim.org";
pc = "mosh matt@binto -- tmux -2u new -At laptop"; pc = "mosh matt@binto -- tmux -2u new -At laptop";