Modularize programs and add starship

This commit is contained in:
DashieTM 2024-08-06 12:40:16 +02:00
parent 1a0064894d
commit 44ac35d6e2
24 changed files with 646 additions and 530 deletions

View file

@ -3,6 +3,5 @@
./env.nix
./xkb_layout.nix
./common_hardware.nix
./theme.nix
];
}

View file

@ -1,8 +0,0 @@
{ lib, config, ... }: {
# imports = lib.mkIf config.conf.default_base_packages.enable [
imports = [
# is wrapped in if statement to enable when needed
../programs/gaming/default.nix
../programs/themes/stylix.nix
];
}

View file

@ -10,9 +10,9 @@
device = 1;
};
hostname = "marmo";
colorscheme = "catppuccin-mocha";
};
mods = {
stylix.colorscheme = "catppuccin-mocha";
hyprland.monitor = [
# default
"DP-1,1920x1080@144,0x0,1"

View file

@ -10,9 +10,9 @@
ironbar.modules = [
{ type = "upower"; class = "memory-usage"; }
];
colorscheme = "catppuccin-mocha";
};
mods = {
stylix.colorscheme = "catppuccin-mocha";
hyprland = {
monitor = [
# default

View file

@ -15,9 +15,9 @@ in
};
streamdeck.enable = true;
hostname = "spaceship";
colorscheme = "catppuccin-mocha";
};
mods = {
stylix.colorscheme = "catppuccin-mocha";
hyprland = {
monitor = [
# default

View file

@ -173,43 +173,6 @@
'';
};
colorscheme = lib.mkOption {
default = {
# custom tokyo night
base00 = "1A1B26";
# base01 = "16161E";
# base01 = "15161e";
base01 = "191a25";
base02 = "2F3549";
base03 = "444B6A";
base04 = "787C99";
base05 = "A9B1D6";
base06 = "CBCCD1";
base07 = "D5D6DB";
base08 = "C0CAF5";
base09 = "A9B1D6";
base0A = "0DB9D7";
base0B = "9ECE6A";
base0C = "B4F9F8";
# base0D = "2AC3DE";
# base0D = "A9B1D6";
# base0D = "62A0EA";
# base0D = "779EF1";
base0D = "366fea";
base0E = "BB9AF7";
base0F = "F7768E";
};
example = "catppuccin-mocha";
type = with lib.types; oneOf [ str attrs path ];
description = ''
Base16 colorscheme.
Can be an attribute set with base00 to base0F,
a string that leads to a yaml file in base16-schemes path,
or a path to a custom yaml file.
'';
};
};
config = {

View file

@ -77,97 +77,6 @@
nssmdns4 = true;
openFirewall = true;
};
programs.starship =
let
base16 = pkgs.callPackage inputs.base16.lib { };
scheme = (base16.mkSchemeAttrs config.stylix.base16Scheme);
code_format = "[](bg:prev_bg fg:#5256c3)[ $symbol ($version)](bg:#5256c3)";
in
{
enable = true;
interactiveOnly = true;
presets = [ "pastel-powerline" ];
settings =
{
# derived from https://starship.rs/presets/pastel-powerline
format = ''$username$directory$git_branch$git_status$git_metrics[ ](bg:none fg:prev_bg)'';
right_format = ''$c$elixir$elm$golang$gradle$haskell$java$julia$nodejs$nim$rust$scala$python$ocaml$opa$perl$zig$dart$dotnet$nix_shell$shell$solidity[](bg:prev_bg fg:#3465A4)$time$os'';
username = {
show_always = false;
style_user = "bg:#5277C3 fg:#${scheme.base05}";
style_root = "bg:#5277C3 fg:#${scheme.base05}";
format = "[ $user ]($style)[](bg:#3465A4 fg:#5277C3)";
disabled = false;
};
os = {
symbols = { NixOS = " "; };
style = "bg:#3465A4 fg:#${scheme.base05}";
disabled = false;
};
directory = {
style = "bg:#3465A4 fg:#${scheme.base05}";
format = "[ $path ]($style)";
truncation_length = 3;
truncation_symbol = "/";
};
git_branch = {
symbol = "";
style = "bg:#5256c3 fg:#${scheme.base05}";
format = "[ ](bg:#5256c3 fg:prev_bg)[$symbol $branch ]($style)";
};
git_status = {
staged = "+\${count} (fg:#C4A000)";
ahead = "\${count} (fg:#C4A000)";
diverged = "\${count} (fg:#C4A000)";
behind = "\${count} (fg:#C4A000)";
stashed = " ";
untracked = "?\${count} (fg:#C4A000)";
modified = "!\${count} (fg:#C4A000)";
deleted = "\${count} (fg:#C4A000)";
conflicted = "=\${count} (fg:#C4A000)";
renamed = "»\${count} (fg:#C4A000)";
style = "bg:#5256c3 fg:fg:#C4A000";
format = "[$all_status$ahead_behind]($style)";
};
git_metrics = {
disabled = false;
format = "([| ](bg:#5256c3)[+$added]($added_style bg:#5256c3)[ -$deleted]($deleted_style bg:#5256c3))";
};
c = { format = code_format; };
elixir = { format = code_format; };
elm = { format = code_format; };
golang = { format = code_format; };
gradle = { format = code_format; };
haskell = { format = code_format; };
java = { format = code_format; };
julia = { format = code_format; };
nodejs = { format = code_format; };
nim = { format = code_format; };
nix_shell = { symbol = ""; format = code_format; };
rust = { format = code_format; };
scala = { format = code_format; };
typst = { format = code_format; };
python = { format = code_format; };
ocaml = { format = code_format; };
opa = { format = code_format; };
perl = { format = code_format; };
zig = { format = code_format; };
dart = { format = code_format; };
dotnet = { format = code_format; };
# docker_context = {
# symbol = " ";
# style = "bg:#06969A";
# format = "[](bg:#06969A fg:prev_bg)[ $symbol $context ]($style)";
# };
time = {
disabled = false;
time_format = "%R"; # Hour:Minute Format
style = "bg:#3465A4 fg:#${scheme.base05}";
format = "[ $time ]($style)";
};
};
};
programs.fish.enable = true;
programs.fish.promptInit = ''

View file

@ -23,7 +23,7 @@
config = lib.mkIf config.mods.coding.enable (lib.optionalAttrs (options?home.packages) {
programs.dashvim = lib.mkIf config.mods.coding.dashvim {
enable = true;
colorscheme = config.conf.colorscheme;
colorscheme = config.mods.stylix.colorscheme;
};
home.packages = with pkgs; [
#basics

View file

@ -18,6 +18,11 @@
./coding.nix
./flatpak.nix
./nextcloud.nix
./starship.nix
./git.nix
./keepassxc.nix
./gaming.nix
./stylix.nix
./hyprland
];
}

View file

@ -0,0 +1,72 @@
{ lib, config, options, pkgs, ... }: {
options.mods.gaming = {
enable = lib.mkOption {
default = false;
example = true;
type = lib.types.bool;
description = "Enabled gaming related features.";
};
tools = lib.mkOption {
default = with pkgs; [
gamemode
steam
lutris
wine
adwsteamgtk
heroic
];
example = [ ];
type = with lib.types; listOf packages;
description = "Install gaming related packages";
};
steam = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = "Whether to use steam";
};
gamemode = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = "Whether to use gamemode";
};
gpu_optimization = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = "Whether to use GPU performance setting. NOTE: this is at your own risk!";
};
gpu_device = lib.mkOption {
default = "0";
example = "1";
type = lib.types.str;
description = "Your gpu device.(Physical id of lshw)";
};
};
config = lib.mkIf config.mods.gaming.enable
(lib.optionalAttrs (options?environment.systemPackages) {
environment.systemPackages = config.mods.gaming.tools;
programs.steam.enable = config.mods.gaming.steam;
programs.gamemode.enable = true;
programs.gamemode = {
enableRenice = true;
settings = {
general = {
governor = "performance";
};
gpu = lib.mkIf config.mods.gaming.gpu_optimization {
apply_gpu_optimisations = "accept-responsibility";
gpu_device = config.mods.gaming.gpu_device;
amd_performance_level = "high";
nv_powermizer_mode = 1;
};
custom = {
start = "notify-send -a 'Gamemode' 'Optimizations activated'";
end = "notify-send -a 'Gamemode' 'Optimizations deactivated'";
};
};
};
});
}

46
modules/programs/git.nix Normal file
View file

@ -0,0 +1,46 @@
{ lib, config, options, pkgs, ... }:
{
options.mods.git = {
username = lib.mkOption {
default = "DashieTM";
example = "globi";
type = lib.types.str;
description = "Git user name";
};
email = lib.mkOption {
default = "fabio.lenherr@gmail.com";
example = "globi@globus.glob";
type = lib.types.str;
description = "Git email";
};
ssh_config = lib.mkOption {
default = ''
Host github.com
${if (config.sops.secrets?hub.path) then "IdentityFile ${config.sops.secrets.hub.path}" else ""}
Host gitlab.com
${if (config.sops.secrets?lab.path) then "IdentityFile ${config.sops.secrets.lab.path}" else ""}
Host dashie.org
${if (config.sops.secrets?dashie.path) then "IdentityFile ${config.sops.secrets.dashie.path}" else ""}
'';
example = '''';
type = lib.types.lines;
description = "ssh configuration (keys for git)";
};
};
config = (lib.optionalAttrs (options?programs.git && options?home.file) {
programs.git = {
enable = true;
userName = config.mods.git.username;
userEmail = config.mods.git.email;
extraConfig = {
merge = {
tool = "nvimdiff";
};
diff = {
tool = "nvimdiff";
};
};
};
home.file.".ssh/config".text = config.mods.git.ssh_config;
});
}

View file

@ -1,5 +1,4 @@
{ lib, config, options, pkgs, ... }: {
options.mods = {
gnome_services.enable = lib.mkOption {
default = true;

View file

@ -50,7 +50,6 @@
qt5ct
qt6ct
gnutar
fishPlugins.tide
nix-index
libnotify
zenith

View file

@ -41,6 +41,23 @@
Extra exec_once.
'';
};
use_default_config = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = ''
Use preconfigured Hyprland config.
'';
};
custom_config = lib.mkOption {
default = { };
example = { };
type = with lib.types; attrsOf anything;
description = ''
Custom Hyprland configuration.
Will be merged with default configuration if enabled.
'';
};
};
};
@ -62,7 +79,8 @@
];
wayland.windowManager.hyprland.enable = true;
wayland.windowManager.hyprland.settings = {
wayland.windowManager.hyprland.settings = lib.mkIf config.mods.hyprland.use_default_config
{
"$mod" = "SUPER";
"source" = "/home/${config.conf.username}/.config/reset/keyboard.conf";
@ -317,7 +335,7 @@
# ];
# };
# };
};
} // config.mods.hyprland.custom_config;
# wayland.windowManager.hyprland.plugins = [
# inputs.Hyprspace.packages.${pkgs.system}.Hyprspace
# ];

View file

@ -0,0 +1,59 @@
{ lib, config, options, pkgs, ... }: {
options.mods.keepassxc = {
enable = lib.mkOption {
default = false;
example = true;
type = lib.types.bool;
description = "Enables the piper program and its daemon";
};
use_cache_config = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = "Whether to overwrite the cache config of keepassxc. Note, this means that changes can't be applied via the program anymore!";
};
cache_config = lib.mkOption {
default = ''
[General]
LastDatabases=/home/dashie/PWs/Passwords.kdbx
LastActiveDatabase=/home/dashie/PWs/Passwords.kdbx
LastOpenedDatabases=/home/dashie/PWs/Passwords.kdbx
LastKeyFiles=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0>\0/\0h\0o\0m\0\x65\0/\0\x64\0\x61\0s\0h\0i\0\x65\0/\0P\0W\0s\0/\0P\0\x61\0s\0s\0w\0o\0r\0\x64\0s\0.\0k\0\x64\0\x62\0x\0\0\0\n\0\0\0>\0/\0h\0o\0m\0\x65\0/\0\x64\0\x61\0s\0h\0i\0\x65\0/\0P\0W\0s\0/\0l\0o\0g\0i\0n\0_\0k\0\x65\0y\0.\0k\0\x65\0y\0x)
'';
example = '''';
type = lib.types.lines;
description = "Cache config to be used.";
};
};
config = lib.mkIf config.mods.keepassxc.enable
(lib.optionalAttrs (options?home.file) {
xdg.configFile."keepassxc/keepassxc.ini" = {
text =
''
[General]
ConfigVersion=2
[Browser]
Enabled=true
[GUI]
ApplicationTheme=classic
HidePasswords=true
MinimizeOnClose=true
MinimizeToTray=true
ShowTrayIcon=true
TrayIconAppearance=monochrome-light
[PasswordGenerator]
Length=30
[Security]
EnableCopyOnDoubleClick=true
'';
};
home.file.".cache/keepassxc/keepassxc.ini" = lib.mkIf config.mods.keepassxc.use_cache_config {
text = config.mods.keepassxc.cache_config;
};
});
}

View file

@ -0,0 +1,120 @@
{ lib, config, options, pkgs, inputs, ... }: {
options.mods = {
starship = {
enable = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = ''
Enables starship prompt
'';
};
use_default_prompt = lib.mkOption {
default = true;
example = false;
type = lib.types.bool;
description = ''
Enables preconfigured prompt
'';
};
custom_prompt = lib.mkOption {
default = { };
example = { };
type = with lib.types; attrsOf anything;
description = ''
Custom configuration for prompt.
Will be merged with preconfigured prompt if that is used.
'';
};
};
};
# environment.systemPackages needed in order to configure systemwide
config = lib.mkIf config.mods.starship.enable (lib.optionalAttrs (options?environment.systemPackages) {
programs.starship =
let
base16 = pkgs.callPackage inputs.base16.lib { };
scheme = (base16.mkSchemeAttrs config.stylix.base16Scheme);
code_format = "[](bg:prev_bg fg:#5256c3)[ $symbol ($version)](bg:#5256c3)";
in
{
enable = true;
interactiveOnly = true;
presets = lib.mkIf config.mods.starship.use_default_prompt [ "pastel-powerline" ];
settings = lib.mkIf config.mods.starship.use_default_prompt
{
# derived from https://starship.rs/presets/pastel-powerline
format = ''$username$directory$git_branch$git_status$git_metrics[ ](bg:none fg:prev_bg)'';
right_format = ''$c$elixir$elm$golang$gradle$haskell$java$julia$nodejs$nim$rust$scala$python$ocaml$opa$perl$zig$dart$dotnet$nix_shell$shell$solidity[](bg:prev_bg fg:#3465A4)$time$os'';
username = {
show_always = false;
style_user = "bg:#5277C3 fg:#${scheme.base05}";
style_root = "bg:#5277C3 fg:#${scheme.base05}";
format = "[ $user ]($style)[](bg:#3465A4 fg:#5277C3)";
disabled = false;
};
os = {
symbols = { NixOS = " "; };
style = "bg:#3465A4 fg:#${scheme.base05}";
disabled = false;
};
directory = {
style = "bg:#3465A4 fg:#${scheme.base05}";
format = "[ $path ]($style)";
truncation_length = 3;
truncation_symbol = "/";
};
git_branch = {
symbol = "";
style = "bg:#5256c3 fg:#${scheme.base05}";
format = "[ ](bg:#5256c3 fg:prev_bg)[$symbol $branch ]($style)";
};
git_status = {
staged = "+\${count} (fg:#C4A000)";
ahead = "\${count} (fg:#C4A000)";
diverged = "\${count} (fg:#C4A000)";
behind = "\${count} (fg:#C4A000)";
stashed = " ";
untracked = "?\${count} (fg:#C4A000)";
modified = "!\${count} (fg:#C4A000)";
deleted = "\${count} (fg:#C4A000)";
conflicted = "=\${count} (fg:#C4A000)";
renamed = "»\${count} (fg:#C4A000)";
style = "bg:#5256c3 fg:fg:#C4A000";
format = "[$all_status$ahead_behind]($style)";
};
git_metrics = {
disabled = false;
format = "([| ](bg:#5256c3)[+$added]($added_style bg:#5256c3)[ -$deleted]($deleted_style bg:#5256c3))";
};
c = { format = code_format; };
elixir = { format = code_format; };
elm = { format = code_format; };
golang = { format = code_format; };
gradle = { format = code_format; };
haskell = { format = code_format; };
java = { format = code_format; };
julia = { format = code_format; };
nodejs = { format = code_format; };
nim = { format = code_format; };
nix_shell = { symbol = ""; format = code_format; };
rust = { format = code_format; };
scala = { format = code_format; };
typst = { format = code_format; };
python = { format = code_format; };
ocaml = { format = code_format; };
opa = { format = code_format; };
perl = { format = code_format; };
zig = { format = code_format; };
dart = { format = code_format; };
dotnet = { format = code_format; };
time = {
disabled = false;
time_format = "%R"; # Hour:Minute Format
style = "bg:#3465A4 fg:#${scheme.base05}";
format = "[ $time ]($style)";
};
} // config.mods.starship.custom_prompt;
};
});
}

View file

@ -0,0 +1,82 @@
{ lib, config, options, pkgs, ... }: {
options.mods.stylix = {
colorscheme = lib.mkOption {
default = {
# custom tokyo night
base00 = "1A1B26";
# base01 = "16161E";
# base01 = "15161e";
base01 = "191a25";
base02 = "2F3549";
base03 = "444B6A";
base04 = "787C99";
base05 = "A9B1D6";
base06 = "CBCCD1";
base07 = "D5D6DB";
base08 = "C0CAF5";
base09 = "A9B1D6";
base0A = "0DB9D7";
base0B = "9ECE6A";
base0C = "B4F9F8";
# base0D = "2AC3DE";
# base0D = "A9B1D6";
# base0D = "62A0EA";
# base0D = "779EF1";
base0D = "366fea";
base0E = "BB9AF7";
base0F = "F7768E";
};
example = "catppuccin-mocha";
type = with lib.types; oneOf [ str attrs path ];
description = ''
Base16 colorscheme.
Can be an attribute set with base00 to base0F,
a string that leads to a yaml file in base16-schemes path,
or a path to a custom yaml file.
'';
};
};
config = (lib.optionalAttrs (options?stylix) {
stylix = {
enable = true;
image = ../../base/black.jpg;
polarity = "dark";
targets = {
nixvim.enable = false;
fish.enable = false;
};
fonts = {
serif = {
package = pkgs.cantarell-fonts;
name = "Cantarell";
};
sansSerif = {
package = pkgs.cantarell-fonts;
name = "Cantarell";
};
monospace = {
package = (pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; });
# name = "JetBrains Mono Nerd";
name = "JetBrainsMono Nerd Font Mono";
};
emoji = {
package = pkgs.noto-fonts-emoji;
name = "Noto Color Emoji";
};
};
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
};
base16Scheme =
(if builtins.isAttrs config.mods.stylix.colorscheme then config.mods.stylix.colorscheme else "${pkgs.base16-schemes}/share/themes/${config.mods.stylix.colorscheme}.yaml");
};
});
}

