feat: decent shell configuration with starship and zsh

direnv and devenv integrated support
experimental nginx test configuration
sway and foot configuration updated
created initial sddm configuration for login manager
This commit is contained in:
Zhongheng Liu 2024-08-01 18:05:58 +08:00
commit 4fe4ebefc8
14 changed files with 529 additions and 4 deletions

View file

@ -1,4 +1,4 @@
# This is your home-manager configuration file
#his is your home-manager configuration file
# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix)
{
inputs,
@ -18,7 +18,8 @@ in
# inputs.nix-colors.homeManagerModule
# You can also split up your configuration and import pieces of it here:
# ./nvim.nix
./swaywm.nix
./shells
];
nixpkgs = {
@ -48,7 +49,10 @@ in
homeDirectory = "/home/${myUserName}";
};
programs.neovim.enable = true;
home.packages = with pkgs; [ protonvpn-gui ];
home.packages = with pkgs; [
protonvpn-gui
devenv
];
programs.home-manager.enable = true;
programs.git.enable = true;
programs.firefox.enable = true;

View file

@ -0,0 +1,10 @@
{pkgs}: {
cd = "z";
cdi = "zi";
ls = "${pkgs.eza}/bin/exa";
cat = "${pkgs.bat}/bin/bat";
ll = "ls -l";
osupdate = "${pkgs.nh}/bin/nh os switch";
homeupdate = "${pkgs.nh}/bin/nh home switch";
batmon = "watch -n0 upower -i /org/freedesktop/UPower/devices/battery_BAT1";
}

View file

@ -0,0 +1,28 @@
{
pkgs,
lib,
config,
...
}: let
cfg = config.myShells;
in
with lib; {
imports = [
./zsh.nix
./direnv.nix
./starship
];
options.myShells = {
enable = mkEnableOption "Enables the shell customisation module.";
useZsh = mkOption {
type = types.bool;
default = true;
};
};
config = mkIf cfg.enable {
myShells = {
zsh.enable = cfg.useZsh;
prompts.starship.enable = true;
};
};
}

View file

@ -0,0 +1,8 @@
{...}: {
programs = {
direnv = {
enable = true;
nix-direnv.enable = true;
};
};
}

View file

@ -0,0 +1,24 @@
{
lib,
pkgs,
config,
...
}: let
cfg = config.myShells.prompts.starship;
in
with lib; {
options = {
myShells.prompts.starship.enable = mkEnableOption "Enables starship prompts.";
myShells.prompts.starship.confPath = mkOption {
type = types.path;
default = ./presets/default.toml;
};
};
config = {
programs.starship = {
enable = true;
enableZshIntegration = true;
settings = builtins.fromTOML (builtins.readFile cfg.confPath);
};
};
}

View file

