refactor: move common/home to nixosModules/shell
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-11-22 17:58:24 -05:00
parent ae24ae1400
commit 66f415ff5f
30 changed files with 393 additions and 314 deletions

View file

@ -4,8 +4,8 @@ TODO: add directory structure info and enforce it
- every root folder in the repo represents a flake output except inputs - every root folder in the repo represents a flake output except inputs
- every root folder only has a `default.nix` and subfolders for each - every root folder only has a `default.nix` and subfolders for each
of its attrs of its attrs
- in a subfolder, there should always be a `default.nix`. if the - in a subfolder, there should always be a `default.nix`
`config` folders? only nix code folder structure? - if there is non nix code, it will be in a `config` folder
- redo docs - redo docs
## AGS ## AGS

View file

@ -115,7 +115,6 @@ in {
home-manager.users = let home-manager.users = let
inherit (config.vars) mainUser; inherit (config.vars) mainUser;
mainHmCfg = config.home-manager.users.${mainUser};
default = { default = {
imports = [ imports = [
@ -137,23 +136,11 @@ in {
shellAliases.nh = "env -u FLAKE nh"; shellAliases.nh = "env -u FLAKE nh";
}; };
} }
./home
./home/trash-d
self.homeManagerModules.neovim
]; ];
home.stateVersion = config.system.stateVersion; home.stateVersion = config.system.stateVersion;
}; };
in { in {
root =
default
// {
programs.neovim = {
inherit (mainHmCfg.programs.neovim) enable enableIde user;
};
};
greeter = mkIf (config.services.greetd.enable) default; greeter = mkIf (config.services.greetd.enable) default;
${mainUser} = default; ${mainUser} = default;
}; };

View file

@ -1,143 +0,0 @@
{
config,
lib,
...
}: let
inherit (lib) concatStrings fileContents;
inherit (config.vars) promptColors;
in {
imports = [./programs.nix];
programs = {
starship = {
enable = true;
enableBashIntegration = true;
settings = {
format = concatStrings [
""
"[](fg:${promptColors.firstColor})"
"[ ](bg:${promptColors.firstColor} fg:#090c0c)"
"[](bg:${promptColors.secondColor} fg:${promptColors.firstColor})"
"$username$hostname"
"[](fg:${promptColors.secondColor} bg:${promptColors.thirdColor})"
"$directory"
"[](fg:${promptColors.thirdColor} bg:${promptColors.fourthColor})"
"$git_branch"
"[](fg:${promptColors.fourthColor})$shlvl$nix_shell"
"\n$character"
];
username = {
show_always = true;
style_user = "fg:${promptColors.textColor} bg:${promptColors.secondColor}";
style_root = "fg:red bg:${promptColors.secondColor} blink";
format = "[ $user]($style)";
};
hostname = {
ssh_only = false;
style = "fg:${promptColors.textColor} bg:${promptColors.secondColor}";
format = "[@$hostname ]($style)";
};
directory = {
style = "fg:${promptColors.firstColor} bg:${promptColors.thirdColor}";
format = "[ $path ]($style)";
truncate_to_repo = false;
truncation_length = 0;
substitutions = {
"Documents" = "󰈙 ";
"Downloads" = " ";
"Music" = " ";
"Pictures" = " ";
};
};
git_branch = {
style = "fg:${promptColors.secondColor} bg:${promptColors.fourthColor}";
symbol = "";
format = "[ $symbol $branch ]($style)";
};
shlvl = {
disabled = false;
repeat = true;
symbol = "󰔳 ";
format = "[ $symbol]($style)";
threshold = 1;
};
nix_shell = {
symbol = " ";
format = "[ $symbol]($style)";
};
character = {
success_symbol = "[\\$](bold green)";
error_symbol = "[\\$](bold red)";
};
};
};
bash = {
enable = true;
enableCompletion = true;
historyFile = "\$HOME/.cache/.bash_history";
historyFileSize = 100000; # default
historySize = 10000; # default
historyControl = [
"erasedups"
"ignorespace"
];
historyIgnore = [
"ls"
"exit"
"logout"
];
shellOptions = [
"histappend"
"checkwinsize"
"extglob"
"globstar"
"checkjobs"
"autocd"
"cdspell"
"dirspell"
"dotglob"
];
shellAliases = {
# Add whitespace after, to allow
# sudo to inherit all other aliases
sudo = "sudo ";
ls = "ls -lah --color=auto";
tree = "tree -a -I node_modules";
cp = "cp -r";
};
#profileExtra = ''
#'';
bashrcExtra =
# bash
''
# Check if shell is interactive
[[ $- == *i* ]] || return 0
${fileContents ./config/dracula/less.sh}
${fileContents ./config/dracula/fzf.sh}
${fileContents ./config/colorgrid.sh}
${fileContents ./config/bashrc}
'';
#initExtra = ''
#'';
#logoutExtra = ''
#'';
};
};
}

