Use home-manager to manage dotfiles

This commit is contained in:
Johannes Rothe 2024-03-09 22:37:11 +01:00
parent 4f860e87c6
commit 62c88c3a18
7 changed files with 516 additions and 20 deletions

View File

@ -57,6 +57,8 @@
# Enable scanning
hardware.sane.enable = true;
hardware.opengl.enable = true;
# bluetooth
hardware.bluetooth.enable = true;
@ -74,7 +76,7 @@
packages = with pkgs; [
chromium
firefox
flatpak
logseq
thunderbird
];
};
@ -108,6 +110,7 @@
gnupg
go
google-cloud-sdk
gopls
gotools
htop
inkscape
@ -117,7 +120,6 @@
libreoffice
mosquitto
mypy
nextcloud-client
nmap
pass-secret-service
pavucontrol
@ -128,6 +130,7 @@
python311
python311Packages.flake8
python311Packages.ipython
rusti-cal
signal-desktop
silver-searcher
shellcheck
@ -156,6 +159,7 @@
wlr.enable = true;
# gtk portal needed to make gtk apps happy
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
config.common.default = "*";
};
programs.light.enable = true;

22
flake.lock generated
View File

@ -1,5 +1,26 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1706981411,
"narHash": "sha256-cLbLPTL1CDmETVh4p0nQtvoF+FSEjsnJTFpTxhXywhQ=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "652fda4ca6dafeb090943422c34ae9145787af37",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-23.11",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1709884566,
@ -18,6 +39,7 @@
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
}

View File

@ -3,16 +3,29 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
home-manager.url = "github:nix-community/home-manager/release-23.11";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, ...}:
outputs = { self, nixpkgs, home-manager, ...}:
let
lib = nixpkgs.lib;
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
nixosConfigurations = {
lift = lib.nixosSystem {
system = "x64_64-linux";
modules = [ ./configuration.nix ./sway.nix ./hardware-configuration.nix ];
lift = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./configuration.nix
./sway.nix
./hardware-configuration.nix
];
};
};
homeConfigurations = {
rothe = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [ ./home/rothe.nix ];
};
};
};

399
home/rothe.nix Normal file
View File

