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 only has a `default.nix` and subfolders for each
of its attrs
- in a subfolder, there should always be a `default.nix`. if the
`config` folders? only nix code folder structure?
- in a subfolder, there should always be a `default.nix`
- if there is non nix code, it will be in a `config` folder
- redo docs
## AGS

View file

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

View file

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

View file

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

View file

@ -24,10 +24,7 @@ in {
# ------------------------------------------------
# User Settings
# ------------------------------------------------
vars = {
mainUser = "mariah";
promptMainColor = "pink";
};
vars.mainUser = "mariah";
users.users.${mainUser} = {
isNormalUser = true;
@ -58,4 +55,17 @@ in {
};
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
# ------------------------------------------------
vars = {
mainUser = "matt";
promptMainColor = "purple";
};
vars.mainUser = "matt";
users.users.${mainUser} = {
isNormalUser = true;
@ -79,12 +76,21 @@ in {
home-manager.users.${mainUser} = {
imports = [
self.homeManagerModules.firefox
self.homeManagerModules.neovim
self.homeManagerModules.shell
];
programs.neovim = {
programs = {
bash = {
enable = true;
promptMainColor = "purple";
};
neovim = {
enable = true;
enableIde = true;
user = mainUser;
};
};
};
}

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,5 @@
self: {
firefox = import ./firefox 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,
self,
...
}: let
inherit (lib) mkIf;
cfg = config.programs.bash;
mkRemoteConf = remote: email: name: {
condition = "hasconfig:remote.*.url:${remote}:*/**";
contents.user = {inherit email name;};
};
mkDefaultRemote = remote: mkRemoteConf remote "matt@nelim.org" "matt1432";
in {
programs = {
config.programs = mkIf cfg.enable {
git = {
enable = true;
package = pkgs.gitFull;
@ -59,20 +64,6 @@ in {
};
};
home.packages = [
(pkgs.writeShellApplication {
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
'';
})
];
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -1,10 +1,14 @@
{
pkgs,
self: {
config,
self,
lib,
pkgs,
...
}: {
programs = {
}: let
inherit (lib) mkIf;
cfg = config.programs.bash;
in {
config.programs = mkIf cfg.enable {
fzf = {
enable = 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;};}
../../common/nix-on-droid.nix
]
++ extraModules;
};