View file

@ -1,8 +0,0 @@
{...}: {
imports = [
./bash
./direnv
./git
./nix-index
];
}

View file

@ -1,11 +0,0 @@
{pkgs, ...}: {
programs.direnv = {
enable = true;
enableBashIntegration = true;
nix-direnv = {
enable = true;
package = pkgs.nix-direnv;
};
};
}

View file

@ -1,11 +0,0 @@
{nix-index-db, ...}: {
imports = [nix-index-db.hmModules.nix-index];
programs = {
nix-index-database.comma.enable = true;
nix-index = {
enable = true;
enableBashIntegration = true;
};
};
}

View file

@ -1,9 +0,0 @@
{
pkgs,
self,
...
}: {
home.packages = [self.packages.${pkgs.system}.trash-d];
programs.bash.shellAliases.rm = "trash";
}

View file

@ -13,32 +13,6 @@ in {
Username that was defined at the initial setup process Username that was defined at the initial setup process
''; '';
}; };
promptMainColor = mkOption {
type = types.enum (import ./prompt-schemes.nix {});
default = "purple";
};
promptColors = mkOption {
description = ''
Colors used in starship prompt
'';
default = import ./prompt-schemes.nix {color = cfg.promptMainColor;};
readOnly = true;
type = types.submodule {
options = let
inherit (types) str;
in {
textColor = mkOption {type = str;};
firstColor = mkOption {type = str;};
secondColor = mkOption {type = str;};
thirdColor = mkOption {type = str;};
fourthColor = mkOption {type = str;};
};
};
};
}; };
config = { config = {

View file

@ -4,6 +4,8 @@
pkgs, pkgs,
... ...
}: { }: {
imports = [./nix-on-droid.nix];
vars.mainUser = "nix-on-droid"; vars.mainUser = "nix-on-droid";
environment.variables.FLAKE = "/data/data/com.termux.nix/files/home/.nix"; environment.variables.FLAKE = "/data/data/com.termux.nix/files/home/.nix";

View file

@ -5,9 +5,12 @@
... ...
}: { }: {
imports = [ imports = [
./vars ../../common/vars
./modules/global.nix ../../common/modules/global.nix
./packages.nix ../../common/packages.nix
self.nixosModules.tmux
{programs.tmux.enableCustomConf = true;}
]; ];
nix = { nix = {
@ -41,8 +44,11 @@
}; };
} }
./home
self.homeManagerModules.neovim self.homeManagerModules.neovim
{programs.neovim.enable = true;}
self.homeManagerModules.shell
{programs.bash.enable = true;}
{ {
programs.bash.sessionVariables = { programs.bash.sessionVariables = {

View file

@ -24,10 +24,7 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# User Settings # User Settings
# ------------------------------------------------ # ------------------------------------------------
vars = { vars.mainUser = "mariah";
mainUser = "mariah";
promptMainColor = "pink";
};
users.users.${mainUser} = { users.users.${mainUser} = {
isNormalUser = true; isNormalUser = true;
@ -58,4 +55,17 @@ in {
}; };
services.kmscon.enable = true; services.kmscon.enable = true;
home-manager.users.${mainUser} = {
imports = [
self.homeManagerModules.shell
];
programs = {
bash = {
enable = true;
promptMainColor = "pink";
};
};
};
} }

View file

@ -25,10 +25,7 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# User Settings # User Settings
# ------------------------------------------------ # ------------------------------------------------
vars = { vars.mainUser = "matt";
mainUser = "matt";
promptMainColor = "purple";
};
users.users.${mainUser} = { users.users.${mainUser} = {
isNormalUser = true; isNormalUser = true;
@ -79,12 +76,21 @@ in {
home-manager.users.${mainUser} = { home-manager.users.${mainUser} = {
imports = [ imports = [
self.homeManagerModules.firefox self.homeManagerModules.firefox
self.homeManagerModules.neovim
self.homeManagerModules.shell
]; ];
programs.neovim = { programs = {
enable = true; bash = {
enableIde = true; enable = true;
user = mainUser; promptMainColor = "purple";
};
neovim = {
enable = true;
enableIde = true;
user = mainUser;
};
}; };
}; };
} }

View file

@ -25,15 +25,7 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# User Settings # User Settings
# ------------------------------------------------ # ------------------------------------------------
vars = { vars.mainUser = "matt";
mainUser = "matt";
promptMainColor =
if deviceName == "thingone"
then "green"
else if deviceName == "thingtwo"
then "red"
else "purple";
};
users.users.${mainUser} = { users.users.${mainUser} = {
isNormalUser = true; isNormalUser = true;
@ -71,12 +63,27 @@ in {
services.kmscon.enable = true; services.kmscon.enable = true;
home-manager.users.${mainUser} = { home-manager.users.${mainUser} = {
imports = []; imports = [
self.homeManagerModules.neovim
self.homeManagerModules.shell
];
programs.neovim = { programs = {
enable = true; bash = {
enableIde = true; enable = true;
user = mainUser; promptMainColor =
if deviceName == "thingone"
then "green"
else if deviceName == "thingtwo"
then "red"
else "purple";
};
neovim = {
enable = true;
enableIde = true;
user = mainUser;
};
}; };
}; };
} }

View file

@ -24,10 +24,7 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# User Settings # User Settings
# ------------------------------------------------ # ------------------------------------------------
vars = { vars.mainUser = "matt";
mainUser = "matt";
promptMainColor = "yellow";
};
users.users.${mainUser} = { users.users.${mainUser} = {
isNormalUser = true; isNormalUser = true;
@ -58,12 +55,22 @@ in {
services.kmscon.enable = true; services.kmscon.enable = true;
home-manager.users.${mainUser} = { home-manager.users.${mainUser} = {
imports = []; imports = [
self.homeManagerModules.neovim
self.homeManagerModules.shell
];
programs.neovim = { programs = {
enable = true; bash = {
enableIde = true; enable = true;
user = mainUser; promptMainColor = "yellow";
};
neovim = {
enable = true;
enableIde = true;
user = mainUser;
};
}; };
}; };
} }

View file

@ -24,10 +24,7 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# User Settings # User Settings
# ------------------------------------------------ # ------------------------------------------------
vars = { vars.mainUser = "matt";
mainUser = "matt";
promptMainColor = "orange";
};
users.users.${mainUser} = { users.users.${mainUser} = {
isNormalUser = true; isNormalUser = true;
@ -58,12 +55,22 @@ in {
services.kmscon.enable = true; services.kmscon.enable = true;
home-manager.users.${mainUser} = { home-manager.users.${mainUser} = {
imports = []; imports = [
self.homeManagerModules.neovim
self.homeManagerModules.shell
];
programs.neovim = { programs = {
enable = true; bash = {
enableIde = true; enable = true;
user = mainUser; promptMainColor = "orange";
};
neovim = {
enable = true;
enableIde = true;
user = mainUser;
};
}; };
}; };
} }

View file

@ -24,10 +24,7 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# User Settings # User Settings
# ------------------------------------------------ # ------------------------------------------------
vars = { vars.mainUser = "matt";
mainUser = "matt";
promptMainColor = "blue";
};
users.users = { users.users = {
${mainUser} = { ${mainUser} = {
@ -72,12 +69,22 @@ in {
services.kmscon.enable = true; services.kmscon.enable = true;
home-manager.users.${mainUser} = { home-manager.users.${mainUser} = {
imports = []; imports = [
self.homeManagerModules.neovim
self.homeManagerModules.shell
];
programs.neovim = { programs = {
enable = true; bash = {
enableIde = true; enable = true;
user = mainUser; promptMainColor = "blue";
};
neovim = {
enable = true;
enableIde = true;
user = mainUser;
};
}; };
}; };
} }

View file

@ -28,10 +28,7 @@ in {
# ------------------------------------------------ # ------------------------------------------------
# User Settings # User Settings
# ------------------------------------------------ # ------------------------------------------------
vars = { vars.mainUser = "matt";
mainUser = "matt";
promptMainColor = "purple";
};
users.users.${mainUser} = { users.users.${mainUser} = {
isNormalUser = true; isNormalUser = true;
@ -98,12 +95,21 @@ in {
home-manager.users.${mainUser} = { home-manager.users.${mainUser} = {
imports = [ imports = [
self.homeManagerModules.firefox self.homeManagerModules.firefox
self.homeManagerModules.neovim
self.homeManagerModules.shell
]; ];
programs.neovim = { programs = {
enable = true; bash = {
enableIde = true; enable = true;
user = mainUser; promptMainColor = "purple";
};
neovim = {
enable = true;
enableIde = true;
user = mainUser;
};
}; };
}; };
} }

View file

@ -1,4 +1,5 @@
self: { self: {
firefox = import ./firefox self; firefox = import ./firefox self;
neovim = import ./neovim self; neovim = import ./neovim self;
shell = import ./shell self;
} }

View file

@ -0,0 +1,108 @@
self: {
config,
lib,
...
}: let
inherit (lib) fileContents mkIf mkOption types;
cfg = config.programs.bash;
in {
imports = [
./starship
(import ./git self)
(import ./misc self)
(import ./nix-tools self)
(import ./trash self)
];
options.programs.bash = {
promptMainColor = mkOption {
type = types.enum (import ./prompt-schemes.nix {});
default = "purple";
};
promptColors = mkOption {
description = ''
Colors used in starship prompt
'';
default = import ./prompt-schemes.nix {color = cfg.promptMainColor;};
readOnly = true;
type = types.submodule {
options = let
inherit (types) str;
in {
textColor = mkOption {type = str;};
firstColor = mkOption {type = str;};
secondColor = mkOption {type = str;};
thirdColor = mkOption {type = str;};
fourthColor = mkOption {type = str;};
};
};
};
};
config = mkIf cfg.enable {
programs.bash = {
enableCompletion = true;
historyFile = "\$HOME/.cache/.bash_history";
historyFileSize = 100000; # default
historySize = 10000; # default
historyControl = [
"erasedups"
"ignorespace"
];
historyIgnore = [
"ls"
"exit"
"logout"
];
shellOptions = [
"histappend"
"checkwinsize"
"extglob"
"globstar"
"checkjobs"
"autocd"
"cdspell"
"dirspell"
"dotglob"
];
shellAliases = {
# Add whitespace after, to allow
# sudo to inherit all other aliases
sudo = "sudo ";
ls = "ls -lah --color=auto";
tree = "tree -a -I node_modules";
cp = "cp -r";
};
#profileExtra = ''
#'';
bashrcExtra =
# bash
''
# Check if shell is interactive
[[ $- == *i* ]] || return 0
${fileContents ./config/dracula/less.sh}
${fileContents ./config/dracula/fzf.sh}
${fileContents ./config/colorgrid.sh}
${fileContents ./config/bashrc}
'';
#initExtra = ''
#'';
#logoutExtra = ''
#'';
};
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -1,15 +1,20 @@
{ self: {
config,
lib,
pkgs, pkgs,
self,
... ...
}: let }: let
inherit (lib) mkIf;
cfg = config.programs.bash;
mkRemoteConf = remote: email: name: { mkRemoteConf = remote: email: name: {
condition = "hasconfig:remote.*.url:${remote}:*/**"; condition = "hasconfig:remote.*.url:${remote}:*/**";
contents.user = {inherit email name;}; contents.user = {inherit email name;};
}; };
mkDefaultRemote = remote: mkRemoteConf remote "matt@nelim.org" "matt1432"; mkDefaultRemote = remote: mkRemoteConf remote "matt@nelim.org" "matt1432";
in { in {
programs = { config.programs = mkIf cfg.enable {
git = { git = {
enable = true; enable = true;
package = pkgs.gitFull; package = pkgs.gitFull;
@ -59,20 +64,6 @@ in {
}; };
}; };
home.packages = [ # For accurate stack trace
(pkgs.writeShellApplication { _file = ./default.nix;
name = "chore";
runtimeInputs = [pkgs.git];
text = ''
DIR=''${1:-"$FLAKE"}
cd "$DIR" || exit 1
git add flake.lock
git commit -m 'chore: update flake.lock'
git push
'';
})
];
} }

View file

@ -1,10 +1,14 @@
{ self: {
pkgs,
config, config,
self, lib,
pkgs,
... ...
}: { }: let
programs = { inherit (lib) mkIf;
cfg = config.programs.bash;
in {
config.programs = mkIf cfg.enable {
fzf = { fzf = {
enable = true; enable = true;
enableBashIntegration = true; enableBashIntegration = true;
@ -51,4 +55,7 @@
}; };
}; };
}; };
# For accurate stack trace
_file = ./default.nix;
} }

View file

@ -0,0 +1,35 @@
self: {
config,
lib,
pkgs,
...
}: let
inherit (lib) mkIf;
inherit (self.inputs) nix-index-db;
cfg = config.programs.bash;
in {
imports = [nix-index-db.hmModules.nix-index];
config.programs = mkIf cfg.enable {
direnv = {
enable = true;
enableBashIntegration = true;
nix-direnv = {
enable = true;
package = pkgs.nix-direnv;
};
};
nix-index-database.comma.enable = true;
nix-index = {
enable = true;
enableBashIntegration = true;
};
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -0,0 +1,81 @@
{
config,
lib,
...
}: let
inherit (lib) concatStrings mkIf;
cfg = config.programs.bash;
in {
programs.starship = mkIf cfg.enable {
enable = true;
enableBashIntegration = true;
settings = {
format = concatStrings [
""
"[](fg:${cfg.promptColors.firstColor})"
"[ ](bg:${cfg.promptColors.firstColor} fg:#090c0c)"
"[](bg:${cfg.promptColors.secondColor} fg:${cfg.promptColors.firstColor})"
"$username$hostname"
"[](fg:${cfg.promptColors.secondColor} bg:${cfg.promptColors.thirdColor})"
"$directory"
"[](fg:${cfg.promptColors.thirdColor} bg:${cfg.promptColors.fourthColor})"
"$git_branch"
"[](fg:${cfg.promptColors.fourthColor})$shlvl$nix_shell"
"\n$character"
];
username = {
show_always = true;
style_user = "fg:${cfg.promptColors.textColor} bg:${cfg.promptColors.secondColor}";
style_root = "fg:red bg:${cfg.promptColors.secondColor} blink";
format = "[ $user]($style)";
};
hostname = {
ssh_only = false;
style = "fg:${cfg.promptColors.textColor} bg:${cfg.promptColors.secondColor}";
format = "[@$hostname ]($style)";
};
directory = {
style = "fg:${cfg.promptColors.firstColor} bg:${cfg.promptColors.thirdColor}";
format = "[ $path ]($style)";
truncate_to_repo = false;
truncation_length = 0;
substitutions = {
"Documents" = "󰈙 ";
"Downloads" = " ";
"Music" = " ";
"Pictures" = " ";
};
};
git_branch = {
style = "fg:${cfg.promptColors.secondColor} bg:${cfg.promptColors.fourthColor}";
symbol = "";
format = "[ $symbol $branch ]($style)";
};
shlvl = {
disabled = false;
repeat = true;
symbol = "󰔳 ";
format = "[ $symbol]($style)";
threshold = 1;
};
nix_shell = {
symbol = " ";
format = "[ $symbol]($style)";
};
character = {
success_symbol = "[\\$](bold green)";
error_symbol = "[\\$](bold red)";
};
};
};
}

View file

@ -0,0 +1,21 @@
self: {
config,
lib,
pkgs,
...
}: let
inherit (lib) elem mkIf;
cfg = config.programs.bash;
trashPkg = self.packages.${pkgs.system}.trash-d;
isCorrectPlatform = elem pkgs.system (trashPkg.meta.platforms or [pkgs.system]);
in {
config = mkIf (cfg.enable && isCorrectPlatform) {
home.packages = [trashPkg];
programs.bash.shellAliases.rm = "trash";
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -85,8 +85,6 @@ inputs: rec {
}) })
{home-manager = {inherit extraSpecialArgs;};} {home-manager = {inherit extraSpecialArgs;};}
../../common/nix-on-droid.nix
] ]
++ extraModules; ++ extraModules;
}; };