@ -0,0 +1,172 @@
"$schema" = 'https://starship.rs/config-schema.json'
format = """
$direnv[](color_orange)\
$os\
$username\
[](bg:color_yellow fg:color_orange)\
$directory\
[](fg:color_yellow bg:color_aqua)\
$git_branch\
$git_status\
[](fg:color_aqua bg:color_blue)\
$c\
$rust\
$golang\
$nodejs\
$php\
$java\
$kotlin\
$haskell\
$python\
[](fg:color_blue bg:color_bg3)\
$docker_context\
$conda\
[](fg:color_bg3 bg:color_bg1)\
$time\
[ ](fg:color_bg1)\
$line_break$character"""
palette = 'gruvbox_dark'
[palettes.gruvbox_dark]
color_fg0 = '#fbf1c7'
color_bg1 = '#3c3836'
color_bg3 = '#665c54'
color_blue = '#458588'
color_aqua = '#689d6a'
color_green = '#98971a'
color_orange = '#d65d0e'
color_purple = '#b16286'
color_red = '#cc241d'
color_yellow = '#d79921'
[os]
disabled = false
style = "bg:color_orange fg:color_fg0"
[os.symbols]
Windows = "󰍲"
Ubuntu = "󰕈"
SUSE = ""
Raspbian = "󰐿"
Mint = "󰣭"
Macos = "󰀵"
Manjaro = ""
Linux = "󰌽"
Gentoo = "󰣨"
Fedora = "󰣛"
Alpine = ""
Amazon = ""
Android = ""
Arch = "󰣇"
Artix = "󰣇"
CentOS = ""
Debian = "󰣚"
Redhat = "󱄛"
RedHatEnterprise = "󱄛"
[direnv]
disabled = false
#command = '[[ $(direnv status) =~ "Found RC allowed false" ]] && echo "=========> missing: direnv allow <============"' # shows output of command
detect_files = ['.envrc'] # can specify filters but wildcards are not supported
[username]
show_always = true
style_user = "bg:color_orange fg:color_fg0"
style_root = "bg:color_orange fg:color_fg0"
format = '[ $user ]($style)'
[directory]
style = "fg:color_fg0 bg:color_yellow"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"
[directory.substitutions]
"Documents" = "󰈙 "
"Downloads" = " "
"Music" = "󰝚 "
"Pictures" = " "
"Developer" = "󰲋 "
[git_branch]
symbol = ""
style = "bg:color_aqua"
format = '[[ $symbol $branch ](fg:color_fg0 bg:color_aqua)]($style)'
[git_status]
style = "bg:color_aqua"
format = '[[($all_status$ahead_behind )](fg:color_fg0 bg:color_aqua)]($style)'
[nodejs]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[c]
symbol = " "
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[rust]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[golang]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[php]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[java]
symbol = " "
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[kotlin]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[haskell]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[python]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[docker_context]
symbol = ""
style = "bg:color_bg3"
format = '[[ $symbol( $context) ](fg:#83a598 bg:color_bg3)]($style)'
[conda]
style = "bg:color_bg3"
format = '[[ $symbol( $environment) ](fg:#83a598 bg:color_bg3)]($style)'
[time]
disabled = false
time_format = "%R"
style = "bg:color_bg1"
format = '[[  $time ](fg:color_fg0 bg:color_bg1)]($style)'
[line_break]
disabled = false
[character]
disabled = false
success_symbol = '[](bold fg:color_green)'
error_symbol = '[](bold fg:color_red)'
vimcmd_symbol = '[](bold fg:color_green)'
vimcmd_replace_one_symbol = '[](bold fg:color_purple)'
vimcmd_replace_symbol = '[](bold fg:color_purple)'
vimcmd_visual_symbol = '[](bold fg:color_yellow)'

View file

@ -0,0 +1,167 @@
"$schema" = 'https://starship.rs/config-schema.json'
format = """
[](color_orange)\
$os\
$username\
[](bg:color_yellow fg:color_orange)\
$directory\
[](fg:color_yellow bg:color_aqua)\
$git_branch\
$git_status\
[](fg:color_aqua bg:color_blue)\
$c\
$rust\
$golang\
$nodejs\
$php\
$java\
$kotlin\
$haskell\
$python\
[](fg:color_blue bg:color_bg3)\
$docker_context\
$conda\
[](fg:color_bg3 bg:color_bg1)\
$time\
[ ](fg:color_bg1)\
$line_break$character"""
palette = 'gruvbox_dark'
[palettes.gruvbox_dark]
color_fg0 = '#fbf1c7'
color_bg1 = '#3c3836'
color_bg3 = '#665c54'
color_blue = '#458588'
color_aqua = '#689d6a'
color_green = '#98971a'
color_orange = '#d65d0e'
color_purple = '#b16286'
color_red = '#cc241d'
color_yellow = '#d79921'
[os]
disabled = false
style = "bg:color_orange fg:color_fg0"
[os.symbols]
Windows = "󰍲"
Ubuntu = "󰕈"
SUSE = ""
Raspbian = "󰐿"
Mint = "󰣭"
Macos = "󰀵"
Manjaro = ""
Linux = "󰌽"
Gentoo = "󰣨"
Fedora = "󰣛"
Alpine = ""
Amazon = ""
Android = ""
Arch = "󰣇"
Artix = "󰣇"
CentOS = ""
Debian = "󰣚"
Redhat = "󱄛"
RedHatEnterprise = "󱄛"
[username]
show_always = true
style_user = "bg:color_orange fg:color_fg0"
style_root = "bg:color_orange fg:color_fg0"
format = '[ $user ]($style)'
[directory]
style = "fg:color_fg0 bg:color_yellow"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"
[directory.substitutions]
"Documents" = "󰈙 "
"Downloads" = " "
"Music" = "󰝚 "
"Pictures" = " "
"Developer" = "󰲋 "
[git_branch]
symbol = ""
style = "bg:color_aqua"
format = '[[ $symbol $branch ](fg:color_fg0 bg:color_aqua)]($style)'
[git_status]
style = "bg:color_aqua"
format = '[[($all_status$ahead_behind )](fg:color_fg0 bg:color_aqua)]($style)'
[nodejs]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[c]
symbol = " "
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[rust]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[golang]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[php]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[java]
symbol = " "
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[kotlin]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[haskell]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[python]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'
[docker_context]
symbol = ""
style = "bg:color_bg3"
format = '[[ $symbol( $context) ](fg:#83a598 bg:color_bg3)]($style)'
[conda]
style = "bg:color_bg3"
format = '[[ $symbol( $environment) ](fg:#83a598 bg:color_bg3)]($style)'
[time]
disabled = false
time_format = "%R"
style = "bg:color_bg1"
format = '[[  $time ](fg:color_fg0 bg:color_bg1)]($style)'
[line_break]
disabled = false
[character]
disabled = false
success_symbol = '[](bold fg:color_green)'
error_symbol = '[](bold fg:color_red)'
vimcmd_symbol = '[](bold fg:color_green)'
vimcmd_replace_one_symbol = '[](bold fg:color_purple)'
vimcmd_replace_symbol = '[](bold fg:color_purple)'
vimcmd_visual_symbol = '[](bold fg:color_yellow)'

