users: refac modules

This commit is contained in:
Dmitriy Pleshevskiy 2022-10-12 01:41:32 +03:00
parent 3f0624c04e
commit 454f167145
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
41 changed files with 681 additions and 953 deletions

View file

@ -1,4 +1,4 @@
{ dedsec-grub-theme, ... } @ inputs:
{ ... } @ inputs:
let
hardware = inputs.hardware.nixosModules;
@ -8,7 +8,6 @@ in
system = "x86_64-linux";
extraModules = [
dedsec-grub-theme.nixosModule
../modules/garbage-collector.nix
../users/jan
];

View file

@ -31,7 +31,7 @@
./home.nix
];
progs.alacritty.fontSize = lib.mkIf (fontSize != null) fontSize;
local.alacritty.fontSize = lib.mkIf (fontSize != null) fontSize;
home.stateVersion = config.system.stateVersion;
};

View file

@ -1,10 +1,26 @@
{ config, pkgs, ... }:
{ config, lib, pkgs, ... }:
let
secrets = import ./secrets.nix;
in
{
imports = (import ./ui) ++ (import ./shell) ++ (import ./progs);
imports = [
../modules/window_manager
../modules/terminal.nix
../modules/shell.nix
../modules/notifications
../modules/file_manager
../modules/mail
../modules/ledger.nix
../modules/pass.nix
../modules/git.nix
../modules/dev_tools.nix
../modules/editor.nix
];
xdg.enable = true;
home.keyboard = {
model = "pc105";
@ -16,24 +32,12 @@ in
home.packages = with pkgs; [
kotatogram-desktop
nheko
docker-compose
libreoffice
image-roll
asciinema # record the terminal
neofetch # command-line system information
# tools
xh # friendly and fast tool for sending HTTP requests
fd # a simple, fast and user-friendly alternative to find
bat # a cat clone with syntax highlighting and git integration
ripgrep # a fuzzy finder
vnetod # a tool to change env sections
# nix
nixpkgs-fmt
nil # lsp server
# browser
# a fork of firefox, focused on privacy, security and freedom
(librewolf.override {
@ -46,69 +50,18 @@ in
postgresql_12 # 🤷 I need only psql
];
# user interface
ui = {
# windows manager
xmonad.enable = true;
# bar
polybar.enable = true;
# lock
betterlockscreen.enable = true;
local.git = {
gpgKey = secrets.gpgSigningKey;
inherit (secrets) userName userEmail;
git-crypt.enable = true;
};
# shell
shell = {
zsh.enable = true;
programs.zsh.initExtra = lib.mkAfter ''
eval "$(cat $HOME/repos/tas/shell/zsh)"
eval $(kubectl completion zsh)
'';
prompt.starship.enable = true;
};
# programs
progs = {
alacritty.enable = true;
git = {
enable = true;
gpgKey = secrets.gpgSigningKey;
inherit (secrets) userName userEmail;
git-crypt.enable = true;
};
# password manager
pass.enable = true;
# email manager
aerc.enable = true;
# finance manager
hledger.enable = true;
# file manager
vifm.enable = true;
# editor
nvim = {
enable = true;
default = true;
};
# tools
exa.enable = true;
zoxide.enable = true;
};
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
accounts = {
email = {
maildirBasePath = "${config.xdg.dataHome}/mail";
accounts = secrets.emailAccounts;
};
};
accounts.email.accounts = secrets.emailAccounts;
home.file = {
"scripts" = {
@ -122,10 +75,4 @@ in
};
};
xdg.enable = true;
services.wired = {
enable = true;
config = ./wired.ron;
};
}

View file

@ -1,164 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.progs.aerc;
exec = cmd: ":${cmd}<Enter>";
fill = cmd: ":${cmd}<space>";
in
{
options.progs.aerc = {
enable = mkOption {
type = types.bool;
default = false;
description = "Add neomutt with my personal configuration";
};
};
# See: https://git.sbruder.de/simon/nixos-config/src/branch/master/users/simon/modules/mail/aerc/default.nix
config = mkIf cfg.enable {
programs.aerc = {
enable = true;
# See: https://man.archlinux.org/man/aerc-config.5.en
extraConfig = {
general = {
unsafe-accounts-conf = true;
};
ui = {
index-format = "%-17.17D %-20.20n %Z %-20.20g %s";
# See https://godoc.org/time#Time.Format
timestamp-format = "2006-01-02 15:04 MST";
this-day-time-format = "15:04";
this-week-time-format = "Monday 15:04";
this-year-time-format = "02 January";
pinned-tab-marker = "";
border-char-vertical = "";
border-char-horizontal = "";
fuzzy-complete = true;
new-message-bell = false;
};
statusline = {
display-mode = "icon";
};
filters = {
"text/plain" = "${./colorize}";
"text/html" = "html";
};
};
extraBinds = {
messages = {
"q" = exec "quit";
"gt" = exec "next-tab";
"gT" = exec "prev-tab";
"j" = exec "next";
"<Down>" = exec "next";
"<C-d>" = exec "next 50%";
"k" = exec "prev";
"<Up>" = exec "prev";
"<C-b>" = exec "prev 50%";
"gg" = exec "select 0";
"G" = exec "select -1";
"J" = exec "next-folder";
"K" = exec "prev-folder";
"c" = fill "cf";
"<Enter>" = exec "view";
"C" = exec "compose";
"/" = fill "search";
"\\" = fill "filter";
"n" = exec "next-result";
"N" = exec "prev-result";
"U" = exec "unsubscribe";
"D" = exec "delete";
"A" = exec "archive flat";
#"D" = exec "modify-labels +deleted -inbox";
#"A" = exec "modify-labels -inbox";
#"ms" = exec "modify-labels +spam -inbox";
#"mS" = exec "modify-labels -spam +inbox";
};
view = {
"q" = exec "close";
"O" = exec "open";
"S" = fill "save";
"f" = exec "forward";
"rr" = exec "reply -a";
"rq" = exec "reply -aq";
"Rr" = exec "reply";
"Rq" = exec "reply -q";
"<C-k>" = exec "prev-part";
"<C-j>" = exec "next-part";
"J" = exec "next";
"K" = exec "prev";
"U" = exec "unsubscribe";
"D" = exec "delete";
"A" = exec "archive flat";
# "ms" = exec "modify-labels +spam -inbox";
# "mS" = exec "modify-labels -spam +inbox";
};
compose = {
"$ex" = "<C-x>";
"<C-k>" = exec "prev-field";
"<C-j>" = exec "next-field";
"<tab>" = exec "next-field";
};
"compose::editor" = {
"$noinherit" = "true";
"$ex" = "<C-x>";
"<C-k>" = exec "prev-field";
"<C-j>" = exec "next-field";
};
"compose::review" = {
"y" = exec "send";
"n" = exec "abort";
"p" = exec "postpone";
"q" = exec "choose -o d discard abort -o p postpone postpone";
"e" = exec "edit";
"a" = fill "attach";
"d" = fill "detach";
};
};
stylesets.default = {
"*.selected.reverse" = true;
"title.reverse" = true;
"header.bold" = true;
"*error.bold" = true;
"error.fg" = 1;
"warning.fg" = 3;
"success.fg" = 2;
"statusline_default.bg" = 0;
"statusline_error.fg" = 1;
"statusline_error.reverse" = true;
"statusline_success.fg" = 2;
"statusline_success.reverse" = true;
"msglist_unread.bold" = true;
"msglist_deleted.fg" = 10;
"tab.bg" = 11;
"tab.selected.reverse" = false;
"tab.selected.bg" = 12;
"tab.fg" = 0;
"completion_default.bg" = 0;
};
};
};
}

View file

@ -1,35 +0,0 @@
{ fontSize ? 11.0 }:
{
window = {
padding = {
x = 5;
y = 5;
};
decorations = "none";
dynamic_title = true;
};
scrolling = {
history = 10000;
multiplier = 3;
};
font =
let
family = "monospace";
mkFont = style: { inherit family style; };
in
{
normal = mkFont "Regular";
bold = mkFont "Bold";
italic = mkFont "Italic";
bold_italic = mkFont "Bold Italic";
size = fontSize;
};
}

View file

@ -1,31 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.progs.alacritty;
alacrittyConfig = import ./config.nix { inherit (cfg) fontSize; };
in
{
options.progs.alacritty = {
enable = mkOption {
type = types.bool;
default = false;
description = "Enable alacritty, GPU-accelerated terminal emulator";
};
fontSize = mkOption {
type = types.number;
default = 11.0;
description = "Alacritty font size";
};
};
config = mkIf cfg.enable {
programs.alacritty = {
enable = true;
settings = alacrittyConfig;
};
};
}

View file

@ -1,11 +0,0 @@
[
./alacritty
./aerc
./exa.nix
./git.nix
./hledger.nix
./nvim.nix
./pass.nix
./vifm
./zoxide.nix
]

View file

@ -1,36 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.progs.exa;
zsh = config.shell.zsh;
exaPackage = pkgs.exa.override { gitSupport = false; };
defaultArgs = "--icons --classify";
bin = "${exaPackage}/bin/exa ${defaultArgs}";
in
{
options.progs.exa = {
enable = mkOption {
type = types.bool;
default = false;
description = "Add and configure exa, a modern replacement for ls";
};
};
config = mkIf cfg.enable {
programs.exa = {
enable = true;
package = exaPackage;
};
programs.zsh.shellAliases = mkIf zsh.enable rec {
ls = "${bin} --oneline";
la = "${ls} --all";
lt = "${bin} --tree --level=3";
ll = "${bin} --long --header";
lla = "${ll} --all";
};
};
}

View file

@ -1,52 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.progs.hledger;
bin = "${pkgs.hledger}/bin/hledger";
sbin = "${bin} --strict";
hledgerAliases = {
hle = bin;
shle = sbin;
};
in
{
options.progs.hledger = {
enable = mkOption {
type = types.bool;
default = false;
description = "Add and configure hledger tool to manage finance";
};
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
hledger
hledger-ui
hledger-interest
];
home.file = {
"finance/commodities.journal".text = ''
; Fiat currencies
commodity 1.000,00 RUB
commodity 1.000,00 USD
; Investment commodities
; Cryptocurrencies
; Other
; Default commodity
; D 1.000,00 RUB
'';
};
programs.zsh.shellAliases = mkIf config.shell.zsh.enable hledgerAliases;
};
}

View file

@ -1,37 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.progs.nvim;
myneovim = pkgs.myneovim.override {
viAlias = true;
vimAlias = true;
enableDevIcons = true;
enableTabby = true;
};
in
{
options.progs.nvim = {
enable = mkOption {
type = types.bool;
default = false;
description = "Add and configure neovim";
};
default = mkOption {
type = types.bool;
default = false;
description = "Set neovim as default editor";
};
};
config = mkIf cfg.enable {
home.packages = [ myneovim ];
home.sessionVariables = mkIf cfg.default {
EDITOR = "nvim";
};
};
}

View file

@ -1,35 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.progs.pass;
passDataDir = "${config.xdg.dataHome}/pass";
myPassPackage = pkgs.pass-minimal.withExtensions (ext: [
ext.pass-audit
]);
in
{
options.progs.pass = {
enable = mkOption {
type = types.bool;
default = false;
description = "Enables pass tool to manage your passwords";
};
};
config = mkIf cfg.enable {
programs.password-store = {
enable = true;
package = myPassPackage;
settings = {
PASSWORD_STORE_DIR = "${passDataDir}/store";
};
};
services.pass-secret-service.enable = true;
programs.gpg.enable = true;
services.gpg-agent.enable = true;
};
}

View file

@ -1,28 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.progs.vifm;
in
{
options.progs.vifm = {
enable = mkOption {
type = types.bool;
default = false;
description = "Add and configure vifm, a vi-like file manager";
};
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
vifm # a vi-like file manager
];
xdg.configFile = {
"vifm/vifmrc".source = ./vifmrc;
};
};
}

View file

@ -1,24 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.progs.zoxide;
in
{
options.progs.zoxide = {
enable = mkOption {
type = types.bool;
default = false;
description = "Add zoxide, a modern replacement for cd";
};
};
config = mkIf cfg.enable {
programs.zoxide = {
enable = true;
enableZshIntegration = config.shell.zsh.enable;
};
};
}

View file

@ -1 +0,0 @@
[ ./zsh.nix ] ++ (import ./prompt)

View file

@ -1 +0,0 @@
[ ./starship ]

View file

@ -1,34 +0,0 @@
{ concatStrings }:
{
add_newline = true;
format = concatStrings [
"$directory"
"$git_branch"
"$git_commit"
"$git_state"
"$git_metrics"
"$git_status"
"$shlvl"
"$nix_shell"
"$cmd_duration"
"$jobs"
"$line_break"
"$character"
];
character = {
success_symbol = "[](bold green)";
error_symbol = "[](bold red)";
};
git_commit.commit_hash_length = 6;
shlvl = {
disabled = false;
format = "[$symbol$shlvl]($style) ";
symbol = " ";
threshold = 3;
};
}

View file

@ -1,28 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.shell.prompt.starship;
starshipConfig = import ./config.nix {
inherit concatStrings;
};
in
{
options.shell.prompt.starship = {
enable = mkOption {
type = types.bool;
default = false;
description = "Enable starship cross-shell prompt";
};
};
config = mkIf cfg.enable {
programs.starship = {
enable = true;
enableZshIntegration = config.shell.zsh.enable;
settings = starshipConfig;
};
};
}

View file

@ -1,51 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.shell.zsh;
in
{
options.shell.zsh = {
enable = mkOption {
type = types.bool;
default = false;
description = "Add z shell";
};
};
config = mkIf cfg.enable {
# fish and zsh support for nix-shell
home.packages = with pkgs; [ any-nix-shell ];
programs.zsh = {
enable = true;
enableAutosuggestions = true;
enableCompletion = true;
defaultKeymap = "viins";
dotDir = ".config/zsh";
history = {
path = "${config.xdg.dataHome}/zsh/zsh_history";
expireDuplicatesFirst = true;
ignorePatterns = [
"rm *"
"kill *"
];
};
oh-my-zsh = {
enable = true;
theme = mkIf (!config.shell.prompt.starship.enable) "robbyrussell";
};
initExtra = ''
any-nix-shell zsh --info-right | source /dev/stdin
eval "$(cat $HOME/repos/tas/shell/zsh)"
eval $(kubectl completion zsh)
'';
};
};
}

View file

@ -1,60 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.ui.betterlockscreen;
package = config.services.betterlockscreen.package;
in
{
options.ui.betterlockscreen = {
enable = mkOption {
type = types.bool;
default = false;
description = "Enable betterlockscreen";
};
};
config = mkIf cfg.enable {
services.betterlockscreen = {
enable = true;
arguments = [ "--display 1" "--" "-e" ];
inactiveInterval = 15;
};
systemd.user.timers.updateBetterlockscreenImage = {
Unit = {
Description = "Update betterlockscreen image timer";
After = [ "graphical-session.target" "timers.target" ];
};
Timer = {
OnUnitActiveSec = "60min";
OnBootSec = "10s";
};
Install = {
WantedBy = [ "graphical-session.target" "timers.target" ];
};
};
systemd.user.services.updateBetterlockscreenImage = {
Unit = {
Description = "Update betterlockscreen image";
After = [ "graphical-session.target" ];
};
Service = {
Type = "oneshot";
Environment = "PATH=/run/current-system/sw/bin";
ExecStart = "${package}/bin/betterlockscreen --display 1 --update ${config.home.homeDirectory}/pictures/wallpapers";
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
};
};
}

View file

@ -1,6 +0,0 @@
[
./xmonad
./polybar
./betterlockscreen.nix
]

View file

@ -1,138 +0,0 @@
{ lib, config, pkgs, colors }:
with lib;
let
mkWifi = interface: {
type = "internal/network";
interval = 3;
interface = {
text = interface;
type = "wireless";
};
label.connected = "%essid% %signal%";
format.connected = {
prefix = "| ";
suffix = "%";
};
};
padding = 1;
in
{
"bar/main" = {
monitor = "\${env:MONITOR:DisplayPort-1}";
width = "100%";
height = "20px";
font = [
"Fira Code:size=9:antialias=true"
"Fira Code:bold:size=9:antialias=true"
"FiraCode Nerd Font Mono:size=9:antialias=true"
"FiraCode Nerd Font Mono:size=14:antialias=true"
];
radius = 0;
modules = {
left = "xmonad";
center = "date wifi_home wifi_laptop";
right = "exchangerate volume battery lang time";
};
};
"module/date" = {
type = "internal/date";
interval = 10;
date = "%a %d %b %Y";
label = "%date%";
format = { inherit padding; };
};
"module/time" = {
type = "internal/date";
time = "%H:%M:%S";
label = {
text = "%time%";
font = 2;
foreground = colors.orange;
};
};
"module/lang" = {
type = "internal/xkeyboard";
format = {
inherit padding;
text = "<label-layout>";
};
label.layout.font = 2;
};
"module/volume" = {
type = "custom/script";
exec = "~/scripts/get_volume.sh";
interval = 1;
format = {
inherit padding;
prefix = "%{T4}%{T-} ";
};
};
"module/battery" = {
type = "internal/battery";
full-at = 99;
low-at = 10;
battery = "BAT0";
adapter = "AC0";
format.charging = {
inherit padding;
text = "%{T3}%{T-} <label-charging>";
foreground = colors.green;
};
format.discharging = {
inherit padding;
text = "%{T3}<ramp-capacity>%{T-} <label-discharging>";
foreground = colors.orange;
};
format.full = {
inherit padding;
text = "%{T3}%{T-} <label-full>";
foreground = colors.green;
};
format.low = {
inherit padding;
text = "%{T3}%{T-} <label-low>";
foreground = colors.red;
};
# Only applies if <ramp-capacity> is used
ramp.capacity = [ "" "" "" "" "" ];
};
"module/wifi_home" = mkWifi "wlp11s0f3u2";
"module/wifi_laptop" = mkWifi "wlp2s0";
"module/xmonad" = mkIf config.ui.xmonad.enable {
type = "custom/script";
exec = "${pkgs.xmonad-log}/bin/xmonad-log";
tail = true;
};
"module/exchangerate" = {
type = "custom/script";
exec = "~/scripts/exchangerate.sh";
interval = 60;
format = {
inherit padding;
prefix = "USD: ";
};
};
"global/wm" = {
margin = {
bottom = 0;
top = 0;
};
};
}

View file

@ -1,39 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.ui.polybar;
pcfg = config.services.polybar;
# TODO: create a theme
colors = {
orange = "#ee9a00";
red = "#ff5555";
green = "#50fa7b";
};
polybarConfig = import ./config.nix { inherit lib config pkgs colors; };
in
{
options.ui.polybar = {
enable = mkOption {
type = types.bool;
default = false;
description = "Enable polybar status bar";
};
};
config = mkIf cfg.enable {
systemd.user.services.polybar = {
# Add additional /usr/bin to run custom scripts
Service.Environment = mkForce "PATH=${pcfg.package}/bin:/run/current-system/sw/bin";
};
services.polybar = {
enable = true;
script = "MONITOR=$(xrandr | grep \"connected primary\" | awk '{print $1;}') polybar &";
settings = polybarConfig;
};
};
}

View file

@ -1,44 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
uiCfg = config.ui;
cfg = uiCfg.xmonad;
in
{
options.ui.xmonad = {
enable = mkOption {
type = types.bool;
default = false;
description = "Enable xsessions and xmonad window manager";
};
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
xclip # access x clipboard from a console
dmenu # menu for x window system
flameshot # powerful yet simple to use screenshot software
nitrogen # wallpaper manager
];
xsession = {
enable = true;
windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
config = ./config.hs;
extraPackages = mkIf uiCfg.polybar.enable (hp: [
hp.dbus
hp.monad-logger
]);
};
initExtra = ''
${pkgs.nitrogen}/bin/nitrogen --restore &
'';
};
};
}

View file

@ -0,0 +1,45 @@
{ config, lib, pkgs, ... }:
let
exaPackage = pkgs.exa.override { gitSupport = false; };
defaultArgs = "--icons --classify";
bin = "${exaPackage}/bin/exa ${defaultArgs}";
in
{
programs.exa = {
enable = true;
package = exaPackage;
};
programs.zsh.shellAliases = lib.mkIf config.programs.zsh.enable rec {
ls = "${bin} --oneline";
la = "${ls} --all";
lt = "${bin} --tree --level=3";
ll = "${bin} --long --header";
lla = "${ll} --all";
};
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
programs.zoxide = {
enable = true;
enableZshIntegration = config.programs.zsh.enable;
};
home.packages = with pkgs; [
# tools
xh # friendly and fast tool for sending HTTP requests
fd # a simple, fast and user-friendly alternative to find
bat # a cat clone with syntax highlighting and git integration
ripgrep # a fuzzy finder
vnetod # a tool to change env sections
# nix
nixpkgs-fmt
nil # lsp server
docker-compose
];
}

15
users/modules/editor.nix Normal file
View file

@ -0,0 +1,15 @@
{ config, pkgs, ... }:
let
myneovim = pkgs.myneovim.override {
viAlias = true;
vimAlias = true;
enableDevIcons = true;
enableTabby = true;
};
in
{
home.packages = [ myneovim ];
home.sessionVariables.EDITOR = "nvim";
}

View file

@ -0,0 +1,9 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [ vifm ];
xdg.configFile = {
"vifm/vifmrc".source = ./vifmrc;
};
}

