diff --git a/configuration.nix b/configuration.nix index d908620..3776813 100644 --- a/configuration.nix +++ b/configuration.nix @@ -47,18 +47,6 @@ manual.manpages.enable = false; }; - hardware = { - pulseaudio = { - enable = true; - - # NixOS allows either a lightweight build (default) or full build of PulseAudio to be installed. - # Only the full build has Bluetooth support, so it must be selected here. - package = pkgs.pulseaudioFull; - - # Extra codecs - extraModules = [ pkgs.pulseaudio-modules-bt ]; - }; - }; system.stateVersion = "21.11"; diff --git a/dotfiles/fish/config.fish b/dotfiles/fish/config.fish index 570ca9f..464f2dd 100644 --- a/dotfiles/fish/config.fish +++ b/dotfiles/fish/config.fish @@ -11,5 +11,6 @@ function fish_user_key_bindings # Use jj to exit insert mode bind -e -M insert \e # unbinds esc - bind -M insert -m default jj 'commandline -f repaint' + bind -M insert -m default jk 'commandline -f repaint' + bind -M insert -m default kj 'commandline -f repaint' end diff --git a/dotfiles/kmonad/keymap.kbd b/dotfiles/kmonad/keymap.kbd index 560460c..9c693da 100644 --- a/dotfiles/kmonad/keymap.kbd +++ b/dotfiles/kmonad/keymap.kbd @@ -1,10 +1,11 @@ (defcfg ;; For Linux - input (device-file "/dev/input/by-path/platform-i8042-serio-0-event-kbd") + ;; input (device-file "$DEVICE") ;; gets dynamically replaced by nix + input (device-file "/dev/input/by-path/platform-i8042-serio-0-event-kbd") output (uinput-sink "My KMonad output" ;; To understand the importance of the following line, see the section on ;; Compose-key sequences at the near-bottom of this file. - "/run/current-system/sw/bin/sleep 1 && /run/current-system/sw/bin/setxkbmap -option compose:ralt") + "/run/current-system/sw/bin/sleep 1 && /run/current-system/sw/bin/setxkbmap" -option compose:ralt") cmp-seq ralt ;; Set the compose key to `RightAlt' cmp-seq-delay 5 ;; 5ms delay between each compose-key sequence press @@ -27,9 +28,6 @@ |# (defalias - mth (layer-toggle math) - Mth (layer-toggle capital-math) - ga #(ralt a h) ;; alpha gb #(ralt b h) ;; beta gg #(ralt g h) ;; gamma @@ -60,14 +58,30 @@ ex #(ralt l e) ;; ∃ lar #(ralt < -) ;; ← rar #(ralt - >) ;; → + and #(ralt l c) ;; and symbol + or #(ralt l d) ;; or symbol + eq #(ralt e q) ;; Equivalence alp #(ralt f \( ) ;; angled left parenthesis arp #(ralt f \) ) ;; angled right parenthesis shrugFace #(ralt l s h r) ;; shrug face topBar #(ralt t -) ;; ¯ +) +;; layers +(defalias + mth (layer-toggle math) + Mth (layer-toggle capital-math) + mathExtra (layer-toggle math-extra) +) + +;; more "special" stuff +(defalias shr #(@topBar \ \_ \_ \( @shrugFace \) \_ / @topBar) ;; ¯\_(ツ)_/¯ + + ml (tap-hold-next-release 200 @gl @mathExtra) + mll l ) (defsrc @@ -92,8 +106,17 @@ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @ex _ _ _ _ _ @alp @arp @neg _ _ _ @shr @go @ge _ @gt _ @gu _ @go @gp _ _ _ - _ @ga @gs _ _ @gg @gth @gps @gph @gl _ _ _ + _ @ga @gs _ _ @gg @gth @gps @gph @ml _ _ _ @Mth _ @gx _ @fal @gb _ @gm @lar @rar _ _ + _ _ _ _ @mathExtra _ _ +) + +(deflayer math-extra + _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ @eq _ _ _ _ _ @or _ _ _ _ + _ @and _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ) @@ -106,4 +129,3 @@ _ _ _ _ _ _ _ ) - diff --git a/dotfiles/kmonad/xcompose b/dotfiles/kmonad/xcompose index ad9e2d7..e2b5c84 100644 --- a/dotfiles/kmonad/xcompose +++ b/dotfiles/kmonad/xcompose @@ -38,3 +38,8 @@ : "⟨" U0357 # FANCY LEFT PAREN : "⟩" U0358 # FANCY RIGHT PAREN + : "⟷" U0359 # LOGICAL EQUIVALENCE + : "∧" U0360 # LOGICAL CONJUNCTION + : "∨" U0361 # LOGICAL DISJUNCTION + + diff --git a/dotfiles/neovim/README.md b/dotfiles/neovim/README.md index f20d791..dc807c7 100644 --- a/dotfiles/neovim/README.md +++ b/dotfiles/neovim/README.md @@ -11,7 +11,7 @@ Table of my own keybinds. Here as documentation for myself. I am yet to include | ---------------- | ------------------------------------------- | ------------------ | | vv | Create vertical split | | | \\ | Save | | -| jj | Exit insert mode | | +| _jk_ | Exit insert mode | | | _\k_ | Insert digraph | | | _\a_ | Swap last 2 used buffers | | | C-n | Open tree | nvim-tree | diff --git a/dotfiles/neovim/lua/my/keymaps.lua b/dotfiles/neovim/lua/my/keymaps.lua index 5a0b41c..bfedaa2 100644 --- a/dotfiles/neovim/lua/my/keymaps.lua +++ b/dotfiles/neovim/lua/my/keymaps.lua @@ -21,16 +21,15 @@ function M.mapSilent(mode, lhs, rhs, opts) end function M.setup() - M.map("i", "jj", "") -- Remap Esc to jj - M.map("n", "", ":w") -- Double space to sace M.map("n", "vv", "v") -- Create vertical split if arpeggio ~= nil then -- Create chords + arpeggio.chord("n", "jl", ":w") -- Double space to sace + arpeggio.chord("i", "jk", "") -- Remap Esc to jk arpeggio.chord("i", "k", "") -- Rebind digraph insertion to leader+k arpeggio.chord("inv", "a", "") -- Rebind switching to the last pane using leader+a end - end return M diff --git a/dotfiles/neovim/lua/my/plugins/lh-brackets.lua b/dotfiles/neovim/lua/my/plugins/lh-brackets.lua index 4deaa3e..85c3cfb 100644 --- a/dotfiles/neovim/lua/my/plugins/lh-brackets.lua +++ b/dotfiles/neovim/lua/my/plugins/lh-brackets.lua @@ -35,8 +35,8 @@ function M.setup() arpeggio.chord("inv", "mo", 'MarkersJumpOutside') for key, brackets in pairs(extraBrackets) do - for _, v in ipairs(brackets) do - A.augroup('custom-brackets' .. key, function() + A.augroup('custom-brackets' .. key, function() + for _, v in ipairs(brackets) do local action = M.createBracketCommand(v[1], v[2], 0, v[3] or "") local glob = '*.' .. key @@ -46,8 +46,8 @@ function M.setup() end A.autocmd('BufEnter', glob, action) - end) - end + end + end) end end diff --git a/modules/applications/default.nix b/modules/applications/default.nix index 29f0f35..4f20e20 100644 --- a/modules/applications/default.nix +++ b/modules/applications/default.nix @@ -19,6 +19,7 @@ ./neovim.nix ./tmux.nix ./kmonad.nix + ./direnv.nix ]; } diff --git a/modules/applications/direnv.nix b/modules/applications/direnv.nix new file mode 100644 index 0000000..755155c --- /dev/null +++ b/modules/applications/direnv.nix @@ -0,0 +1,10 @@ +# https://github.com/nix-community/nix-direnv +{ pkgs, ... }: { + home-manager.users.adrielus = { + programs.direnv.enable = true; + programs.direnv.nix-direnv.enable = true; + + # optional for nix flakes support in home-manager 21.11, not required in home-manager unstable or 22.05 + programs.direnv.nix-direnv.enableFlakes = true; + }; +} diff --git a/modules/applications/kmonad.nix b/modules/applications/kmonad.nix index 1f159f9..5da3c98 100644 --- a/modules/applications/kmonad.nix +++ b/modules/applications/kmonad.nix @@ -1,12 +1,33 @@ -{ pkgs, ... }: -let kmonadRoot = ../../dotfiles/kmonad; in +{ pkgs, lib, ... }: +let + kmonadRoot = ../../dotfiles/kmonad; + kmonadInstances = [{ + config = kmonadRoot + "/keymap.kbd"; + inputDevices = [ + "/dev/input/by-path/platform-i8042-serio-0-event-kbd" + ]; + }]; + + createKmonadInstances = ({ config, inputDevices }: + let + configContent = builtins.readFile config; + in + lib.lists.map + (device: + "${pkgs.writeTextDir "configs/kmonad.kbd" (builtins.replaceStrings [ "$DEVICE" ] [ device ] configContent)}/kmonad.kbd" + ) + inputDevices + + ); +in { users.extraUsers.adrielus.extraGroups = [ "input" "uinput" ]; services = { kmonad = { enable = true; - configfiles = [ (kmonadRoot + "/keymap.kbd") ]; + # configfiles = lib.lists.concatMap createKmonadInstances kmonadInstances; + configfiles = lib.lists.map ({ config, ... }: config) kmonadInstances; }; xserver = { diff --git a/modules/applications/neovim.nix b/modules/applications/neovim.nix index 4202897..ed5df2f 100644 --- a/modules/applications/neovim.nix +++ b/modules/applications/neovim.nix @@ -64,6 +64,7 @@ in purescript-vim # purescript syntax highlighting nvim-comment # allows toggling line-comments nvim-treesitter # use treesitter for syntax highlighting + nvim-treesitter-textobjects # the lean plugin told me to add this startup-nvim # splash screen vim-devicons # nice looking icons nvim-web-devicons # fork of vim-devicons? diff --git a/modules/applications/shells/fish.nix b/modules/applications/shells/fish.nix index a70f396..4bf072b 100644 --- a/modules/applications/shells/fish.nix +++ b/modules/applications/shells/fish.nix @@ -7,6 +7,7 @@ let themePackage = builtins.getAttr theme pkgs.myFishPlugins.themes; # Dynamically pick the theme path in { + users.defaultUserShell = pkgs.fish; home-manager.users.adrielus = { # Source every file in the theme xdg.configFile."fish/conf.d/plugin-${theme}.fish".text = lib.mkAfter '' diff --git a/modules/bluetooth.nix b/modules/bluetooth.nix new file mode 100644 index 0000000..a5866af --- /dev/null +++ b/modules/bluetooth.nix @@ -0,0 +1,48 @@ +# Taken from https://nixos.wiki/wiki/Bluetooth +{ pkgs, ... }: { + hardware.bluetooth = { + enable = true; + settings = { + General = { + Enable = "Source,Sink,Media,Socket"; + }; + }; + }; + + services.blueman.enable = true; + + # TODO: investigate why this does not work + # systemd.user.services.mpris-proxy = { + # Unit.Description = "Mpris proxy"; + # Unit.After = [ "network.target" "sound.target" ]; + # Service.ExecStart = "${pkgs.bluez}/bin/mpris-proxy"; + # Install.WantedBy = [ "default.target" ]; + # }; + + hardware = { + pulseaudio = { + enable = true; + + # NixOS allows either a lightweight build (default) or full build of PulseAudio to be installed. + # Only the full build has Bluetooth support, so it must be selected here. + package = pkgs.pulseaudioFull; + + # Extra codecs + extraModules = [ pkgs.pulseaudio-modules-bt ]; + + configFile = pkgs.writeText "default.pa" '' + load-module module-bluetooth-policy + load-module module-bluetooth-discover + ## module fails to load with + ## module-bluez5-device.c: Failed to get device path from module arguments + ## module.c: Failed to load module "module-bluez5-device" (argument: ""): initialization failed. + # load-module module-bluez5-device + # load-module module-bluez5-discover + ''; + + extraConfig = '' + load-module module-switch-on-connect + ''; + }; + }; +} diff --git a/modules/default.nix b/modules/default.nix index 96e6560..18407f1 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -9,5 +9,6 @@ ./xserver.nix ./users.nix ./nix.nix + ./bluetooth.nix ]; }