@ -0,0 +1,399 @@
{ config, pkgs, lib, ... }:
{
home.username = "rothe";
home.homeDirectory = "/home/rothe";
home.packages = with pkgs; [
flameshot
swaylock
(nerdfonts.override { fonts = [ "RobotoMono" ]; })
];
programs.fish = {
enable = true;
# start sway on login
loginShellInit = ''
if test -z "$DISPLAY" -a $XDG_VTNR = 1
exec sway
end
'';
# disable greeting
shellInit = ''
set fish_greeting
'';
shellAliases = {
"..." = "cd ../..";
"cds" = "cd ~/src/";
"ll" = "ls -lh";
"cal" = "rusti-cal --color -w";
"ip" = "ip -c";
};
};
programs.foot = {
enable = true;
settings = {
main = {
font = "Roboto Mono Nerd Font:size=10";
dpi-aware = "no";
};
# nordiq from https://codeberg.org/dnkl/foot/src/branch/master/themes/
colors = {
background = "0e1420";
foreground = "dbdee9";
regular0 = "5b6272";
regular1 = "bf616a";
regular2 = "a3be8c";
regular3 = "ebcb8b";
regular4 = "81a1c1";
regular5 = "b48ead";
regular6 = "88c0d0";
regular7 = "e5e9f0";
bright0 = "4c566a";
bright1 = "bf616a";
bright2 = "a3be8c";
bright3 = "ebcb8b";
bright4 = "81a1c1";
bright5 = "b48ead";
bright6 = "8fbcbb";
bright7 = "eceff4";
};
};
};
programs.git = {
enable = true;
userEmail = "mail@johannes-rothe.de";
userName = "Johannes Rothe";
aliases = {
ci = "commit";
st = "status";
co = "checkout";
br = "branch";
};
lfs = {
enable = true;
};
extraConfig = {
core = {
editor = "vim";
};
};
};
programs.tmux = {
enable = true;
prefix = "C-a";
historyLimit = 150000;
keyMode = "vi";
customPaneNavigationAndResize = true;
extraConfig = ''
bind-key Space next-window
set -g status-right '#[fg=colour242]#S'
set -g status-left ' '
set -g window-status-format '#I:#W'
set -g window-status-current-format '#I:#W'
set -g allow-rename off
# default statusbar colors
set-option -g status-style bg=colour232,fg=colour239,default
# border
set -g pane-border-style fg=colour234,bg=default
set -g pane-active-border-style fg=colour236,bg=default
# active window title colors
set-window-option -g window-status-current-style fg=colour231,bg=default
set-window-option -g window-status-style fg=colour239,bg=default
# bell
set-window-option -g window-status-bell-style fg=colour232,bg=colour253
# Correct colors
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",*256col*:Tc"
'';
};
programs.rofi = {
enable = true;
font = "Roboto Mono Nerd Font 10";
theme = "Arc-Dark";
};
programs.ssh = {
enable = true;
extraConfig = ''
AddKeysToAgent yes
SendEnv GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
'';
};
programs.vim = {
enable = true;
defaultEditor = true;
# List of supported plugins: nix-env -f '<nixpkgs>' -qaP -A vimPlugins
plugins = [
pkgs.vimPlugins.ale
pkgs.vimPlugins.gitgutter
pkgs.vimPlugins.indentLine
pkgs.vimPlugins.nerdtree
pkgs.vimPlugins.python-syntax
pkgs.vimPlugins.rainbow
pkgs.vimPlugins.sonokai
pkgs.vimPlugins.vim-airline
pkgs.vimPlugins.vim-devicons
pkgs.vimPlugins.vim-go
pkgs.vimPlugins.vim-hcl
pkgs.vimPlugins.vim-isort
pkgs.vimPlugins.vim-terraform
pkgs.vimPlugins.YouCompleteMe
];
extraConfig = ''
set number
set colorcolumn=88
set background=dark
set cursorline
" Theme
if has('termguicolors')
set termguicolors
endif
let g:sonokai_style = "atlantis"
let g:sonokai_disable_italic_comment = 1
colorscheme sonokai
let g:airline_theme = "sonokai"
" Filetypes
au BufNewFile,BufRead *.launch set filetype=xml
augroup indent
autocmd FileType python,go,dockerfile,js,toml :set tabstop=4 softtabstop=4 shiftwidth=4 expandtab autoindent fileformat=unix
autocmd FileType terraform,sh,json,yaml,html,css :set tabstop=2 softtabstop=2 shiftwidth=2 expandtab autoindent fileformat=unix
augroup end
augroup spell
autocmd FileType gitcommit :set spell
autocmd FileType markdown :set spell
augroup end
augroup shortcuts
autocmd FileType terraform nnoremap <F9> :! terraform fmt<CR>
autocmd FileType python nnoremap <F9> :Black<CR> :Isort <CR>
autocmd FileType go nnoremap <F9> <Plug>(go-fmt)<Plug>(go-lint)
autocmd FileType go nnoremap <F7> <Plug>(go-build)
autocmd FileType go nnoremap <F8> <Plug>(go-run)
autocmd FileType go nnoremap gd <Plug>(go-def)
augroup end
" YouCompleteMe
let g:ycm_gopls_binary_path = "${pkgs.gopls}/bin/gopls"
" Black
let g:black_linelength = 88
" NERDTREE
" open nerdtree when no file is specified on startup
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" toggle nerdtree keyboard shortcut
map <C-t> :NERDTreeToggle<CR>
" Devicons
let g:webdevicons_conceal_nerdtree_brackets = 1
syntax enable
if exists("g:loaded_webdevicons")
call webdevicons#refresh()
endif
'';
};
programs.waybar = {
enable = true;
settings = {
mainBar = {
position = "bottom";
height = 24;
modules-left = [
"sway/workspaces"
"sway/mode"
];
modules-right = [
"network"
"cpu"
"memory"
"battery"
"tray"
"clock"
];
"network" = {
format-wifi = " {essid} {ipaddr} ({signalStrength}%)";
format-ethernet = "{ipaddr}";
};
"clock" = {
format = "{:%a, %d.%m.%Y CW%V %H:%M}";
};
"cpu" = {
"interval" = 30;
"format" = "󰗉 {load}";
};
"memory" = {
"interval" = 30;
"format" = " {percentage}%";
};
"battery" = {
"interval" = 10;
"format" = "󰁹 {capacity}% ({time})";
"format-charging" = " {capacity}%";
"format-full" = " {capacity}%";
"states" = {
"warning" = 30;
"critical" = 15;
};
};
};
};
style = ./waybar.css;
};
# Automatic display output management
services.kanshi = {
enable = true;
profiles = {
undocked = {
outputs = [
{
criteria = "eDP-1";
status = "enable";
}
];
};
home_office = {
outputs = [
{
criteria = "eDP-1";
status = "disable";
}
{
criteria = "HDMI-A-2";
status = "enable";
}
];
};
office = {
outputs = [
{
criteria = "eDP-1";
status = "disable";
}
{
criteria = "DP-1";
status = "enable";
}
];
};
};
};
services.swayidle = {
enable = true;
timeouts = [
{ timeout = 1800; command = "${pkgs.swaylock}/bin/swaylock -f -c 000000"; }
{
timeout = 3600;
command = "${pkgs.sway}/bin/swaymsg 'output * dpms off'";
resumeCommand = "${pkgs.sway}/bin/swaymsg 'output * dpms on'";
}
];
events = [
{ event = "before-sleep"; command = "${pkgs.swaylock}/bin/swaylock -f -c 000000"; }
];
};
services.gammastep = {
enable = true;
latitude = 50.81;
longitude = 6.37;
};
services.mako = {
enable = true;
};
wayland.windowManager.sway = {
enable = true;
package = pkgs.sway;
wrapperFeatures.gtk = true;
config = let
wallpaper = "~/.wallpapers/voxel-city-by-huntingfluff.jpg";
in {
modifier = "Mod4";
focus.followMouse = false;
bars = [{
command = "waybar";
}];
output = {
"*" = {
bg = "${wallpaper} fill";
};
};
input = {
"*" = {
xkb_layout = "de";
};
};
menu = "rofi -show drun";
startup = [
{ command = "logseq"; }
];
window = {
hideEdgeBorders = "smart";
titlebar = false;
commands = [
{
command = "move scratchpad, resize set 1280 800";
criteria = {
title = "Logseq";
};
}
];
};
keybindings = let
modifier = config.wayland.windowManager.sway.config.modifier;
in lib.mkOptionDefault {
"--release Print" = "exec flameshot gui";
"${modifier}+l" = "exec swaylock -f -i ${wallpaper} -s fill";
"${modifier}+m" = "scratchpad show";
"XF86MonBrightnessDown" = "exec light -U 10";
"XF86MonBrightnessUp" = "exec light -A 10";
"XF86AudioRaiseVolume" = "exec 'pactl set-sink-volume @DEFAULT_SINK@ +1%'";
"XF86AudioLowerVolume" = "exec 'pactl set-sink-volume @DEFAULT_SINK@ -1%'";
"XF86AudioMute" = "exec 'pactl set-sink-mute @DEFAULT_SINK@ toggle'";
};
};
};
home.file = {
".wallpapers".source = ./wallpapers;
};
# Add extra variables like $EDITOR
home.sessionVariables = {
};
# This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release
# introduces backwards incompatible changes.
#
# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
# release notes.
home.stateVersion = "23.05"; # Please read the comment before changing.
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 KiB

71
home/waybar.css Normal file
View File

@ -0,0 +1,71 @@
* {
border: none;
border-radius: 0;
font-family: Roboto Mono Nerd Font;
font-size: 14px;
box-shadow: none;
text-shadow: none;
transition-duration: 0s;
}
window {
color: #dbdee9;
background: rgba(14, 20, 32, 0.8);
}
#workspaces {
margin: 0 5px;
}
#workspaces button {
padding: 0 5px;
color: rgba(217, 216, 216, 0.4);
}
#workspaces button.visible {
color: rgba(217, 216, 216, 1);
font-weight: bold;
}
#workspaces button.urgent {
color: #fc5d7c;
}
#mode, #battery, #cpu, #memory, #network, #tray, #temperature {
margin: 0px 6px 0px 10px;
min-width: 25px;
}
#network {
color: #e1e3e4;
}
#cpu {
color: #72cce8;
}
#memory {
color: #ba9cf3;
}
#clock {
margin: 0px 6px 0px 10px;
min-width: 25px;
color: #e1e3e4
}
#battery.warning {
color: #f69c5e;
}
#battery.critical {
color: #ff6578;
}
#battery.charging {
color: #9dd274;
}
#battery.full {
color: #9dd274;
}

View File

@ -1,20 +1,7 @@
{ config, pkgs, lib, ... }:
{
environment.systemPackages = with pkgs; [
dmenu
i3status
kanshi
mako
rofi # dmenu replacement
scrot # screenshot
sway-contrib.grimshot
swayidle
swaylock
];
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
};
}