View file

@ -1,35 +0,0 @@
{ pkgs
, lib
, config
, ...
}: lib.mkIf config.conf.gaming.enable {
environment.systemPackages = with pkgs; [
gamemode
steam
lutris
wine
adwsteamgtk
heroic
];
programs.steam.enable = true;
programs.gamemode.enable = true;
programs.gamemode = {
enableRenice = true;
settings = {
general = {
governor = "performance";
};
gpu = lib.mkIf config.conf.gaming.gamemode_gpu {
apply_gpu_optimisations = "accept-responsibility";
gpu_device = config.conf.gaming.device;
amd_performance_level = "high";
nv_powermizer_mode = 1;
};
custom = {
start = "notify-send -a 'Gamemode' 'Optimizations activated'";
end = "notify-send -a 'Gamemode' 'Optimizations deactivated'";
};
};
};
}

View file

@ -3,11 +3,8 @@
./kitty.nix
./yazi.nix
./fish.nix
./ssh.nix
./direnv.nix
./git.nix
./firefox.nix
./keepass.nix
./neovide.nix
];
}

View file

@ -1,16 +0,0 @@
{
programs.git = {
enable = true;
userName = "DashieTM";
userEmail = "fabio.lenherr@gmail.com";
extraConfig = {
merge = {
tool = "nvimdiff";
};
diff = {
tool = "nvimdiff";
};
};
};
}

