From 2723186f49b1d622eb918956d7a258a6f7228620 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 19 Apr 2021 14:29:38 +0200 Subject: [PATCH 01/12] home: basic i3 setup --- home/default.nix | 4 +++ home/x/default.nix | 10 ++++++ home/x/i3.nix | 77 ++++++++++++++++++++++++++++++++++++++++ hosts/boreal/default.nix | 2 ++ hosts/boreal/home.nix | 7 ++++ 5 files changed, 100 insertions(+) create mode 100644 home/x/default.nix create mode 100644 home/x/i3.nix create mode 100644 hosts/boreal/home.nix diff --git a/home/default.nix b/home/default.nix index 5a16987..1cb28cb 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,5 +1,9 @@ { ... }: { + imports = [ + ./x + ]; + home.stateVersion = "20.09"; home.username = "alarsyo"; diff --git a/home/x/default.nix b/home/x/default.nix new file mode 100644 index 0000000..382e0e5 --- /dev/null +++ b/home/x/default.nix @@ -0,0 +1,10 @@ +{ config, lib, pkgs, ... }: +{ + imports = [ + ./i3.nix + ]; + + options.my.home.x = with lib; { + enable = mkEnableOption "X server configuration"; + }; +} diff --git a/home/x/i3.nix b/home/x/i3.nix new file mode 100644 index 0000000..307b7b8 --- /dev/null +++ b/home/x/i3.nix @@ -0,0 +1,77 @@ +{ config, lib, pkgs, ... }: +let + isEnabled = config.my.home.x.enable; + + myTerminal = + # FIXME: fix when terminal is setup in home + # if config.my.home.terminal.program != null + if true + then "alacritty" + else "i3-sensible-terminal"; + + alt = "Mod1"; # `Alt` key + modifier = "Mod4"; # `Super` key + + logoutMode = "[L]ogout, [S]uspend, [P]oweroff, [R]eboot"; +in +{ + config = lib.mkIf isEnabled { + # FIXME: enable flameshot when added + # my.home = {}; + + xsession.windowManager.i3 = { + enable = true; + + config = { + inherit modifier; + + bars = + [ + { + statusCommand = "i3status"; + position = "top"; + } + ]; + + focus = { + followMouse = true; + mouseWarping = true; + }; + + fonts = [ + "DejaVu Sans Mono 8" + ]; + + keybindings = lib.mkOptionDefault { + "${modifier}+Shift+e" = ''mode "${logoutMode}"''; + }; + + modes = + let + makeModeBindings = attrs: attrs // { + "Escape" = "mode default"; + "Return" = "mode default"; + }; + in + { + ${logoutMode} = makeModeBindings { + "l" = "exec --no-startup-id i3-msg exit, mode default"; + "s" = "exec --no-startup-id systemctl suspend, mode default"; + "p" = "exec --no-startup-id systemctl poweroff, mode default"; + "r" = "exec --no-startup-id systemctl reboot, mode default"; + }; + }; + + startup = [ + # FIXME: make it conditional on "nvidia" being part of video drivers + { + command = "nvidia-settings -a '[gpu:0]/GPUPowerMizerMode=1'"; + notification = false; + } + ]; + + terminal = myTerminal; + }; + }; + }; +} diff --git a/hosts/boreal/default.nix b/hosts/boreal/default.nix index 71615c6..347132a 100644 --- a/hosts/boreal/default.nix +++ b/hosts/boreal/default.nix @@ -10,6 +10,8 @@ in imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix + + ./home.nix ]; # Use the systemd-boot EFI boot loader. diff --git a/hosts/boreal/home.nix b/hosts/boreal/home.nix new file mode 100644 index 0000000..fe3fea0 --- /dev/null +++ b/hosts/boreal/home.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + home-manager.users.alarsyo = { + # Keyboard settings & i3 settings + my.home.x.enable = true; + }; +} From 75026b906ec8f0ab203f280347b89481c0079732 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 19 Apr 2021 14:36:52 +0200 Subject: [PATCH 02/12] home: i3: shortcut to launch emacs --- home/x/i3.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/home/x/i3.nix b/home/x/i3.nix index 307b7b8..e9504bc 100644 --- a/home/x/i3.nix +++ b/home/x/i3.nix @@ -44,6 +44,7 @@ in keybindings = lib.mkOptionDefault { "${modifier}+Shift+e" = ''mode "${logoutMode}"''; + "${modifier}+i" = "exec ${pkgs.emacsPgtkGcc}/bin/emacsclient -c"; }; modes = From 37882e8d102652091ebbc751da9c551ea1906a13 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 19 Apr 2021 14:58:52 +0200 Subject: [PATCH 03/12] home: x: setup i3status-rust --- home/x/default.nix | 1 + home/x/i3.nix | 43 ++++++++++++++++++++++++++++++++++++++++++- home/x/i3bar.nix | 22 ++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 home/x/i3bar.nix diff --git a/home/x/default.nix b/home/x/default.nix index 382e0e5..ca92c09 100644 --- a/home/x/default.nix +++ b/home/x/default.nix @@ -2,6 +2,7 @@ { imports = [ ./i3.nix + ./i3bar.nix ]; options.my.home.x = with lib; { diff --git a/home/x/i3.nix b/home/x/i3.nix index e9504bc..555a887 100644 --- a/home/x/i3.nix +++ b/home/x/i3.nix @@ -13,6 +13,17 @@ let modifier = "Mod4"; # `Super` key logoutMode = "[L]ogout, [S]uspend, [P]oweroff, [R]eboot"; + + # colors + colorBg = "#282828"; + colorRed = "#cc241d"; + colorGreen = "#98971a"; + colorYellow = "#d79921"; + colorBlue = "#458588"; + colorPurple = "#b16286"; + colorAqua = "#689d68"; + colorGray = "#a89984"; + colorDarkGray = "#1d2021"; in { config = lib.mkIf isEnabled { @@ -26,10 +37,40 @@ in inherit modifier; bars = + let + barConfigPath = + config.xdg.configFile."i3status-rust/config-top.toml".target; + in [ { - statusCommand = "i3status"; + statusCommand = "i3status-rs ${barConfigPath}"; position = "top"; + + colors = { + background = colorBg; + statusline = colorYellow; + + focusedWorkspace = { + border = colorAqua; + background = colorAqua; + text = colorDarkGray; + }; + inactiveWorkspace = { + border = colorDarkGray; + background = colorDarkGray; + text = colorYellow; + }; + activeWorkspace = { + border = colorAqua; + background = colorDarkGray; + text = colorYellow; + }; + urgentWorkspace = { + border = colorRed; + background = colorRed; + text = colorBg; + }; + }; } ]; diff --git a/home/x/i3bar.nix b/home/x/i3bar.nix new file mode 100644 index 0000000..644a06b --- /dev/null +++ b/home/x/i3bar.nix @@ -0,0 +1,22 @@ +{ config, lib, pkgs, ... }: +let + isEnabled = config.my.home.x.enable; +in +{ + config = lib.mkIf isEnabled { + home.packages = with pkgs; [ + alsaUtils # Used by `sound` block + lm_sensors # Used by `temperature` block + ]; + + programs.i3status-rust = { + enable = true; + + bars = { + top = { + theme = "gruvbox-light"; + }; + }; + }; + }; +} From 806f0bd4fb222d49bba498d6194e5e4161d7c2e6 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 19 Apr 2021 15:04:52 +0200 Subject: [PATCH 04/12] flake: make home-manager chatty --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index edb5671..c7f0e9f 100644 --- a/flake.nix +++ b/flake.nix @@ -67,6 +67,7 @@ home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.users.alarsyo = import ./home; + home-manager.verbose = true; } { From 1fa2bee372c677da7fecc04763418f44cb73bb42 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 19 Apr 2021 15:05:52 +0200 Subject: [PATCH 05/12] home: x: don't use absolute path for commands --- home/x/i3.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/x/i3.nix b/home/x/i3.nix index 555a887..2c47281 100644 --- a/home/x/i3.nix +++ b/home/x/i3.nix @@ -85,7 +85,7 @@ in keybindings = lib.mkOptionDefault { "${modifier}+Shift+e" = ''mode "${logoutMode}"''; - "${modifier}+i" = "exec ${pkgs.emacsPgtkGcc}/bin/emacsclient -c"; + "${modifier}+i" = "exec emacsclient -c"; }; modes = From 244d2111afc955bb2f368d3c6604bb13b0e10464 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 19 Apr 2021 15:42:27 +0200 Subject: [PATCH 06/12] home: move emacs service to home config --- home/default.nix | 1 + home/emacs.nix | 19 +++++++++++++++++++ hosts/boreal/default.nix | 5 ----- hosts/boreal/home.nix | 1 + 4 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 home/emacs.nix diff --git a/home/default.nix b/home/default.nix index 1cb28cb..c9a4a7e 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,6 +1,7 @@ { ... }: { imports = [ + ./emacs.nix ./x ]; diff --git a/home/emacs.nix b/home/emacs.nix new file mode 100644 index 0000000..7229282 --- /dev/null +++ b/home/emacs.nix @@ -0,0 +1,19 @@ +{ config, lib, pkgs, ... }: +{ + options.my.home.emacs = with lib; { + enable = mkEnableOption "Emacs daemon configuration"; + }; + + config = lib.mkIf config.my.home.emacs.enable { + services.emacs = { + enable = true; + # generate emacsclient desktop file + client.enable = true; + }; + + programs.emacs = { + enable = true; + package = pkgs.emacsPgtkGcc; + }; + }; +} diff --git a/hosts/boreal/default.nix b/hosts/boreal/default.nix index 347132a..f2b13f4 100644 --- a/hosts/boreal/default.nix +++ b/hosts/boreal/default.nix @@ -71,11 +71,6 @@ in layout = "fr"; xkbVariant = "us"; }; - - emacs = { - enable = true; - package = pkgs.emacsPgtkGcc; - }; }; sound.enable = true; diff --git a/hosts/boreal/home.nix b/hosts/boreal/home.nix index fe3fea0..46f1750 100644 --- a/hosts/boreal/home.nix +++ b/hosts/boreal/home.nix @@ -3,5 +3,6 @@ home-manager.users.alarsyo = { # Keyboard settings & i3 settings my.home.x.enable = true; + my.home.emacs.enable = true; }; } From f64b7b18d736dd46911b89b94f86be15b5325a90 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 19 Apr 2021 15:51:50 +0200 Subject: [PATCH 07/12] home: setup flameshot --- base/gui-programs.nix | 1 - home/default.nix | 1 + home/flameshot.nix | 13 +++++++++++++ home/x/i3.nix | 5 +++-- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 home/flameshot.nix diff --git a/base/gui-programs.nix b/base/gui-programs.nix index 62b386c..8d73749 100644 --- a/base/gui-programs.nix +++ b/base/gui-programs.nix @@ -6,7 +6,6 @@ emacsPgtkGcc feh firefox - flameshot pavucontrol slack spotify diff --git a/home/default.nix b/home/default.nix index c9a4a7e..abf442e 100644 --- a/home/default.nix +++ b/home/default.nix @@ -2,6 +2,7 @@ { imports = [ ./emacs.nix + ./flameshot.nix ./x ]; diff --git a/home/flameshot.nix b/home/flameshot.nix new file mode 100644 index 0000000..359fc8c --- /dev/null +++ b/home/flameshot.nix @@ -0,0 +1,13 @@ +{ config, lib, ... }: +let + cfg = config.my.home.flameshot; +in +{ + options.my.home.flameshot = with lib; { + enable = mkEnableOption "flameshot autolaunch"; + }; + + config.services.flameshot = lib.mkIf cfg.enable { + enable = true; + }; +} diff --git a/home/x/i3.nix b/home/x/i3.nix index 2c47281..9a76351 100644 --- a/home/x/i3.nix +++ b/home/x/i3.nix @@ -27,8 +27,9 @@ let in { config = lib.mkIf isEnabled { - # FIXME: enable flameshot when added - # my.home = {}; + my.home = { + flameshot.enable = true; + }; xsession.windowManager.i3 = { enable = true; From d72c0d592694a225c480ce76ce588fc4c059793d Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 19 Apr 2021 16:07:38 +0200 Subject: [PATCH 08/12] home: emacs: move package dependencies in homeconf --- base/gui-programs.nix | 9 ++------- home/emacs.nix | 10 ++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/base/gui-programs.nix b/base/gui-programs.nix index 8d73749..f98fedf 100644 --- a/base/gui-programs.nix +++ b/base/gui-programs.nix @@ -3,22 +3,17 @@ environment.systemPackages = with pkgs; [ alacritty discord - emacsPgtkGcc feh firefox pavucontrol slack spotify - sqlite # needed for org-roam zathura ]; - fonts.fonts = with pkgs; [ - input-fonts - emacs-all-the-icons-fonts - ]; - networking.networkmanager.enable = true; programs.nm-applet.enable = true; + + # NOTE: needed for home emacs configuration nixpkgs.config.input-fonts.acceptLicense = true; } diff --git a/home/emacs.nix b/home/emacs.nix index 7229282..5b1808e 100644 --- a/home/emacs.nix +++ b/home/emacs.nix @@ -5,6 +5,16 @@ }; config = lib.mkIf config.my.home.emacs.enable { + home.packages = with pkgs; [ + sqlite # needed by org-roam + + # fonts used by my config + input-fonts + emacs-all-the-icons-fonts + ]; + # make sure above fonts are discoverable + fonts.fontconfig.enable = true; + services.emacs = { enable = true; # generate emacsclient desktop file From 4168da868d1ed385070df82ce8c2b09f9320269c Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 19 Apr 2021 16:28:45 +0200 Subject: [PATCH 09/12] home: i3: make status bar font bigger --- home/x/i3.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/home/x/i3.nix b/home/x/i3.nix index 9a76351..23121bf 100644 --- a/home/x/i3.nix +++ b/home/x/i3.nix @@ -46,6 +46,7 @@ in { statusCommand = "i3status-rs ${barConfigPath}"; position = "top"; + fonts = [ "DejaVu Sans Mono 9" ]; colors = { background = colorBg; From 0cb51a65f6146bd0914884e14d53f657f839d301 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 19 Apr 2021 18:59:24 +0200 Subject: [PATCH 10/12] home: tmux: basic setup --- base/programs.nix | 4 ---- home/default.nix | 1 + home/tmux.nix | 14 ++++++++++++++ hosts/boreal/home.nix | 1 + 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 home/tmux.nix diff --git a/base/programs.nix b/base/programs.nix index 0770768..2de78f9 100644 --- a/base/programs.nix +++ b/base/programs.nix @@ -14,10 +14,6 @@ AddKeysToAgent yes ''; }; - tmux = { - enable = true; - baseIndex = 1; - }; }; environment.systemPackages = with pkgs; [ diff --git a/home/default.nix b/home/default.nix index abf442e..0da2e12 100644 --- a/home/default.nix +++ b/home/default.nix @@ -3,6 +3,7 @@ imports = [ ./emacs.nix ./flameshot.nix + ./tmux.nix ./x ]; diff --git a/home/tmux.nix b/home/tmux.nix new file mode 100644 index 0000000..8325fa9 --- /dev/null +++ b/home/tmux.nix @@ -0,0 +1,14 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.my.home.tmux; +in +{ + options.my.home.tmux = with lib; { + enable = mkEnableOption "tmux dotfiles"; + }; + + config.programs.tmux = lib.mkIf cfg.enable { + enable = true; + baseIndex = 1; + }; +} diff --git a/hosts/boreal/home.nix b/hosts/boreal/home.nix index 46f1750..c39bf22 100644 --- a/hosts/boreal/home.nix +++ b/hosts/boreal/home.nix @@ -4,5 +4,6 @@ # Keyboard settings & i3 settings my.home.x.enable = true; my.home.emacs.enable = true; + my.home.tmux.enable = true; }; } From 7a20e72e863e110812456be0a476b8f78afe183b Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 19 Apr 2021 19:01:09 +0200 Subject: [PATCH 11/12] boreal: disable wireguard config for now --- hosts/boreal/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts/boreal/default.nix b/hosts/boreal/default.nix index f2b13f4..bd66dcb 100644 --- a/hosts/boreal/default.nix +++ b/hosts/boreal/default.nix @@ -40,7 +40,7 @@ in # List services that you want to enable: my.services = { wireguard = { - enable = true; + enable = false; iface = "wg"; port = 51820; From 1ccbe85361909329fd589fe9a5b7bdd6721f68b6 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 19 Apr 2021 17:09:16 +0200 Subject: [PATCH 12/12] packages: package tmux-thumbs --- base/programs.nix | 1 + flake.nix | 4 ++++ home/tmux.nix | 1 + packages/default.nix | 4 ++++ packages/fix.patch | 41 ++++++++++++++++++++++++++++++++++++++++ packages/tmux-thumbs.nix | 38 +++++++++++++++++++++++++++++++++++++ 6 files changed, 89 insertions(+) create mode 100644 packages/default.nix create mode 100644 packages/fix.patch create mode 100644 packages/tmux-thumbs.nix diff --git a/base/programs.nix b/base/programs.nix index 2de78f9..57d7f8b 100644 --- a/base/programs.nix +++ b/base/programs.nix @@ -22,6 +22,7 @@ fd ripgrep tree + packages.tmux-thumbs wget # development diff --git a/flake.nix b/flake.nix index c7f0e9f..fb18bcf 100644 --- a/flake.nix +++ b/flake.nix @@ -74,6 +74,10 @@ nixpkgs.overlays = [ emacs-overlay.overlay + (self: super: { + packages = import ./packages { pkgs = super; }; + }) + # uncomment this to build everything from scratch, fun but takes a # while # diff --git a/home/tmux.nix b/home/tmux.nix index 8325fa9..24402eb 100644 --- a/home/tmux.nix +++ b/home/tmux.nix @@ -10,5 +10,6 @@ in config.programs.tmux = lib.mkIf cfg.enable { enable = true; baseIndex = 1; + plugins = with pkgs; [ packages.tmux-thumbs ]; }; } diff --git a/packages/default.nix b/packages/default.nix new file mode 100644 index 0000000..befb57c --- /dev/null +++ b/packages/default.nix @@ -0,0 +1,4 @@ +{ pkgs }: +{ + tmux-thumbs = pkgs.callPackage ./tmux-thumbs.nix {}; +} diff --git a/packages/fix.patch b/packages/fix.patch new file mode 100644 index 0000000..38295c4 --- /dev/null +++ b/packages/fix.patch @@ -0,0 +1,41 @@ +diff --git a/src/swapper.rs b/src/swapper.rs +index aff33e1..cb5f21a 100644 +--- a/src/swapper.rs ++++ b/src/swapper.rs +@@ -210,11 +210,10 @@ impl<'a> Swapper<'a> { + }; + + let pane_command = format!( +- "tmux capture-pane -t {active_pane_id} -p{scroll_params} | tail -n {height} | {dir}/target/release/thumbs -f '%U:%H' -t {tmp} {args}; tmux swap-pane -t {active_pane_id}; {zoom_command} tmux wait-for -S {signal}", ++ "tmux capture-pane -t {active_pane_id} -p{scroll_params} | tail -n {height} | @@replace-me@@/thumbs -f '%U:%H' -t {tmp} {args}; tmux swap-pane -t {active_pane_id}; {zoom_command} tmux wait-for -S {signal}", + active_pane_id = active_pane_id, + scroll_params = scroll_params, + height = self.active_pane_height.unwrap_or(i32::MAX), +- dir = self.dir, + tmp = TMP_FILE, + args = args.join(" "), + zoom_command = zoom_command, +diff --git a/tmux-thumbs.sh b/tmux-thumbs.sh +index 92d5625..c6300c7 100755 +--- a/tmux-thumbs.sh ++++ b/tmux-thumbs.sh +@@ -35,4 +35,4 @@ add-param command string + add-param upcase-command string + add-param osc52 boolean + +-"${CURRENT_DIR}/target/release/tmux-thumbs" "${PARAMS[@]}" || true ++@@replace-me@@ "${PARAMS[@]}" || true +diff --git a/tmux-thumbs.tmux b/tmux-thumbs.tmux +index 4fc9355..87c5346 100755 +--- a/tmux-thumbs.tmux ++++ b/tmux-thumbs.tmux +@@ -8,9 +8,3 @@ THUMBS_KEY="$(tmux show-option -gqv @thumbs-key)" + THUMBS_KEY=${THUMBS_KEY:-$DEFAULT_THUMBS_KEY} + + tmux bind-key "${THUMBS_KEY}" run-shell -b "${CURRENT_DIR}/tmux-thumbs.sh" +- +-BINARY="${CURRENT_DIR}/target/release/thumbs" +- +-if [ ! -f "$BINARY" ]; then +- tmux split-window "cd ${CURRENT_DIR} && cargo build --release --target-dir=target && echo 'Press any key to continue...' && read -k1" +-fi diff --git a/packages/tmux-thumbs.nix b/packages/tmux-thumbs.nix new file mode 100644 index 0000000..cd69486 --- /dev/null +++ b/packages/tmux-thumbs.nix @@ -0,0 +1,38 @@ +{ pkgs, lib, rustPlatform, fetchFromGitHub }: +let + pname = "tmux-thumbs"; + version = "0.5.1"; + tmux-thumbs-binary = rustPlatform.buildRustPackage { + pname = pname; + version = version; + + src = fetchFromGitHub { + owner = "fcsonline"; + repo = pname; + rev = version; + sha256 = "sha256-rU+tsrYJxoqF8Odh2ucvNekc+fLnSY6kFoVFUjqaTFE="; + }; + + cargoSha256 = "sha256-/F9tftRLqC6dk7lX41C8RUMqlrgzc0nkunc0rue5zuM="; + + patches = [ ./fix.patch ]; + postPatch = '' + substituteInPlace src/swapper.rs --replace '@@replace-me@@' '$out/bin/thumbs' + ''; + meta = {}; + }; +in pkgs.tmuxPlugins.mkTmuxPlugin { + pluginName = pname; + version = version; + rtpFilePath = "tmux-thumbs.tmux"; + src = fetchFromGitHub { + owner = "fcsonline"; + repo = pname; + rev = version; + sha256 = "sha256-rU+tsrYJxoqF8Odh2ucvNekc+fLnSY6kFoVFUjqaTFE="; + }; + patches = [ ./fix.patch ]; + postInstall = '' + substituteInPlace $target/tmux-thumbs.sh --replace '@@replace-me@@' '${tmux-thumbs-binary}/bin/tmux-thumbs' + ''; +}