Migrate to flake

This commit is contained in:
Fabian Hauser 2022-04-10 16:15:44 +02:00
parent 7e24481850
commit 6cdbba8c60
42 changed files with 842 additions and 770 deletions

View file

@ -0,0 +1,6 @@
{ pkgs, ... }: {
programs.alacritty = {
enable = true;
settings."background_opacity" = 0.95;
};
}

View file

@ -0,0 +1,115 @@
{ config, pkgs, lib, ... }:
{
imports = [
./evolution.nix
./firefox.nix
./gpg.nix
./ssh.nix
./scripts.nix
./webapps.nix
./vim.nix
./git.nix
./waybar.nix
./psql.nix
./mako.nix
./redshift.nix
./alacritty.nix
./shell.nix
./swaylock.nix
./kanshi.nix
./sway.nix
];
services = {
network-manager-applet.enable = true;
nextcloud-client = {
enable = true;
startInBackground = true;
};
owncloud-client.enable = true;
pasystray.enable = true;
blueman-applet.enable = true;
};
home = {
packages = with pkgs;
[ # Networking
unison
transmission # GUI Tools, maybe extract...
] ++ [ # Desktop Environment Applications
google-chrome
chromium
#midori # TODO: Currently unused
#qutebrowser # TODO: Currently unused
synergy
#quicksynergy # Currently unused
nextcloud-client
owncloud-client
] ++ [ # office # TODO: Migrate to office.nix
# TODO: Build fails!
libreoffice-fresh # TODO: Dictionaries, nixos/nixpkgs#14430
# pdfgrep
# pdftk
# calibre
tectonic
# texstudio
# pandoc
# system-config-printer
# cups-pk-helper
# cups-bjnp
# gutenprint
# gutenprintBin
# hplipWithPlugin
simple-scan
gnome.gnome-online-accounts
gnome.gnome-control-center
] ++ [ # Communication
signal-desktop
tdesktop
discord
mattermost-desktop
# pidgin pidgin-otr pidgin-with-plugins #TODO: Pidgin needed?
#TODO: ekiga?
skype
slack
teams
jitsi-meet-electron
teamviewer
rdesktop
] ++ [ # Development
vscodium
gitlab-runner
docker-compose
vagrant
virt-manager
modemmanager # TODO: makes sense here?
modem-manager-gui
];
#TODO: Write module
activation.statefulConfigSymlinks =
config.lib.dag.entryAfter [ "writeBoundary" ] ''
set -eo pipefail
STATEFUL_CONFS=(
".config/spotify"
".mozilla"
".password-store"
)
for STATEFUL_CONF in ''${STATEFUL_CONFS[@]}; do
if [ -e "$STATEFUL_CONF" ] && [ ! -h "$STATEFUL_CONF" ]; then
echo "File $STATEFUL_CONF already exists, exiting!" >&2
exit 1
fi
if [ -h "$STATEFUL_CONF" ]; then
rm "$STATEFUL_CONF"
fi
$DRY_RUN_CMD ln -s $VERBOSE_ARG "$HOME/.stateful/$STATEFUL_CONF" "$HOME/$STATEFUL_CONF"
done
'';
};
}

View file

@ -0,0 +1,4 @@
{ pkgs, ... }: {
dconf.settings."org/gnome/evolution-data-server/calendar".notify-enable-audio =
false;
}

View file

@ -0,0 +1,10 @@
{ pkgs, ... }: {
programs.firefox = {
enable = true;
package = pkgs.firefox-wayland;
};
home.sessionVariables = {
MOZ_ENABLE_WAYLAND = "true";
MOZ_DBUS_REMOTE = "1";
};
}

View file