View file

@ -1,36 +0,0 @@
{
xdg.configFile."keepassxc/keepassxc.ini" = {
text =
''
[General]
ConfigVersion=2
[Browser]
Enabled=true
[GUI]
ApplicationTheme=classic
HidePasswords=true
MinimizeOnClose=true
MinimizeToTray=true
ShowTrayIcon=true
TrayIconAppearance=monochrome-light
[PasswordGenerator]
Length=30
[Security]
EnableCopyOnDoubleClick=true
'';
};
home.file.".cache/keepassxc/keepassxc.ini" = {
text = ''
[General]
LastDatabases=/home/dashie/PWs/Passwords.kdbx
LastActiveDatabase=/home/dashie/PWs/Passwords.kdbx
LastOpenedDatabases=/home/dashie/PWs/Passwords.kdbx
LastKeyFiles=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0>\0/\0h\0o\0m\0\x65\0/\0\x64\0\x61\0s\0h\0i\0\x65\0/\0P\0W\0s\0/\0P\0\x61\0s\0s\0w\0o\0r\0\x64\0s\0.\0k\0\x64\0\x62\0x\0\0\0\n\0\0\0>\0/\0h\0o\0m\0\x65\0/\0\x64\0\x61\0s\0h\0i\0\x65\0/\0P\0W\0s\0/\0l\0o\0g\0i\0n\0_\0k\0\x65\0y\0.\0k\0\x65\0y\0x)
'';
};
}

