From 2823c2f0f906c4c0d5c92081b31fabaccb15fa4d Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Fri, 20 May 2022 12:39:40 +0200 Subject: [PATCH] Maintain more global options via home-manager Use home-manager to create xsession. Readme contains info on how to start xsession on login. That way home-manager can maintain languages, keyboard and further stuff globally for user. No more need to set stuff as workaround within i3 or zsh. Also enabled to start systemd units after login, as home-manager will create and trigger `hm-graphical-session.target`. --- home.nix | 4 ++- home/home.nix | 68 +++++++++++++++++++++++++++++++++++ home/programs/zsh.nix | 36 ------------------- home/services/batteryicon.nix | 2 +- home/windowManager/i3.nix | 10 ++---- home/xsession.nix | 11 ++++++ readme.md | 17 +++++++++ 7 files changed, 102 insertions(+), 46 deletions(-) create mode 100644 home/home.nix create mode 100644 home/xsession.nix diff --git a/home.nix b/home.nix index 996b5e2..6a6975f 100644 --- a/home.nix +++ b/home.nix @@ -31,6 +31,8 @@ file = import ./home/files.nix { }; + } // import ./home/home.nix { + inherit pkgs; }; nix = import ./home/programs/nix.nix { @@ -70,7 +72,7 @@ }; - xsession.windowManager.i3 = import ./home/windowManager/i3.nix { + xsession = import ./home/xsession.nix { inherit config pkgs; }; diff --git a/home/home.nix b/home/home.nix new file mode 100644 index 0000000..348b004 --- /dev/null +++ b/home/home.nix @@ -0,0 +1,68 @@ +{ pkgs }: + +let + usLocale = "en_US.UTF-8"; + +in { + + language = { + base = "${usLocale}"; + ctype = "${usLocale}"; + numeric = "${usLocale}"; + time = "${usLocale}"; + collate = "${usLocale}"; + monetary = "${usLocale}"; + messages = "${usLocale}"; + paper = "${usLocale}"; + name = "${usLocale}"; + address = "${usLocale}"; + telephone = "${usLocale}"; + measurement = "${usLocale}"; + }; + + keyboard = { + layout = "us"; + model = "pc105"; + options = [ + "numpad:mac" + "ctrl:nocaps" + "compose:ralt" + ]; + }; + + sessionVariables = { + EDITOR = "${pkgs.neovim}/bin/nvim"; + SHELL = "${pkgs.zsh}/bin/zsh"; + + TYPO3_CONTEXT = "Development/dsiepmann"; + TYPO3_ADDITIONAL_CONFIGURATION = "/home/daniels/.local/share/typo3-configuration/AdditionalConfiguration.inc.php"; + + LSCOLORS = "HxGxDxDxbxDxDxababcxcx"; + LS_COLORS = "di=1;37:ln=1;36:so=1;33:pi=1;33:ex=31:bd=1;33:cd=1;33:su=30;41:sg=30;41:tw=32:ow=32"; + GREP_COLOR = "0;30;44"; + PHAN_COLOR_SCHEME = "code"; + }; + + shellAliases = { + ll = "ls -laph --color=auto"; + + # Open in main view with all references. + tigr = "tig refs"; + # Open in main view with ALL commits, not only current branch tree. + tiga = "tig --all --show-signature"; + + # Tmux outside tmux. + ta = "tmux attach"; + tc = "tmux new-session -s "; + + # TYPO3 contribution specific commands + t3Push = "git push origin HEAD:refs/for/master"; + t3Pull = "git pull --rebase origin master; git checkout master"; + t3Rollback = "git checkout master; git reset --hard origin/master"; + t3Clean = "t3Rollback && t3Pull"; + + # TODO: Move to nix package / shellapplication Create borg backup + createBackup = "mkdir -p ~/backup-etc && sudo cp -r /etc/* ~/backup-etc && sudo cp -r /etc/.* ~/backup-etc && sudo chown daniels:daniels -R ~/backup-etc/ && borg create -v --progress --stats --exclude-from ~/.config/borg/exclude /media/daniels/Backup::$(date +%F-%R) ~/; sudo rm -rf ~/backup-etc"; + }; + +} diff --git a/home/programs/zsh.nix b/home/programs/zsh.nix index 00bd18c..95976ac 100644 --- a/home/programs/zsh.nix +++ b/home/programs/zsh.nix @@ -10,48 +10,12 @@ # Can be re sourced via: __HM_ZSH_SESS_VARS_SOURCED= source ~/.zshenv sessionVariables = { - LC_ALL = "en_US.UTF-8"; - LANG = "en_US.UTF-8"; - LANGUAGE = "en_US"; - MANPAGER="${pkgs.page}/bin/page -C -e 'au User PageDisconnect sleep 100m|%y p|enew! |bd! #|pu p|set ft=man'"; - EDITOR = "${pkgs.neovim}/bin/nvim"; - SHELL = "${pkgs.zsh}/bin/zsh"; - - LSCOLORS = "HxGxDxDxbxDxDxababcxcx"; - LS_COLORS = "di=1;37:ln=1;36:so=1;33:pi=1;33:ex=31:bd=1;33:cd=1;33:su=30;41:sg=30;41:tw=32:ow=32"; - GREP_COLOR = "0;30;44"; - - TYPO3_CONTEXT = "Development/dsiepmann"; - TYPO3_ADDITIONAL_CONFIGURATION = "/home/daniels/.local/share/typo3-configuration/AdditionalConfiguration.inc.php"; - PHAN_COLOR_SCHEME = "code"; # Reduce timeout after (vi keybindings) KEYTIMEOUT = 1; }; - shellAliases = { - ll = "ls -laph --color=auto"; - - # Open in main view with all references. - tigr = "tig refs"; - # Open in main view with ALL commits, not only current branch tree. - tiga = "tig --all --show-signature"; - - # Tmux outside tmux. - ta = "tmux attach"; - tc = "tmux new-session -s "; - - # TYPO3 contribution specific commands - t3Push = "git push origin HEAD:refs/for/master"; - t3Pull = "git pull --rebase origin master; git checkout master"; - t3Rollback = "git checkout master; git reset --hard origin/master"; - t3Clean = "t3Rollback && t3Pull"; - - # Create borg backup - createBackup = "mkdir -p ~/backup-etc && sudo cp -r /etc/* ~/backup-etc && sudo cp -r /etc/.* ~/backup-etc && sudo chown daniels:daniels -R ~/backup-etc/ && borg create -v --progress --stats --exclude-from ~/.config/borg/exclude /media/daniels/Backup::$(date +%F-%R) ~/; sudo rm -rf ~/backup-etc"; - }; - history = { size = 10000; save = 10000; diff --git a/home/services/batteryicon.nix b/home/services/batteryicon.nix index 5cfb30e..efaf66f 100644 --- a/home/services/batteryicon.nix +++ b/home/services/batteryicon.nix @@ -12,7 +12,7 @@ Install = { WantedBy = [ - "default.target" + "hm-graphical-session.target" ]; }; } diff --git a/home/windowManager/i3.nix b/home/windowManager/i3.nix index 35e3f60..4bc8e6b 100644 --- a/home/windowManager/i3.nix +++ b/home/windowManager/i3.nix @@ -183,12 +183,6 @@ in { command = "xinput --set-prop 'DELL07E6:00 06CB:76AF Touchpad' 'libinput Tapping Enabled' 1"; notification = false; } - { - # Use CAPS LOCK as ctrl - command = "setxkbmap -option ctrl:nocaps; setxkbmap -option compose:ralt"; - notification = false; - always = true; - } { command = "xsetroot -solid \"#2E3436\""; notification = false; @@ -379,8 +373,8 @@ in { displays = { "a" = "exec xrandr --auto --output eDP1 --scale 1x1 --mode 1920x1080 && xbacklight -set 10;"; "e" = "exec xrandr --auto --output eDP1 --off"; - "h" = "exec xrandr --output eDP1 --off --output DP2-1 --scale 1x1 --mode 2560x1440 && setxkbmap -option ctrl:nocaps && setxkbmap -option compose:ralt && setxkbmap -option numpad:mac"; - "v" = "exec xrandr --auto --output DP2-1 --primary --scale 1x1 --mode 2560x1440 --output eDP1 --mode 1920x1080 --left-of DP2-1 && setxkbmap -option ctrl:nocaps && setxkbmap -option compose:ralt && setxkbmap -option numpad:mac"; + "h" = "exec xrandr --output eDP1 --off --output DP2-1 --scale 1x1 --mode 2560x1440"; + "v" = "exec xrandr --auto --output DP2-1 --primary --scale 1x1 --mode 2560x1440 --output eDP1 --mode 1920x1080 --left-of DP2-1"; "r" = "exec xrandr --output DP2-1 --primary --mode 1920x1080 --output eDP1 --mode 1920x1080 --left-of DP2-1 && xbacklight -set 100;"; # Mirror diff --git a/home/xsession.nix b/home/xsession.nix new file mode 100644 index 0000000..d409719 --- /dev/null +++ b/home/xsession.nix @@ -0,0 +1,11 @@ +{ config, pkgs }: + +{ + enable = true; + + numlock.enable = true; + + windowManager.i3 = import ./windowManager/i3.nix { + inherit config pkgs; + }; +} diff --git a/readme.md b/readme.md index 784523f..bc6b265 100644 --- a/readme.md +++ b/readme.md @@ -84,6 +84,23 @@ List of manual needed changes for various reasons. cd ~/.local/share && ln -s ~/.nix-profile/share/applications +* Allow gdm3 to use xsessions as login. + Add the following content as `/usr/share/xsessions/xsession.desktop`: + + [Desktop Entry] + Name=XSession + Comment=This session uses the custom xsession file + Exec=/etc/X11/Xsession + Type=Application + X-DesktopNames=GNOME-Flashback;GNOME; + X-Ubuntu-Gettext-Domain=gnome-flashback + + This is used by gdm3 (installed via ubuntu host) to allow logging in via + xsession which will pick up all the settings generated by home-manager. + + Do not forget to call `sudo desktop-file-install xsession.desktop` to make + system aware of the file. + Todos -----