@ -0,0 +1,92 @@
{ pkgs, ... }: {
programs.git = {
enable = true;
package = pkgs.gitAndTools.gitFull;
aliases = {
s = "status --short --branch";
a = "add --patch";
c = "commit --message";
l =
"log --color --graph --pretty=format:'%Cred%h%Creset - %C(bold)%s%Creset%C(yellow)%d%Creset %C(green)%an%Creset %C(cyan)%cr%Creset (S: %G?)' --abbrev-commit";
d = "diff";
fup = "commit --fixup";
fuprebase = "rebase --interactive --autosquash";
ignore = "update-index --skip-worktree";
unignore = "update-index --no-skip-worktree";
ignored = ''!git ls-files -v | grep "^S"'';
};
#delta = {
# enable = true;
# options = {
# side-by-side = "true";
# line-numbers = "true";
# line-numbers-minus-style = "#444444";
# line-numbers-zero-style = "#444444";
# line-numbers-plus-style = "#444444";
# line-numbers-left-format = "{nm:>4}┊";
# line-numbers-right-format = "{np:>4}│";
# line-numbers-left-style = "blue";
# line-numbers-right-style = "blue";
# };
#};
extraConfig = {
core = {
packedGitWindowSize = "16m";
packedGitLimit = "64m";
};
pack = {
windowMemory = "64m";
packSizeLimit = "64m";
thread = "1";
deltaCacheSize = "1m";
};
color = {
branch = "auto";
diff = "auto";
status = "auto";
};
submodule.recurse = true;
push.default = "current";
pull.rebase = "true";
branch.autosetuprebase = "always";
log.follow = true;
rerere.enabled = true;
};
includes = let
mkDefaultConfig = (dir: {
condition = "gitdir:${dir}";
contents = {
user = {
signingkey = "0x8A52A140BEBF7D2C";
email = "fabian@fh2.ch";
name = "Fabian Hauser";
};
};
});
workConfig = {
contents = {
commit.gpgsign = true;
tag.gpgsign = true;
user = {
signingkey = "0xE0CDD70E5D286D64";
email = "fabian.hauser@threema.ch";
};
url."git@work.github.com".insteadOf = "git@github.com";
};
};
in [
(mkDefaultConfig "~/private/")
(mkDefaultConfig "/etc/nixos/")
(mkDefaultConfig "~/.password-store/")
(mkDefaultConfig "~/shares/cloud.qo.is/")
(mkDefaultConfig "~/shares/drive.switch.ch/")
((mkDefaultConfig "~/work/") // workConfig)
((mkDefaultConfig "~/shares/cloud.threema.ch/") // workConfig)
];
ignores = [ "*~" "*.swp" ".direnv/" ];
lfs.enable = true;
};
}

View file

@ -0,0 +1,45 @@
{ pkgs, pkgsUnstable, ... }: {
#TODO: ENV variabls for agent
home.sessionVariables.SSH_AUTH_SOCK =
"/run/user/1000/gnupg/S.gpg-agent.ssh";
programs.gpg = {
enable = true;
package = pkgsUnstable.gnupg;
settings = {
"use-agent" = true;
"trust-model" = "tofu";
"no-emit-version" = true;
"no-comments" = true;
"sig-notation" = "issuer-fpr@notations.openpgp.fifthhorseman.net=%g";
"keyserver" = "hkps://keys.openpgp.org";
"keyserver-options" = "auto-key-retrieve no-honor-keyserver-url";
"personal-cipher-preferences" = "AES256 AES192 AES CAST5";
"cert-digest-algo" = "SHA512";
"personal-digest-preferences" = "SHA512 SHA384 SHA256 SHA224";
"default-preference-list" =
"SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed";
"display-charset" = "utf-8";
"fixed-list-mode" = true;
"with-fingerprint" = true;
"keyid-format" = "0xlong";
"verify-options" = "show-uid-validity";
"list-options" = "show-uid-validity";
};
scdaemonSettings = { disable-ccid = true; };
# TODO: Complete this list and maybe transfer to managed configuration?
#publicKeys = [
# { source = "./fabian.hauser@qo.is.pub"; trust = 5; }
# { source = "./fabian.hauser@threema.ch.pub"; trust = 5; }
#];
};
services.gpg-agent = {
enable = true;
enableScDaemon = true;
enableSshSupport = true;
enableExtraSocket = true;
sshKeys = [
"99DFB0F28CF9420A2D6383139E86814A1568C81B" # 0x8193A5D218B553DD / fabian.hauser@threema.ch
"638143D3F6421377E9D4C7F1D2EDC5AA0A860351" # 0x3E957C9C8CB5D6B2 / fabian.hauser@qo.is
];
};
}

View file

@ -0,0 +1,65 @@
{ pkgs, lib, config, ... }: {
# systemd.user.services.kanshi.Install.WantedBy = "home-manager-fhauser.service"; # TODO: Upstream array type of systemdTarget
services.kanshi = {
enable = true;
profiles = let
backgroundPicturePath = "~/pictures/backgrounds";
backgroundCommand = ''
#swaymsg "output * bg `find ${backgroundPicturePath} -type f | shuf -n 1` fill"
'';
mkScreen = (screen: {
criteria = screen;
status = "enable";
scale = 1.0;
});
in rec {
#mobile-work.exec = backgroundCommand;
mobile-work.outputs = [
(mkScreen "Unknown 0x08CE 0x00000000" // {
position = "0,0";
scale = 2.0;
})
];
mobile-work-external.outputs = [
(mkScreen "Unknown 0x08CE 0x00000000" // {
position = "1920,0";
scale = 2.0;
})
(mkScreen "Lenovo Group Limited M14 V907R2HD" // { position = "0,0"; })
];
mobile-private.outputs = [
(mkScreen "Unknown 0x1536 0x00000000" // {
position = "0,0";
scale = 1.5;
})
];
home-dock.outputs = mobile-work.outputs ++ [
(mkScreen "Dell Inc. DELL P2720DC 22JPK53" // {
position = "1920,0";
scale = 1.0;
status = "enable";
})
];
office-dock.outputs = [
(mkScreen "Dell Inc. DELL P2720DC BRKPK53" // { position = "0,0"; })
(mkScreen "Dell Inc. DELL P2720DC 6JRRK53" // { position = "2560,0"; })
(mkScreen "Unknown 0x08CE 0x00000000" // {
position = "5120,0";
scale = 2.0;
})
];
home-pc.outputs = [
(mkScreen "Dell Inc. DELL P2720DC 22JPK53" // { position = "0,0"; })
(mkScreen "Unknown HP Z27 CN482201RP" // {
position = "2560,0";
scale = 1.5;
})
];
home-pc-row.outputs = home-pc.outputs ++ [
(mkScreen "Eizo Nanao Corporation EV2450 92395086" // {
position = "5120,0";
})
];
};
};
}