View file

@ -1,10 +0,0 @@
{ config, ... }: {
home.file.".ssh/config".text = ''
Host github.com
IdentityFile ${config.sops.secrets.hub.path}
Host gitlab.com
IdentityFile ${config.sops.secrets.lab.path}
Host dashie.org
IdentityFile ${config.sops.secrets.dashie.path}
'';
}

View file

@ -1,9 +1,6 @@
{
imports = [
./qt.nix
./stylix.nix
# ./gtk3.nix
# ./gtk4.nix
];
}

View file

@ -1,44 +0,0 @@
{ pkgs, config, ... }:
{
stylix = {
enable = true;
image = ../../base/black.jpg;
polarity = "dark";
targets = {
nixvim.enable = false;
fish.enable = false;
};
fonts = {
serif = {
package = pkgs.cantarell-fonts;
name = "Cantarell";
};
sansSerif = {
package = pkgs.cantarell-fonts;
name = "Cantarell";
};
monospace = {
package = (pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; });
# name = "JetBrains Mono Nerd";
name = "JetBrainsMono Nerd Font Mono";
};
emoji = {
package = pkgs.noto-fonts-emoji;
name = "Noto Color Emoji";
};
};
cursor = {
package = pkgs.bibata-cursors;
name = "Bibata-Modern-Classic";
size = 24;
};
base16Scheme =
(if builtins.isAttrs config.conf.colorscheme then config.conf.colorscheme else "${pkgs.base16-schemes}/share/themes/${config.conf.colorscheme}.yaml");
};
}