View file

@ -1,18 +1,10 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.progs.git;
cfg = config.local.git;
in
{
options.progs.git = {
enable = mkOption {
type = types.bool;
default = false;
description = "Add git with my personal settings";
};
options.local.git = with lib; {
userName = mkOption {
type = types.str;
description = "Set your global name";
@ -38,14 +30,13 @@ in
};
};
config = mkIf cfg.enable {
home.packages = mkIf cfg.git-crypt.enable [ pkgs.git-crypt ];
config = {
home.packages = lib.mkIf cfg.git-crypt.enable [ pkgs.git-crypt ];
programs.git = {
enable = true;
userName = cfg.userName;
userEmail = cfg.userEmail;
signing = mkIf (cfg.gpgKey != null) {
inherit (cfg) userName userEmail;
signing = lib.mkIf (cfg.gpgKey != null) {
key = cfg.gpgKey;
signByDefault = true;
};
@ -75,6 +66,7 @@ in
plo = "pull origin";
rb = "rebase";
rbi = "rebase -i";
lo = "log --pretty=oneline";
};
};
};

37
users/modules/ledger.nix Normal file
View file

@ -0,0 +1,37 @@
{ lib, config, pkgs, ... }:
let
bin = "${pkgs.hledger}/bin/hledger";
sbin = "${bin} --strict";
hledgerAliases = {
hle = bin;
shle = sbin;
};
in
{
home.packages = with pkgs; [
hledger
hledger-ui
hledger-interest
];
home.file = {
"finance/commodities.journal".text = ''
; Fiat currencies
commodity 1.000,00 RUB
commodity 1.000,00 USD
; Investment commodities
; Cryptocurrencies
; Other
; Default commodity
; D 1.000,00 RUB
'';
};
programs.zsh.shellAliases = lib.mkIf config.programs.zsh.enable hledgerAliases;
}

View file

@ -0,0 +1,152 @@
{ config, pkgs, ... }:
let
exec = cmd: ":${cmd}<Enter>";
fill = cmd: ":${cmd}<space>";
in
{
accounts.email.maildirBasePath = "${config.xdg.dataHome}/mail";
# See: https://git.sbruder.de/simon/nixos-config/src/branch/master/users/simon/modules/mail/aerc/default.nix
programs.aerc = {
enable = true;
# See: https://man.archlinux.org/man/aerc-config.5.en
extraConfig = {
general = {
unsafe-accounts-conf = true;
};
ui = {
index-format = "%-17.17D %-20.20n %Z %-20.20g %s";
# See https://godoc.org/time#Time.Format
timestamp-format = "2006-01-02 15:04 MST";
this-day-time-format = "15:04";
this-week-time-format = "Monday 15:04";
this-year-time-format = "02 January";
pinned-tab-marker = "";
border-char-vertical = "";
border-char-horizontal = "";
fuzzy-complete = true;
new-message-bell = false;
};
statusline = {
display-mode = "icon";
};
filters = {
"text/plain" = "${./colorize}";
"text/html" = "html";
};
};
extraBinds = {
messages = {
"q" = exec "quit";
"gt" = exec "next-tab";
"gT" = exec "prev-tab";
"j" = exec "next";
"<Down>" = exec "next";
"<C-d>" = exec "next 50%";
"k" = exec "prev";
"<Up>" = exec "prev";
"<C-b>" = exec "prev 50%";
"gg" = exec "select 0";
"G" = exec "select -1";
"J" = exec "next-folder";
"K" = exec "prev-folder";
"c" = fill "cf";
"<Enter>" = exec "view";
"C" = exec "compose";
"/" = fill "search";
"\\" = fill "filter";
"n" = exec "next-result";
"N" = exec "prev-result";
"U" = exec "unsubscribe";
"D" = exec "delete";
"A" = exec "archive flat";
#"D" = exec "modify-labels +deleted -inbox";
#"A" = exec "modify-labels -inbox";
#"ms" = exec "modify-labels +spam -inbox";
#"mS" = exec "modify-labels -spam +inbox";
};
view = {
"q" = exec "close";
"O" = exec "open";
"S" = fill "save";
"f" = exec "forward";
"rr" = exec "reply -a";
"rq" = exec "reply -aq";
"Rr" = exec "reply";
"Rq" = exec "reply -q";
"<C-k>" = exec "prev-part";
"<C-j>" = exec "next-part";
"J" = exec "next";
"K" = exec "prev";
"U" = exec "unsubscribe";
"D" = exec "delete";
"A" = exec "archive flat";
# "ms" = exec "modify-labels +spam -inbox";
# "mS" = exec "modify-labels -spam +inbox";
};
compose = {
"$ex" = "<C-x>";
"<C-k>" = exec "prev-field";
"<C-j>" = exec "next-field";
"<tab>" = exec "next-field";
};
"compose::editor" = {
"$noinherit" = "true";
"$ex" = "<C-x>";
"<C-k>" = exec "prev-field";
"<C-j>" = exec "next-field";
};
"compose::review" = {
"y" = exec "send";
"n" = exec "abort";
"p" = exec "postpone";
"q" = exec "choose -o d discard abort -o p postpone postpone";
"e" = exec "edit";
"a" = fill "attach";
"d" = fill "detach";
};
};
stylesets.default = {
"*.selected.reverse" = true;
"title.reverse" = true;
"header.bold" = true;
"*error.bold" = true;
"error.fg" = 1;
"warning.fg" = 3;
"success.fg" = 2;
"statusline_default.bg" = 0;
"statusline_error.fg" = 1;
"statusline_error.reverse" = true;
"statusline_success.fg" = 2;
"statusline_success.reverse" = true;
"msglist_unread.bold" = true;
"msglist_deleted.fg" = 10;
"tab.bg" = 11;
"tab.selected.reverse" = false;
"tab.selected.bg" = 12;
"tab.fg" = 0;
"completion_default.bg" = 0;
};
};
}

View file

@ -0,0 +1,8 @@
{ ... }:
{
services.wired = {
enable = true;
config = ./wired.ron;
};
}

22
users/modules/pass.nix Normal file
View file

@ -0,0 +1,22 @@
{ config, pkgs, ... }:
let
passDataDir = "${config.xdg.dataHome}/pass";
myPassPackage = pkgs.pass-minimal.withExtensions (ext: [
ext.pass-audit
]);
in
{
programs.password-store = {
enable = true;
package = myPassPackage;
settings = {
PASSWORD_STORE_DIR = "${passDataDir}/store";
};
};
services.pass-secret-service.enable = true;
programs.gpg.enable = true;
services.gpg-agent.enable = true;
}

66
users/modules/shell.nix Normal file
View file

@ -0,0 +1,66 @@
{ lib, config, pkgs, ... }:
{
# fish and zsh support for nix-shell
home.packages = with pkgs; [ any-nix-shell ];
programs.zsh = {
enable = true;
enableAutosuggestions = true;
enableCompletion = true;
defaultKeymap = "viins";
dotDir = ".config/zsh";
history = {
path = "${config.xdg.dataHome}/zsh/zsh_history";
expireDuplicatesFirst = true;
ignorePatterns = [
"rm *"
"kill *"
];
};
oh-my-zsh.enable = true;
initExtra = ''
any-nix-shell zsh --info-right | source /dev/stdin
'';
};
programs.starship = {
enable = true;
enableZshIntegration = config.programs.zsh.enable;
settings = {
add_newline = true;
format = lib.concatStrings [
"$directory"
"$git_branch"
"$git_commit"
"$git_state"
"$git_metrics"
"$git_status"
"$shlvl"
"$nix_shell"
"$cmd_duration"
"$jobs"
"$line_break"
"$character"
];
character = {
success_symbol = "[](bold green)";
error_symbol = "[](bold red)";
};
git_commit.commit_hash_length = 6;
shlvl = {
disabled = false;
format = "[$symbol$shlvl]($style) ";
symbol = " ";
threshold = 3;
};
};
};
}

View file

@ -0,0 +1,46 @@
{ lib, config, pkgs, ... }:
let
cfg = config.local.alacritty;
in
{
options.local.alacritty = with lib; {
fontSize = mkOption {
type = types.number;
default = 11.0;
description = "Alacritty font size";
};
};
config = {
programs.alacritty = {
enable = true;
settings = {
window = {
padding = { x = 5; y = 5; };
decorations = "none";
dynamic_title = true;
};
scrolling = {
history = 10000;
multiplier = 3;
};
font =
let
family = "monospace";
mkFont = style: { inherit family style; };
in
{
normal = mkFont "Regular";
bold = mkFont "Bold";
italic = mkFont "Italic";
bold_italic = mkFont "Bold Italic";
size = cfg.fontSize;
};
};
};
};
}

View file

@ -0,0 +1,46 @@
{ config, lib, pkgs, ... }:
let
inherit (config.services.betterlockscreen) package;
in
{
services.betterlockscreen = {
enable = true;
arguments = [ "--display 1" "--" "-e" ];
inactiveInterval = 15;
};
systemd.user.timers.updateBetterlockscreenImage = {
Unit = {
Description = "Update betterlockscreen image timer";
After = [ "graphical-session.target" "timers.target" ];
};
Timer = {
OnUnitActiveSec = "60min";
OnBootSec = "10s";
};
Install = {
WantedBy = [ "graphical-session.target" "timers.target" ];
};
};
systemd.user.services.updateBetterlockscreenImage = {
Unit = {
Description = "Update betterlockscreen image";
After = [ "graphical-session.target" ];
};
Service = {
Type = "oneshot";
Environment = "PATH=/run/current-system/sw/bin";
ExecStart = "${package}/bin/betterlockscreen --display 1 --fx '' --update ${config.home.homeDirectory}/pictures/wallpapers";
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
};
}

View file

@ -0,0 +1,9 @@
{ ... }:
{
imports = [
./xmonad.nix
./polybar.nix
./betterlockscreen.nix
];
}

View file

@ -0,0 +1,162 @@
{ lib, config, pkgs, ... }:
with lib;
let
inherit (config.services.polybar) package;
# TODO: create a theme
colors = {
orange = "#ee9a00";
red = "#ff5555";
green = "#50fa7b";
};
in
{
systemd.user.services.polybar = {
# Add additional /usr/bin to run custom scripts
Service.Environment = mkForce "PATH=${package}/bin:/run/current-system/sw/bin";
};
services.polybar = {
enable = true;
script = "MONITOR=$(xrandr | grep \"connected primary\" | awk '{print $1;}') polybar &";
settings =
let
mkWifi = interface: {
type = "internal/network";
interval = 3;
interface = {
text = interface;
type = "wireless";
};
label.connected = "%essid% %signal%";
format.connected = {
prefix = "| ";
suffix = "%";
};
};
padding = 1;
in
{
"bar/main" = {
monitor = "\${env:MONITOR:DisplayPort-1}";
width = "100%";
height = "20px";
font = [
"Fira Code:size=9:antialias=true"
"Fira Code:bold:size=9:antialias=true"
"FiraCode Nerd Font Mono:size=9:antialias=true"
"FiraCode Nerd Font Mono:size=14:antialias=true"
];
radius = 0;
modules = {
left = "xmonad";
center = "date wifi_home wifi_laptop";
right = "exchangerate volume battery lang time";
};
};
"module/date" = {
type = "internal/date";
interval = 10;
date = "%a %d %b %Y";
label = "%date%";
format = { inherit padding; };
};
"module/time" = {
type = "internal/date";
time = "%H:%M:%S";
label = {
text = "%time%";
font = 2;
foreground = colors.orange;
};
};
"module/lang" = {
type = "internal/xkeyboard";
format = {
inherit padding;
text = "<label-layout>";
};
label.layout.font = 2;
};
"module/volume" = {
type = "custom/script";
exec = "~/scripts/get_volume.sh";
interval = 1;
format = {
inherit padding;
prefix = "%{T4}%{T-} ";
};
};
"module/battery" = {
type = "internal/battery";
full-at = 99;
low-at = 10;
battery = "BAT0";
adapter = "AC0";
format.charging = {
inherit padding;
text = "%{T3}%{T-} <label-charging>";
foreground = colors.green;
};
format.discharging = {
inherit padding;
text = "%{T3}<ramp-capacity>%{T-} <label-discharging>";
foreground = colors.orange;
};
format.full = {
inherit padding;
text = "%{T3}%{T-} <label-full>";
foreground = colors.green;
};
format.low = {
inherit padding;
text = "%{T3}%{T-} <label-low>";
foreground = colors.red;
};
# Only applies if <ramp-capacity> is used
ramp.capacity = [ "" "" "" "" "" ];
};
"module/wifi_home" = mkWifi "wlp11s0f3u2";
"module/wifi_laptop" = mkWifi "wlp2s0";
"module/xmonad" = mkIf config.xsession.windowManager.xmonad.enable {
type = "custom/script";
exec = "${pkgs.xmonad-log}/bin/xmonad-log";
tail = true;
};
"module/exchangerate" = {
type = "custom/script";
exec = "~/scripts/exchangerate.sh";
interval = 60;
format = {
inherit padding;
prefix = "USD: ";
};
};
"global/wm" = {
margin = {
bottom = 0;
top = 0;
};
};
}
;
};
}

View file

@ -0,0 +1,28 @@
{ config, lib, pkgs, ... }:
{
home.packages = with pkgs; [
xclip # access x clipboard from a console
dmenu # menu for x window system
flameshot # powerful yet simple to use screenshot software
nitrogen # wallpaper manager
];
xsession = {
enable = true;
windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
config = ./xmonad_config.hs;
extraPackages = (hp: [
hp.dbus
hp.monad-logger
]);
};
initExtra = ''
${pkgs.nitrogen}/bin/nitrogen --restore &
'';
};
}