View file

@ -0,0 +1,14 @@
{ pkgs, ... }: {
programs.mako = {
enable = true;
backgroundColor = "#CCCCCCCC"; # TODO: Make layout colors in a central place
borderSize = 0;
#borderColor = "#4C7899FF";
defaultTimeout = 1500;
#ignoreTimeout = true;
#textColor = "#FFFFFFFF";
#width = 300;
#height = 100;
#font = "monospace 10";
}; # TODO
}

View file

@ -0,0 +1,21 @@
{ pkgs, ... }: {
home.file.".psqlrc".text = ''
\set QUIET 1
\pset linestyle unicode
\pset border 2
\set null [null]
\set COMP_KEYWORD_CASE upper
\set ON_ERROR_ROLLBACK interactive
\set PROMPT1 '%[%033[1m%]%M/%/%R%[%033[0m%]%# '
\set PROMPT2 ''''
\set VERBOSITY verbose
\timing
\x auto
\unset QUIET
\conninfo
'';
}

View file

@ -0,0 +1,13 @@
{ pkgs, ... }: {
services.redshift = {
enable = true;
package = pkgs.redshift-wlr;
settings.redshift.brightness-night = "0.9";
temperature.day = 6300;
temperature.night = 5500;
latitude = "47.2";
longitude = "8.8";
tray = true;
};
}

View file

@ -0,0 +1,79 @@
{ pkgs, config, ... }:
let
passbemenu = pkgs.writeScriptBin "passbemenu" ''
#!${pkgs.stdenv.shell}
shopt -s nullglob globstar
typeit=0
if [[ $1 == "--type" ]]; then
typeit=1
shift
fi
export BEMENU_BACKEND=wayland
prefix=''${PASSWORD_STORE_DIR-~/.password-store}
password_files=( $(find -L "$prefix" -type f -name '*.gpg') )
password_files=( "''${password_files[@]#"$prefix"/}" )
password_files=( "''${password_files[@]%.gpg}" )
password=$(printf '%s\n' "''${password_files[@]}" | \
${pkgs.bemenu}/bin/bemenu --list 20 --ignorecase --prompt 'Pass: ' "$@")
[[ -n $password ]] || exit
${pkgs.pass-wayland}/bin/pass show -c "$password" 2>/dev/null
'';
threema-vpn = pkgs.writeScriptBin "threema-vpn" ""; #''
# #!${pkgs.stdenv.shell}
# set -eo pipefail
# SERVICE=openvpn-threema
# SERVICE_EXEC="${config.systemd.services.openvpn-threema.serviceConfig.ExecStart}"
# exec sudo ${pkgs.openvpn}/sbin/openvpn''${SERVICE_EXEC#@* openvpn}
#'';
threema-env = pkgs.writeScriptBin "threema-env" ''
#!/usr/bin/env bash
set -eo pipefail
# Nix shell might fail on some PWDs, so go to home
OLD_PWD=`pwd`
cd $HOME
ENV_NAME="$1"
ENV_FILE="$HOME/shares/cloud.threema.ch/envs/''${ENV_NAME}.nix"
COMMAND="''${2-bash}"
if [ -z "$ENV_NAME" ]; then
echo "Error: No env name provided" >&2
exit 2
fi
if [ ! -f "$ENV_FILE" ]; then
echo "Error: Env file does not exist" >&2
exit 3
fi
echo "Starting '$COMMAND' in env '$ENV_FILE'"
${pkgs.nix}/bin/nix-shell ''${ENV_FILE} --run "(cd $OLD_PWD; $COMMAND)"
'';
wsudo = with pkgs.xorg;
pkgs.writeScriptBin "wsudo" ''
#!/usr/bin/env bash
#small script to enable root access to x-windows system
${xhost}/bin/xhost +SI:localuser:root
sudo $1
#disable root access after application terminates
${xhost}/bin/xhost -SI:localuser:root
#print access status to allow verification that root access was remov
ed
${xhost}/bin/xhost
'';
in {
home.packages =
[ passbemenu threema-vpn threema-env wsudo ];
}

View file

@ -0,0 +1,59 @@
{ pkgs, ... }: {
programs = {
bash = {
enable = true;
historyIgnore = [ "ls" "cd" "exit" "j" ];
shellAliases = {
# Sane defaults
l = "ls -lah";
cp = "cp --reflink=auto";
pwgen = "pwgen -c -n -s -N 30";
bc = "bc --mathlib";
cal = "cal -m";
curl = "curl -L";
# Git helpers
git-fetch-pr =
"git config --add remote.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pr/*'";
git-config-fetchall = ''
git config --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*"'';
git-enable-signing =
"git config commit.gpgsign true && git config tag.gpgsign true";
# Common Typos
gits = "git s";
};
initExtra = ''
function o(){
xdg-open "$*" >/dev/null 2>&1 &
}
'';
shellOptions = [ "autocd" "checkjobs" "dotglob" "globstar" "histappend" ];
sessionVariables = {
#TODO: Some of these should be migrated to the according application.
GPG_TTY = "$(tty)";
PGDATABASE = "postgres";
};
};
autojump = {
enable = true;
enableBashIntegration = true;
};
powerline-go = {
enable = true;
settings = {
hostname-only-if-ssh = true;
numeric-exit-codes = true;
colorize-hostname = true;
cwd-max-depth = 4;
modules = "ssh,host,root,cwd,perms,dotenv,venv,node,git,jobs";
};
};
direnv = {
enable = true;
enableBashIntegration = true;
nix-direnv.enable = true;
};
};
}

View file

@ -0,0 +1,26 @@
{ pkgs, lib, ... }: {
programs.ssh = let
forceIdentityThreema = {
identityFile = toString (pkgs.writeText "fabian.hauser@threema.ch.pub" ''
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO7h492sXT7zdamf+nbOt+y6jiqxicOnm6+wiuEG1EvZ openpgp:0x18B553DD
'');
identitiesOnly = true;
};
forceIdentityPrivate = {
identityFile = toString (pkgs.writeText "fabian.hauser@qo.is.pub" ''
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIPF8ZV7vhpbVvLxiKq8ANVusNUHMbtii5MuvjxCbVz7vSNVPo9OOLvYyDqhbRAWMTdQeGZVAaALBufKKmprDTRFMpnA7Ut4TFrdz/5DTaR2KEjJ7P75moH+0xooR/GsbzFGsNBSQSXK3u1igndPYEC/PqCHN++32kDo2wLqTB4VLrEovU3iq8BMckn329Bu1fGbXKTgDpEvUEEwFO2brQZLMmzILGF/v4B9ImEGtinAUNgDSfEpgPN23sdWQH9rwEClGv95JmWNf05tuVomhZzOBtCFoAno3XB1nj16avjsqJ3aGFY2CCcfsNrwKzhIotmm82bcI4BJuJIVRIKbZ1 cardno:000610954665
'');
identitiesOnly = true;
};
in {
enable = true;
matchBlocks = {
"work.github.com" = forceIdentityThreema // {
hostname = "github.com";
user = "git";
};
"github.com" = forceIdentityPrivate // { user = "git"; };
};
#TODO: Authorized keys implementation, see https://github.com/nix-community/home-manager/pull/9
};
}

View file

@ -0,0 +1,156 @@
{ pkgs, lib, config, ... }: let
adhereTheSwayTarget = {
Install.WantedBy = lib.mkForce [ "sway-session.target" ];
Unit.PartOf = lib.mkForce [ "sway-session.target" ];
};
# TODO: active screen with -m $active_screen
bemenuLauncher = pkgs.writeScriptBin "bemenuLauncher" ''
#!${pkgs.stdenv.shell}
#active_screen=$(swaymsg -r -t get_outputs | \
# ${pkgs.jq}/bin/jq '. [] | select (.focused == true) | .name | split ("-") | last')
${pkgs.dmenu}/bin/dmenu_path | \
${pkgs.bemenu}/bin/bemenu --list 20 --ignorecase --prompt 'Start: ' | \
xargs swaymsg exec --
'';
in rec {
home.packages = with pkgs; [
sway-contrib.grimshot
wl-clipboard
libappindicator
gnome.defaultIconTheme
gnome2.gnome-icon-theme
hicolor-icon-theme # TODO: Move these requirements?
];
xsession.preferStatusNotifierItems = true;
wayland.windowManager.sway = {
enable = true;
systemdIntegration = true;
xwayland = true;
wrapperFeatures = { gtk = true; };
extraSessionCommands = ''
#export XDG_CURRENT_DESKTOP=Unity
export XDG_CURRENT_DESKTOP=sway
export XDG_SESSION_TYPE="wayland"
export _JAVA_AWT_WM_NONREPARENTING=1
export SSH_AUTH_SOCK=/run/user/1000/gnupg/S.gpg-agent.ssh # TODO: Migrate
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
# TODO: QTpie
export WLR_DRM_NO_MODIFIERS=1
export WLR_NO_HARDWARE_CURSORS=1
'';
config = {
input = {
"type:keyboard" = {
xkb_layout = "ch,de";
xkb_options = "eurosign:e";
};
"*" = { xkb_numlock = "enable"; };
};
terminal = "${pkgs.alacritty}/bin/alacritty";
menu = "${bemenuLauncher}/bin/bemenuLauncher";
gaps.inner = 8;
modifier = "Mod4";
window.border = 0;
#colors.focused.border = "#323232";
#TODO: Workspace Programm assignment: Not working properly
assigns = {
"10" = [{ app_id = "^firefox$"; }];
"11" = [{ app_id = "^(claws-mail|thunderbird|evolution)$"; }];
"12" = [{
class = "^Chromium-browser$";
instance = "^web.threema.ch";
}];
"13" = [{ class = "^Spotify$"; }];
};
keybindings = let
mod = wayland.windowManager.sway.config.modifier;
playerctl = "${pkgs.playerctl}/bin/playerctl";
pamixer = "${pkgs.pamixer}/bin/pamixer";
light = "${pkgs.light}/bin/light";
in lib.mkOptionDefault {
"${mod}+p" = "exec passbemenu";
"${mod}+x" = "move workspace to output right";
"${mod}+y" = "move workspace to output left";
"${mod}+section" = "workspace 0";
"${mod}+0" = "workspace 10";
"${mod}+apostrophe" = "workspace 11";
"${mod}+dead_circumflex" = "workspace 12";
"${mod}+dead_diaeresis" = "workspace 13";
"${mod}+dollar" = "workspace 14";
"${mod}+Shift+section" = "move container to workspace 0";
"${mod}+Shift+0" = "move container to workspace 10";
"${mod}+Shift+apostrophe" = "move container to workspace 11";
"${mod}+Shift+dead_circumflex" = "move container to workspace 12";
"${mod}+Shift+dead_diaeresis" = "move container to workspace 13";
"${mod}+Shift+dollar" = "move container to workspace 14";
"Ctrl+mod1+l" = "exec ${pkgs.systemd}/bin/loginctl lock-session";
"Ctrl+mod1+Shift+L" = "exec ${pkgs.systemd}/bin/systemctl suspend";
# pulse audio volume control
XF86AudioLowerVolume = "exec ${pamixer} --decrease 3";
XF86AudioRaiseVolume = "exec ${pamixer} --increase 3";
XF86AudioMute = "exec ${pamixer} --toggle-mute";
XF86AudioMicMute = "exec ${pamixer} --default-source --toggle-mute";
# Spotify control
XF86AudioPause = "exec ${playerctl} play-pause";
XF86AudioPlay = "exec ${playerctl} play-pause";
XF86AudioNext = "exec ${playerctl} next";
XF86AudioPrev = "exec ${playerctl} previous";
# screen brightness
XF86MonBrightnessUp = "exec ${light} -A 10";
XF86MonBrightnessDown = "exec ${light} -U 5";
# screenshot
Print = "exec ${pkgs.sway-contrib.grimshot}/bin/grimshot copy area";
};
};
extraConfig = ''
# Disable the laptop screen when the lid is closed.
bindswitch --reload lid:on output eDP-1 disable
bindswitch --reload lid:off output eDP-1 enable
'';
};
systemd.user.services.network-manager-applet = adhereTheSwayTarget;
systemd.user.services.nextcloud-client = adhereTheSwayTarget // {
# For trayicon to work:
Unit.After = [ "waybar.service" ];
Service = {
ExecStartPre = "${pkgs.coreutils}/bin/sleep 3";
Environment = lib.mkForce
"PATH=${config.home.profileDirectory}/bin XDG_CURRENT_DESKTOP=Unity";
};
};
systemd.user.services.owncloud-client = adhereTheSwayTarget // {
# For trayicon to work:
Unit.After = [ "waybar.service" ];
Service = {
ExecStartPre = "${pkgs.coreutils}/bin/sleep 3";
Environment = lib.mkForce
"PATH=${config.home.profileDirectory}/bin XDG_CURRENT_DESKTOP=Unity";
};
};
systemd.user.services.pasystray = adhereTheSwayTarget;
gtk = {
iconTheme = {
# package = pkgs.gnome-icon-theme;
# name = "gnome";
package = pkgs.hicolor_icon_theme;
name = "hicolor";
};
gtk3.extraConfig.gtk-menu-images = true;
};
dconf.settings = { "org/gnome/desktop/interface".menus-have-icons = true; };
}

View file

@ -0,0 +1,33 @@
{ pkgs, ... }: {
systemd.user.services.swayidle = let
lock =
"${pkgs.swaylock}/bin/swaylock --hide-keyboard-layout --ignore-empty-password --daemonize --show-failed-attempts --color=000000";
logTimeCmd = "${pkgs.coreutils}/bin/date --rfc-3339=seconds >> ~/locklog";
idleCmd = (action:
''${pkgs.sway}/bin/swaymsg "output * dpms ${action}" && ${logTimeCmd}'');
timeout-screens-off = 600;
timeout-lock = 630;
timeout-suspend = 1800;
in {
Unit = {
Description = "Idle Manager for Wayland";
Documentation = [ "man:swayidle(1)" ];
PartOf = [ "graphical-session.target" ];
};
Service = {
Environment = "PATH=${pkgs.bash}/bin";
ExecStart = ''
${pkgs.swayidle}/bin/swayidle -w -d \
timeout ${toString timeout-lock} '${lock}' \
timeout ${toString timeout-screens-off} '${idleCmd "off"}' \
resume '${idleCmd "on"}' \
timeout ${
toString timeout-suspend
} '${pkgs.systemd}/bin/systemctl suspend' \
lock '${lock}' \
before-sleep '${lock}';
''; # TODO: Make this configurable and add home-manager module. (Requires sway with systemd-target support)
};
Install = { WantedBy = [ "sway-session.target" ]; };
};
}

View file

@ -0,0 +1,54 @@
{ pkgs, ... }: {
programs.vim = {
enable = true;
extraConfig = ''
colorscheme elflord
set autoindent
set ruler
set pastetoggle=<F2>
set splitbelow
set splitright
set tabstop=2
set softtabstop=2
set listchars="eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:"
set grepprg=ack\ -k
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
"nnoremap <C-w>E :SyntasticCheck<CR> :SyntasticToggleMode<CR>
" Rust
"let g:rustfmt_autosave = 1
let g:racer_cmd="~/.cargo/bin/racer"
"let g:racer_experimental_completer = 1
au FileType rust nmap gd <Plug>(rust-def)
au FileType rust nmap gs <Plug>(rust-def-split)
au FileType rust nmap gx <Plug>(rust-def-vertical)
au FileType rust nmap <leader>gd <Plug>(rust-doc)
" Typescript
au BufRead,BufNewFile *.ts setfiletype typescript
" Options
filetype plugin indent on
syntax on
'';
plugins = with pkgs.vimPlugins; [ vim-sensible vim-airline ];
settings = {
background = "dark";
ignorecase = true;
mouse = "n";
hidden = true;
expandtab = true;
};
};
}

View file

@ -0,0 +1,384 @@
{ pkgs, lib, config, ... }: {
xsession.preferStatusNotifierItems = true;
wayland.windowManager.sway.config.bars = [ ];
programs.waybar = {
enable = true;
settings = [{
position = "top";
#height =
modules-left = [ "sway/mode" "sway/workspaces" ];
modules-center = [ "sway/window" ];
modules-right = [
"backlight"
"idle_inhibitor"
"bluetooth"
"cpu"
"temperature"
"memory"
"disk"
"network"
"pulseaudio"
#"custom/keyboard-layout"
"battery"
"tray"
"clock"
];
modules = {
backlight.format = " {percent}%";
disk.format = " {percentage_used}%";
clock.format = "{:%Y-%2m-%2d%H:%M}";
"sway/workspaces" = {
disable-scroll-wraparound = true;
enable-bar-scroll = true;
numeric-first = true;
};
battery = {
interval = 10;
states = {
warning = 15;
critical = 10;
};
format = " {capacity}% {time}"; # Icon: bolt
format-discharging = "{icon} {capacity}% {time}";
format-time = "{H}:{M}";
format-icons = [
"" # Icon: battery-full
"" # Icon: battery-three-quarters
"" # Icon: battery-half
"" # Icon: battery-quarter
"" # Icon: battery-empty
];
tooltip = "true";
};
cpu = {
interval = "5";
format = " {usage}% ({load})"; # Icon: microchip
states = {
warning = "70";
critical = "90";
};
};
#"custom/keyboard-layout" = {
# exec = pkgs.writeShellScript "keyboard-layout" "swaymsg -t get_inputs | grep -m1 'xkb_active_layout_name' | cut -d '\"' -f4";
# # Interval set only as a fallback, as the value is updated by signal
# interval = "30";
# format = " {}"; # Icon: keyboard
# # Signal sent by Sway key binding (~/.config/sway/key-bindings)
# signal = "1"; # SIGHUP
# tooltip = "false";
#};
memory = {
interval = "5";
format = " {}%"; # Icon: microchip
states = {
warning = "70";
critical = "90";
};
};
network = {
interval = "5";
format-wifi = " {essid} ({signalStrength}%)"; # Icon: wifi
format-ethernet = "🔗 {ifname}: {ipaddr}/{cidr}"; # Icon: ethernet
format-disconnected = "🔗";
tooltip-format = "{ifname}: {ipaddr}";
};
"sway/mode" = {
format =
''<span style="italic"> {}</span>''; # Icon: expand-arrows-alt
tooltip = "false";
};
"sway/window" = {
format = "{}";
max-length = "120";
};
"sway/workspaces" = {
all-outputs = false;
disable-scroll = true;
format = "{icon}";
format-icons = {
"10" = " 10";
"11" = " 11";
"12" = " 12";
"13" = " 13";
};
};
pulseaudio = {
scroll-step = 3;
format = "{icon} {volume}%";
format-bluetooth = "{icon} {volume}%";
format-muted = "🔇";
format-icons = {
headphones = "";
handsfree = "";
headset = "";
phone = "";
portable = "";
car = "";
default = [ "" "" "" ];
};
on-click = "pavucontrol";
};
temperature = {
critical-threshold = 80;
interval = 5;
format = "{icon} {temperatureC}°C";
format-icons = [
"" # Icon: temperature-empty
"" # Icon: temperature-quarter
"" # Icon: temperature-half
"" # Icon: temperature-three-quarters
"" # Icon: temperature-full
];
tooltip = "true";
hwmon-path = "/sys/class/hwmon/hwmon2/temp1_input";
};
idle_inhibitor = {
format = "{icon}";
format-icons = {
activated = "";
deactivated = "";
};
};
tray = {
icon-size = "21";
spacing = "10";
};
};
}];
systemd.enable = true;
style = ''
/* =============================================================================
*
* Waybar configuration
*
* Configuration reference: https://github.com/Alexays/Waybar/wiki/Configuration
*
* =========================================================================== */
/* -----------------------------------------------------------------------------
* Keyframes
* -------------------------------------------------------------------------- */
@keyframes blink-warning {
70% {
color: white;
}
to {
color: white;
background-color: orange;
}
}
@keyframes blink-critical {
70% {
color: white;
}
to {
color: white;
background-color: red;
}
}
/* -----------------------------------------------------------------------------
* Base styles
* -------------------------------------------------------------------------- */
/* Reset all styles */
* {
border: none;
border-radius: 0;
min-height: 0;
margin: 0;
padding: 0;
}
/* The whole bar */
#waybar {
background: #323232;
color: white;
/*font-family: Cantarell, Noto Sans, sans-serif;*/
font-size: 13px;
}
/* Each module */
#battery,
#clock,
#cpu,
#custom-keyboard-layout,
#memory,
#mode,
#network,
#pulseaudio,
#temperature,
#backlight,
#idle_inhibitor,
#tray {
margin-left: 5px;
margin-right: 5px;
padding-left: 5px;
padding-right: 5px;
/*border-right: solid 1px black;*/
}
#backlight {
margin-right: 0;
padding-right: 0;
}
#idle_inhibiter {
margin-left: 0;
padding-left: 0;
}
/* -----------------------------------------------------------------------------
* Module styles
* -------------------------------------------------------------------------- */
#battery {
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#battery.warning {
color: orange;
}
#battery.critical {
color: red;
}
#battery.warning.discharging {
animation-name: blink-warning;
animation-duration: 4s;
}
#battery.critical.discharging {
animation-name: blink-critical;
animation-duration: 3s;
}
#clock {
font-weight: bold;
}
#cpu {
/* No styles */
}
#cpu.warning {
color: orange;
}
#cpu.critical {
color: red;
}
#memory {
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#memory.warning {
color: orange;
}
#memory.critical {
color: red;
animation-name: blink-critical;
animation-duration: 2s;
}
#mode {
background: #64727D;
border-top: 2px solid white;
/* To compensate for the top border and still have vertical centering */
padding-bottom: 2px;
}
#network {
/* No styles */
}
#network.disconnected {
color: orange;
}
#pulseaudio {
/* No styles */
}
#pulseaudio.muted {
/* No styles */
}
#custom-spotify {
color: rgb(102, 220, 105);
}
#temperature {
/* No styles */
}
#temperature.critical {
color: red;
}
#tray {
/* No styles */
}
#window {
font-weight: bold;
}
#workspaces button {
border-top: 2px solid transparent;
/* To compensate for the top border and still have vertical centering */
padding-bottom: 2px;
padding-left: 10px;
padding-right: 10px;
color: #888888;
}
#workspaces button.focused {
border-color: #4c7899;
color: white;
background-color: #285577;
}
#workspaces button.urgent {
border-color: #c9545d;
color: #c9545d;
}
'';
};
systemd.user.services.waybar = with lib; {
# Install.WantedBy = mkForce [ "sway-session.target" ]; # TODO: Set as systemd.target with 22.05
Unit = {
Requisite = mkForce [ ];
After = mkForce [ ];
PartOf = [ "tray.target" ];
};
};
}

View file

@ -0,0 +1,26 @@
{ pkgs, ... }:
let
web-app = name: url:
pkgs.writeScriptBin name ''
#!${pkgs.stdenv.shell}
exec ${pkgs.chromium}/bin/chromium --user-data-dir=$HOME/.config/chromium-app-${name} --app="${url}"
'';
whatsapp = web-app "whatsapp" "https://web.whatsapp.com/";
threema = web-app "threema" "https://web-beta.threema.ch/";
threema-work = web-app "threema-work" "https://web-beta.threema.ch/";
threema-red = web-app "threema-red" "https://web-work-staging.threema.ch/";
threema-tickets = web-app "threema-tickets" "https://ticket.threema.ch/scp/";
netflix = web-app "netflix" "https://netflix.com/";
disneyplus = web-app "disneyplus" "https://disneyplus.com/";
in {
home.packages = [
whatsapp
netflix
disneyplus
threema
threema-work
threema-red
threema-tickets
];
}