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

View file

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

View file

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

View file

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

View file

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