View file

@ -0,0 +1,36 @@
{
pkgs,
lib,
config,
...
}: let
cfg = config.shell.zsh;
in
with lib; {
options.myShells.zsh = {
enable = mkEnableOption "Enables zsh and components.";
};
config = {
programs.zsh = {
enable = true;
syntaxHighlighting.enable = true;
shellAliases = import ./aliases {inherit pkgs;};
dirHashes = {
docs = "$HOME/Documents";
dl = "$HOME/Downloads";
dev = "$HOME/devel";
screen = "$HOME/Pictures/Screenshots";
};
oh-my-zsh = {
enable = true;
plugins = [
"git"
"rsync"
"zoxide"
];
theme = "agnoster";
};
};
home.packages = with pkgs; [zoxide];
};
}

View file

@ -0,0 +1,10 @@
{pkgs, lib, ...}:
{
wayland.windowManager.sway = {
enable = true;
config = rec {
modifier = "Mod4";
terminal = "${pkgs.foot}/bin/foot -f 'BlexMono Nerd Font:size=24' zsh";
};
};
}

View file

@ -10,7 +10,10 @@
{
imports = [
./variables.nix
./nvidia.nix
#./greetd-sway.nix
#./nvidia.nix
./fonts.nix
./services/nginx.service.nix
./hardware-configuration.nix
];
boot.loader = {
@ -31,6 +34,18 @@
'';
};
};
services.displayManager.sddm = {
enable = true;
wayland.enable = true;
};
systemd.user.services.kanshi = {
description = "kanshi daemon";
serviceConfig = {
Type = "simple";
ExecStart = ''${pkgs.kanshi}/bin/kanshi -c kanshi_config_file'';
};
};
security.polkit.enable = true;
services.gnome.gnome-keyring.enable = true;
programs.sway = {
@ -53,6 +68,7 @@
flake-registry = "";
nix-path = config.nix.nixPath;
};
channel.enable = false;
registry = lib.mapAttrs (_: flake: {inherit flake;}) flakeInputs;
nixPath = lib.mapAttrsToList (n: _: "${n}=flake:${n}") flakeInputs;
};
@ -79,6 +95,7 @@
PasswordAuthentication = false;
};
};
services.automatic-timezoned.enable = true;
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
system.stateVersion = "24.05";
}

29
nixos/fonts.nix Normal file
View file

@ -0,0 +1,29 @@
{pkgs, ...}: {
fonts.packages = with pkgs; [
#helvetica-neue-lt-std
aileron
#corefonts
#vistafonts
#vistafonts-chs
noto-fonts
#noto-fonts-cjk
noto-fonts-emoji
#liberation_ttf
#mplus-outline-fonts.githubRelease
#dina-font
#proggyfonts
#glasstty-ttf
(
nerdfonts.override {
fonts = [
"FiraCode"
"IBMPlexMono"
#"IntelOneMono"
#"CascadiaMono"
#"CommitMono"
#"JetBrainsMono"
];
}
)
];
}

10
nixos/greetd-sway.nix Normal file
View file

@ -0,0 +1,10 @@
{pkgs, config, lib, ...}: {
services.greetd = {
enable = true;
settings = {
default_session = {
command = "${pkgs.sway}/bin/sway";
};
};
};
}

View file

@ -14,6 +14,10 @@
};
};
};
hardware.opengl = {
enable = true;
};
services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia = {
prime = {
offload.enable = false;

View file

@ -0,0 +1,6 @@
{...}:
{
services.nginx = {
enable = true;
};
}