diff --git a/flake.nix b/flake.nix index 4813367..a5c05d9 100644 --- a/flake.nix +++ b/flake.nix @@ -8,9 +8,10 @@ ... } @ inputs: let mods = import ./modules; + cLib = import ./lib {inherit (nixpkgs) lib;}; mkLinuxSystem = mod: nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs;}; + specialArgs = {inherit inputs cLib;}; modules = [ inputs.home-manager.nixosModules.home-manager diff --git a/home/c/default.nix b/home/c/default.nix index d7e7aa2..3f8bd92 100644 --- a/home/c/default.nix +++ b/home/c/default.nix @@ -19,6 +19,7 @@ }; home.packages = with pkgs; [ + # TODO: sort this out gnome.adwaita-icon-theme networkmanagerapplet libsecret diff --git a/home/c/programs/fish/default.nix b/home/c/programs/fish/default.nix index 4b3c330..4268b18 100644 --- a/home/c/programs/fish/default.nix +++ b/home/c/programs/fish/default.nix @@ -1,8 +1,13 @@ -{pkgs, ...}: let +{ + pkgs, + cLib, + ... +}: let mkFishPlug = pkg: { name = pkg.pname; inherit (pkg) src; }; + tmux = cLib.getProgFor pkgs "tmux"; in { programs.fish = { enable = true; @@ -12,14 +17,15 @@ in { trap __trap_exit_tmux EXIT ''; + # TODO: dont use this directly shellAliases = {v = "nvim";}; functions = { __trap_exit_tmux = { body = '' - test (tmux list-windows | wc -l) = 1 || exit - test (tmux list-panes | wc -l) = 1 || exit - tmux switch-client -t main + test (${tmux} list-windows | wc -l) = 1 || exit + test (${tmux} list-panes | wc -l) = 1 || exit + ${tmux} switch-client -t main ''; }; }; diff --git a/home/c/programs/hypr/default.nix b/home/c/programs/hypr/default.nix index bcdacdb..a3e9483 100644 --- a/home/c/programs/hypr/default.nix +++ b/home/c/programs/hypr/default.nix @@ -1,4 +1,28 @@ -{...}: { +{ + pkgs, + cLib, + ... +}: let + getProgFor' = cLib.getProgFor' pkgs; + getProgFor = cLib.getProgFor pkgs; + web = getProgFor "firefox"; + mail = getProgFor "betterbird"; + chat = getProgFor "discord"; + media = getProgFor "spotify"; + terminal = getProgFor "alacritty"; + runner = getProgFor "rofi"; + rofi-rbw = getProgFor "rofi-rbw-wayland"; + tmux = getProgFor "tmux"; + slurp = getProgFor "slurp"; + grim = getProgFor "grim"; + wl-copy = getProgFor' "wl-clipboard" "wl-copy"; + mullvad = getProgFor' "mullvad-vpn" "mullvad-gui"; + playerctl = getProgFor "playerctl"; + brightnessctl = getProgFor "brightnessctl"; + wpctl = getProgFor' "wireplumber" "wpctl"; + hyprlock = getProgFor "hyprlock"; + hyprctl = getProgFor' "hyprland" "hyprctl"; +in { services = { blueman-applet.enable = true; network-manager-applet.enable = true; @@ -65,7 +89,7 @@ enable = true; systemd.enable = true; xwayland.enable = true; - # TODO: move to nix config over text + settings = { "monitor" = ",prefered,auto,1"; @@ -137,13 +161,13 @@ "$mainMod SHIFT, q, exit" "$mainMod, F, fullscreen" "$mainMod SHIFT, f, togglefloating" - "$mainMod, d, exec, rofi -show drun" - "$mainMod, w, exec, rofi -show window" - "$mainMod, p, exec, rofi-rbw --no-folder" + "$mainMod, d, exec, ${runner} -show drun" + "$mainMod, w, exec, ${runner} -show window" + "$mainMod, p, exec, ${rofi-rbw} --no-folder" "$mainMod, s, togglesplit" - "$mainMod SHIFT, r, exec, hyprctl reload" - "$mainMod, return, exec, alacritty -e tmux new -A -s main" - "$mainMod SHIFT, return, exec, [float; pin] alacritty -e tmux new -A -s main" + "$mainMod SHIFT, r, exec, ${hyprctl} reload" + "$mainMod, return, exec, ${terminal} -e ${tmux} new -A -s main" + "$mainMod SHIFT, return, exec, [float; pin] ${terminal} -e ${tmux} new -A -s main" "$mainMod, b, workspace, name:web" "$mainMod, n, workspace, name:chat" @@ -172,9 +196,9 @@ "$mainMod SHIFT, l, movewindow, r" "$mainMod SHIFT, k, movewindow, u" "$mainMod SHIFT, j, movewindow, d" - ''SHIFT, Print, exec, grim -g "$(slurp)" - | wl-copy'' - ", Print, exec, grim - | wl-copy" - "$mainMod, 0, exec, hyprlock" + ''SHIFT, Print, exec, ${grim} -g "$(${slurp})" - | ${wl-copy}'' + ", Print, exec, ${grim} - | ${wl-copy}" + "$mainMod, 0, exec, ${hyprlock}" ] ++ (builtins.concatLists (builtins.genList (x: let ws = x + 1; @@ -187,10 +211,10 @@ 9)); workspace = [ - "name:web, on-created-empty: firefox" - "name:chat, on-created-empty: discord" - "name:media, on-created-empty: spotify" - "name:mail, on-created-empty: betterbird" + "name:web, on-created-empty: ${web}" + "name:chat, on-created-empty: ${chat}" + "name:media, on-created-empty: ${media}" + "name:mail, on-created-empty: ${mail}" ]; bindm = [ @@ -199,25 +223,19 @@ ]; bindle = [ - ", XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+" - ", XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-" - ", XF86AudioMute , exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle" - ", XF86AudioMicMute , exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle" - ", XF86AudioPlay , exec, playerctl play-pause" - ", XF86AudioPause , exec, playerctl play-pause" - ", XF86AudioNext , exec, playerctl next" - ", XF86AudioPrev , exec, playerctl previous" - ", XF86MonBrightnessUp, exec, brightnessctl -c backlight set +5%" - ", XF86MonBrightnessDown, exec, brightnessctl -c backlight set 5%-" + ", XF86AudioRaiseVolume, exec, ${wpctl} set-volume @DEFAULT_AUDIO_SINK@ 5%+" + ", XF86AudioLowerVolume, exec, ${wpctl} set-volume @DEFAULT_AUDIO_SINK@ 5%-" + ", XF86AudioMute , exec, ${wpctl} set-mute @DEFAULT_AUDIO_SINK@ toggle" + ", XF86AudioMicMute , exec, ${wpctl} set-mute @DEFAULT_AUDIO_SOURCE@ toggle" + ", XF86AudioPlay , exec, ${playerctl} play-pause" + ", XF86AudioPause , exec, ${playerctl} play-pause" + ", XF86AudioNext , exec, ${playerctl} next" + ", XF86AudioPrev , exec, ${playerctl} previous" + ", XF86MonBrightnessUp, exec, ${brightnessctl} -c backlight set +5%" + ", XF86MonBrightnessDown, exec, ${brightnessctl} -c backlight set 5%-" ]; - exec = [ - #"pkill wpaperd & sleep 0.5 && wpaperd" - #"pkill waybar & sleep 0.5 && waybar" - #"pkill mako & sleep 0.5 && mako" - ]; - - exec-once = ["mullvad-gui"]; + exec-once = [(toString mullvad)]; }; }; } diff --git a/home/c/programs/nvim/.luarc.json b/home/c/programs/nvim/.luarc.json deleted file mode 100644 index 904146d..0000000 --- a/home/c/programs/nvim/.luarc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "diagnostics.globals": [ - "vim", - "lsp_on_attach" - ] -} diff --git a/home/c/programs/nvim/default.nix b/home/c/programs/nvim/default.nix deleted file mode 100644 index 000a085..0000000 --- a/home/c/programs/nvim/default.nix +++ /dev/null @@ -1,313 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: { - programs.neovim = let - leaders = '' - vim.g.mapleader = ' ' - vim.g.maplocalleader = ' ' - ''; - toLua = str: '' - lua << EOF - ${leaders} - ${str} - EOF - ''; - toLuaFile = file: '' - lua << EOF - ${leaders} - ${builtins.readFile file} - EOF - ''; - toLuaFileLSP = file: '' - lua << EOF - ${leaders} - ${builtins.readFile ./plugin/lsp/lsp-keys.lua} - ${builtins.readFile file} - EOF - ''; - - fromGit = ref: rev: repo: - pkgs.vimUtils.buildVimPlugin { - pname = "${lib.strings.sanitizeDerivationName repo}"; - version = ref; - src = builtins.fetchGit { - url = "https://github.com/${repo}.git"; - inherit ref; - inherit rev; - }; - }; - - # always installs latest version - pluginGit = fromGit "HEAD"; - in { - enable = true; - - # package = pkgs.neovim-nightly; - - extraPackages = with pkgs; [ - # Rust - rust-analyzer - cargo - rustc - rustfmt - - # YAML - yaml-language-server - - # JSON - nodePackages.vscode-json-languageserver - - # Go - gopls - - # Typescript - nodePackages.typescript - nodePackages.typescript-language-server - - # Javascript - eslint_d - - # Python - nodePackages.pyright - black - - # Util - ripgrep - fzf - - # C-Family - clang-tools - - # Shell - shellcheck - shfmt - - # Lua - lua-language-server - selene - stylua - - # Nix - rnix-lsp - nixfmt - statix - - # LLM - ollama - - # Haskell - haskellPackages.haskell-debug-adapter - haskellPackages.haskell-language-server - haskellPackages.fourmolu - ghc - - # Docker - dockerfile-language-server-nodejs - docker-compose-language-service - ]; - - defaultEditor = true; - - viAlias = true; - vimAlias = true; - vimdiffAlias = true; - - extraLuaConfig = '' - ${builtins.readFile ./options.lua} - ''; - - plugins = with pkgs.vimPlugins; [ - { - plugin = nvim-lspconfig; - config = toLuaFileLSP ./plugin/lsp/lsp.lua; - } - - { - plugin = crates-nvim; - config = toLua "require('crates').setup()"; - } - - { - plugin = rustaceanvim; - config = toLuaFileLSP ./plugin/lsp/rust.lua; - } - - { - plugin = haskell-tools-nvim; - config = toLuaFileLSP ./plugin/lsp/haskell.lua; - } - - { - plugin = SchemaStore-nvim; - config = toLuaFileLSP ./plugin/lsp/schemastore.lua; - } - - { - plugin = todo-comments-nvim; - config = - toLua - "require('todo-comments').setup(); vim.api.nvim_set_keymap('n', 'vtd', ':TodoTelescope', { noremap = true });"; - } - - { - plugin = comment-nvim; - config = toLua "require('Comment').setup()"; - } - - { - plugin = onedark-nvim; - config = "colorscheme onedark"; - } - - neodev-nvim - - { - plugin = nvim-cmp; - config = toLuaFile ./plugin/cmp.lua; - } - - { - plugin = telescope-nvim; - config = toLuaFile ./plugin/telescope.lua; - } - - { - plugin = - pluginGit "951b163e55ce7639eb320c450bde9283c4fe968b" - "laytan/cloak.nvim"; - config = toLuaFile ./plugin/cloak.lua; - } - - { - plugin = - pluginGit "41ad952c8269fa7aa3a4b8a5abb44541cb628313" - "David-Kunz/gen.nvim"; - config = toLuaFile ./plugin/gen.lua; - } - - { - plugin = nvim-dap; - config = toLuaFile ./plugin/debugger.lua; - } - - { - plugin = - pluginGit "fd35a46f4b7c1b244249266bdcb2da3814f01724" - "xiyaowong/transparent.nvim"; - config = toLua "require('transparent').setup{}"; - } - - nvim-dap-ui - telescope-dap-nvim - nvim-dap-virtual-text - - telescope-fzf-native-nvim - - cmp_luasnip - cmp-nvim-lsp - - luasnip - friendly-snippets - - { - plugin = hardtime-nvim; - config = toLua "require('hardtime').setup()"; - } - - { - plugin = nvim-surround; - config = toLua "require('nvim-surround').setup{}"; - } - - { - plugin = harpoon; - config = toLuaFile ./plugin/harpoon.lua; - } - - { - plugin = lualine-nvim; - config = - toLua - "require('lualine').setup{options = {icons_enabled = true, theme = 'onedark', component_separators = '|', section_separators = ''}, sections = { lualine_a = { { 'buffers', } } }}"; - } - - { - plugin = nvim-autopairs; - config = toLua "require('nvim-autopairs').setup {}"; - } - - { - plugin = leap-nvim; - config = toLua "require('leap.user').add_default_mappings()"; - } - - { - plugin = none-ls-nvim; - config = toLuaFile ./plugin/lsp/none-ls.lua; - } - - { - plugin = oil-nvim; - config = toLuaFile ./plugin/oil.lua; - } - - { - plugin = zen-mode-nvim; - config = toLuaFile ./plugin/zen.lua; - } - twilight-nvim - - nvim-web-devicons - - { - plugin = undotree; - config = - toLua "vim.keymap.set('n', 'u', vim.cmd.UndotreeToggle)"; - } - - { - plugin = gitsigns-nvim; - config = toLuaFile ./plugin/gitsigns.lua; - } - - { - plugin = nvim-treesitter.withPlugins (p: [ - p.tree-sitter-nix - p.tree-sitter-vim - p.tree-sitter-bash - p.tree-sitter-lua - p.tree-sitter-python - p.tree-sitter-rust - p.tree-sitter-json - p.tree-sitter-c - p.tree-sitter-comment - p.tree-sitter-javascript - p.tree-sitter-fish - p.tree-sitter-dockerfile - p.tree-sitter-cpp - p.tree-sitter-git_config - p.tree-sitter-git_rebase - p.tree-sitter-gitattributes - p.tree-sitter-gitcommit - p.tree-sitter-gitignore - p.tree-sitter-markdown - p.tree-sitter-markdown_inline - p.tree-sitter-make - p.tree-sitter-norg - p.tree-sitter-ssh_config - p.tree-sitter-typescript - p.tree-sitter-tsx - p.tree-sitter-haskell - p.tree-sitter-yaml - p.tree-sitter-zig - ]); - config = toLuaFile ./plugin/treesitter.lua; - } - - vim-nix - ]; - }; -} diff --git a/home/c/programs/tmux/default.nix b/home/c/programs/tmux/default.nix index ffabf71..0f4cfeb 100644 --- a/home/c/programs/tmux/default.nix +++ b/home/c/programs/tmux/default.nix @@ -1,4 +1,13 @@ -{pkgs, ...}: { +{ + pkgs, + cLib, + ... +}: let + getProgFor = cLib.getProgFor pkgs; + getProgFor' = cLib.getProgFor' pkgs; + tmux = getProgFor "tmux"; + tmux-sessionizer = getProgFor' "tmux-sessionizer-cl" "tmux-sessionizer"; +in { programs.tmux = { enable = true; shortcut = "x"; @@ -42,9 +51,9 @@ bind \\ split-window -v -c "#{pane_current_path}" bind c new-window -c "#{pane_current_path}" - bind-key -r s run-shell "tmux display-popup -E 'tmux-sessionizer -s'" - bind-key -r f run-shell "tmux display-popup -E 'tmux-sessionizer -p'" - bind-key -r m run-shell "tmux switch-client -t main" + bind-key -r s run-shell "${tmux} display-popup -E '${tmux-sessionizer} -s'" + bind-key -r f run-shell "${tmux} display-popup -E '${tmux-sessionizer} -p'" + bind-key -r m run-shell "${tmux} switch-client -t main" bind S choose-tree bind -r k select-pane -U @@ -54,7 +63,7 @@ ''; }; - home.packages = [ - pkgs.tmux-sessionizer-cl - ]; + # home.packages = [ + # pkgs.tmux-sessionizer-cl + # ]; } diff --git a/home/c/programs/waybar/default.nix b/home/c/programs/waybar/default.nix index e5c5bfe..1d941fc 100644 --- a/home/c/programs/waybar/default.nix +++ b/home/c/programs/waybar/default.nix @@ -1,4 +1,10 @@ -{pkgs, ...}: { +{ + pkgs, + cLib, + ... +}: let + soundControl = cLib.getProgFor pkgs "pwvucontrol"; +in { programs.waybar = { enable = true; package = pkgs.waybar.override { @@ -35,7 +41,7 @@ tooltip = false; }; wireplumber = { - on-click = "${pkgs.pwvucontrol}/bin/pwvucontrol"; + on-click = toString soundControl; format = "{icon} {volume}%"; format-muted = ""; format-icons = ["" "" ""]; diff --git a/hosts/artemis/home.nix b/hosts/artemis/home.nix index fb18af5..3bfde5c 100644 --- a/hosts/artemis/home.nix +++ b/hosts/artemis/home.nix @@ -1,4 +1,8 @@ -{inputs, ...}: { +{ + inputs, + cLib, + ... +}: { programs.hyprlock.enable = true; security.pam.services.hyprlock = {}; home-manager = { @@ -11,6 +15,6 @@ inputs.self.homeManagerModules.trayscale ]; users.c = import ../../home/c; - extraSpecialArgs = {inherit inputs;}; + extraSpecialArgs = {inherit inputs cLib;}; }; } diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..c8b84db --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,6 @@ +{lib, ...}: let + getProgFor' = pkgs: prog: progn: lib.getExe' pkgs.${prog} progn; + getProgFor = pkgs: prog: getProgFor' pkgs prog prog; +in { + inherit getProgFor getProgFor'; +}