From c867dd3ea21816e69de08088385d0d9246433765 Mon Sep 17 00:00:00 2001 From: Stefan Weigl-Bosker Date: Mon, 24 Feb 2025 12:08:53 -0500 Subject: fixed nixGL wrapper --- flake.lock | 10 ++++---- flake.nix | 18 ++++++++------ home.nix | 13 +++++++++- modules/default.nix | 3 ++- modules/global.nix | 14 ++++++++--- modules/neovim/default.nix | 55 +++++++++++++++++++++++++++++++++++++++++ modules/neovim/keybinds.lua | 41 ++++++++++++++++++++++++++++++ modules/neovim/settings.lua | 50 +++++++++++++++++++++++++++++++++++++ modules/nvim/default.nix | 47 ----------------------------------- modules/nvim/keybinds.lua | 41 ------------------------------ modules/nvim/settings.lua | 50 ------------------------------------- modules/qutebrowser/default.nix | 13 ++++++++++ modules/sway/default.nix | 24 ++++++++++++------ 13 files changed, 215 insertions(+), 164 deletions(-) create mode 100644 modules/neovim/default.nix create mode 100644 modules/neovim/keybinds.lua create mode 100644 modules/neovim/settings.lua delete mode 100644 modules/nvim/default.nix delete mode 100644 modules/nvim/keybinds.lua delete mode 100644 modules/nvim/settings.lua create mode 100644 modules/qutebrowser/default.nix diff --git a/flake.lock b/flake.lock index 58fc7e8..ad7f39f 100644 --- a/flake.lock +++ b/flake.lock @@ -22,11 +22,11 @@ ] }, "locked": { - "lastModified": 1740254115, - "narHash": "sha256-MwxDtYB/MSGZlr/xS+ExGYH2QgHk73ShD40shxjad/Y=", + "lastModified": 1740283128, + "narHash": "sha256-R61wtNknWWejnl+K0l4sxu/wnLNFbNe44tNM2zbj5yE=", "owner": "nix-community", "repo": "home-manager", - "rev": "cb3f6e9b59d3a5e51ef9f7da2b8418d5c72aaef8", + "rev": "ed030a787938cae01d693ebaad52bbb672a4a69d", "type": "github" }, "original": { @@ -46,13 +46,13 @@ "lastModified": 1713543440, "narHash": "sha256-lnzZQYG0+EXl/6NkGpyIz+FEOc/DSEG57AP1VsdeNrM=", "owner": "nix-community", - "repo": "nixGL", + "repo": "nixgl", "rev": "310f8e49a149e4c9ea52f1adf70cdc768ec53f8a", "type": "github" }, "original": { "owner": "nix-community", - "repo": "nixGL", + "repo": "nixgl", "type": "github" } }, diff --git a/flake.nix b/flake.nix index f742c9f..4758390 100644 --- a/flake.nix +++ b/flake.nix @@ -10,13 +10,14 @@ }; nixgl = { - url = "github:nix-community/nixGL"; + url = "github:nix-community/nixgl"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = inputs@{ + self, nixpkgs, home-manager, nixgl, @@ -31,17 +32,18 @@ config.allowUnfree = true; inherit system overlays; }; - custom = import "custom.nix"; + inherit (pkgs) lib; in { packages.${system}.default = home-manager.defaultPackage.${system}; homeConfigurations = { - "stefan" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - extraSpecialArgs = { - inherit inputs; - }; - modules = [ ./home.nix ]; + inherit inputs system pkgs; + "stefan" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + extraSpecialArgs = { + inherit system inputs pkgs; }; + modules = [ ./home.nix ]; }; + }; }; } diff --git a/home.nix b/home.nix index 230502c..fc54d2a 100644 --- a/home.nix +++ b/home.nix @@ -1,4 +1,4 @@ -{ inputs, config, lib, pkgs, ... }: +{ inputs, config, lib, pkgs, nixgl, ... }: { imports = [ ./modules/global.nix @@ -6,6 +6,17 @@ ]; config.modules = { + global = { + notNixOS = true; + }; foot.enable = true; + + + neovim = { + enable = true; + }; +# sway = { +# enable = true; +# }; }; } diff --git a/modules/default.nix b/modules/default.nix index 65bf42a..bb06c36 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -3,6 +3,7 @@ imports = [ ./foot.nix ./sway - ./nvim + ./neovim + ./qutebrowser ]; } diff --git a/modules/global.nix b/modules/global.nix index e187685..f26be5f 100644 --- a/modules/global.nix +++ b/modules/global.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ...}: +{ config, lib, pkgs, inputs, ...}: let cfg = config.modules.global; in @@ -20,11 +20,18 @@ in foot.enable = true; sway = { enable = true; - package = if cfg.notNixOS then - config.lib.nixGL.wrap pkgs.sway else pkgs.sway; + wrapWithNixGL = true; +# package = if cfg.notNixOS then + # (config.lib.nixGL.wrap pkgs.sway) else pkgs.sway; +# package = config.lib.nixGL.wrap pkgs.sway; }; }; + nixGL = lib.mkIf cfg.notNixOS { + packages = inputs.nixgl.packages; + defaultWrapper = "mesa"; + }; + programs = { home-manager.enable = true; }; @@ -44,6 +51,7 @@ in wl-clipboard mako wmenu + cmatrix ]); }; diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix new file mode 100644 index 0000000..775f420 --- /dev/null +++ b/modules/neovim/default.nix @@ -0,0 +1,55 @@ +{ config, lib, pkgs, ...}: +let + cfg = config.modules.neovim; + lua = str: "lua << EOF\n${str}\nEOF\n"; + luaImport = file: "lua << EOF\n${builtins.readFile file}\nEOF\n"; +in +{ + options.modules.neovim = { + enable = lib.mkEnableOption "neovim"; + }; + + config = { + programs.neovim = lib.mkIf cfg.enable { + enable = true; + defaultEditor = true; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + plugins = with pkgs.vimPlugins; [ + { + plugin = nvim-lspconfig; + config = let + servers = [ + { name = "clangd"; } + ]; + in lua (pkgs.lib.strings.concatStrings (pkgs.lib.lists.forEach servers (s: "require('lspconfig')['${s.name}'].setup(${s.config or "{}"})\n"))); + } + + (nvim-treesitter.withPlugins (p: with p; [ + tree-sitter-nix + tree-sitter-c + tree-sitter-lua + tree-sitter-zig + tree-sitter-markdown + tree-sitter-markdown-inline + ])) + + { + plugin = neorg; + config = lua '' + require("neorg").setup() + ''; + } + base16-nvim + telescope-nvim + telescope-fzf-native-nvim + ]; + extraLuaConfig = '' + ${builtins.readFile ./settings.lua} + ${builtins.readFile ./keybinds.lua} + require("neorg").setup() + ''; + }; + }; +} diff --git a/modules/neovim/keybinds.lua b/modules/neovim/keybinds.lua new file mode 100644 index 0000000..cbd46c5 --- /dev/null +++ b/modules/neovim/keybinds.lua @@ -0,0 +1,41 @@ +local map = vim.keymap.set + +local function nmap(lhs, rhs, opts) + map('n', lhs, rhs, opts) +end + +local function swap(mode, bind1, bind2) + local tmp=bind1 + map(mode, bind1, bind2) + map(mode, bind2, tmp) +end + +local function swapnv(bind1, bind2) + swap({'n', 'v'}, bind1, bind2) +end + +swapnv('m', 'h') +swapnv('n', 'j') +swapnv('e', 'k') +swapnv('i', 'l') + +swapnv('M', 'H') +swapnv('N', 'J') +--swapnv('E', 'K') +swapnv('I', 'L') + +nmap('tn', ':tabnew', { desc = "Open a new tab" }) +nmap('tc', ':tabc', { desc = "Close the current tab" }) +nmap('tm', ':tabp', { desc = "Go to previous tab" }) +nmap('ti', ':tabn', { desc = "Go to next tab" }) + +nmap('wv', ':vne', { desc = "Create vertical split" }) +nmap('wh', ':new', { desc = "Create horizontal split" }) +nmap('wc', ':clo', { desc = "Close current window" }) + +nmap('wm', '', { desc = "Focus window left of the current one" }) +nmap('wn', '', { desc = "Focus window below the current one" }) +nmap('we', '', { desc = "Focus window above the current one" }) +nmap('wi', '', { desc = "Focus window right of the current one" }) + +nmap('fo', 'Telescope find_files', { silent = true }) diff --git a/modules/neovim/settings.lua b/modules/neovim/settings.lua new file mode 100644 index 0000000..816757c --- /dev/null +++ b/modules/neovim/settings.lua @@ -0,0 +1,50 @@ +vim.g.mapleader = ' ' + +vim.o.number = true +vim.o.relativenumber = true +vim.o.splitright = true +vim.o.splitbelow = true +vim.o.scrolloff = 15 +vim.o.wrap = false +vim.o.lbr = true +vim.o.shortmess = vim.o.shortmess .. "I" +vim.o.termguicolors = true +vim.opt.fillchars = {eob = " "} +--vim.o.smd = false +--vim.opt.laststatus = 3 +vim.opt.pumheight = 6 +vim.opt.shiftwidth = 8 +vim.opt.tabstop = 8 +vim.opt.expandtab = true +vim.o.mouse="" +vim.o.guicursor="" +vim.o.swapfile=false + +vim.cmd[[ + colorscheme base16-mountain + hi LineNr guifg=#ceb188 + hi LineNrAbove guifg=#262626 + hi LineNrBelow guifg=#262626 + hi CursorLineNr guifg=#ceb188 guibg=#191919 gui=bold + hi FloatBorder guifg=#4c4c4c + hi Pmenu guibg=#0d0d0d + hi PmenuSel guibg=#191919 guifg=#cacaca + hi WinBar guifg=#4c4c4c + hi WinSeparator guifg=#191919 + + " status line + hi StatusLine guibg=#191919 guifg=#4c4c4c + hi StatuslineInactive guibg=#191919 guifg=#4c4c4c gui=NONE + hi StatuslineAccent guifg=#0f0f0f guibg=#aca98a gui=bold + hi StatuslineInsertAccent guifg=#0f0f0f guibg=#8aabac gui=bold + hi StatuslineVisualAccent guifg=#0f0f0f guibg=#8f8aac gui=bold + hi StatuslineReplaceAccent guifg=#0f0f0f guibg=#ac8a8c gui=bold + hi StatuslineTerminalAccent guifg=#0f0f0f guibg=#ac8a8c gui=bold + hi StatuslineCommandAccent guifg=#0f0f0f guibg=#8aac8b gui=bold + hi StatuslineFileIcon guibg=#191919 guifg=#8f8aac + hi StatuslineInfo guibg=#191919 guifg=#4c4c4c + hi LspError guibg=#191919 guifg=#c49ea0 + hi LspWarn guibg=#191919 guifg=#8f8aac + hi LspInfo guibg=#191919 guifg=#8f8aac + hi LspHint guibg=#191919 guifg=#8aabac +]] diff --git a/modules/nvim/default.nix b/modules/nvim/default.nix deleted file mode 100644 index 54f9d53..0000000 --- a/modules/nvim/default.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ config, lib, pkgs, ...}: -let - cfg = config.modules.nvim; - lua = str: "lua << EOF\n${str}\nEOF\n"; - luaImport = file: "lua << EOF\n${builtins.readFile file}\nEOF\n"; -in -{ - options.modules.nvim = { - }; - - config = { - programs.neovim = { - enable = true; - defaultEditor = true; - viAlias = true; - vimAlias = true; - vimdiffAlias = true; - plugins = with pkgs.vimPlugins; [ - { - plugin = nvim-lspconfig; - config = let - servers = [ - { name = "clangd"; } - ]; - in lua(pkgs.lib.strings.concatStrings (pkgs.lib.lists.forEach servers (s: "require('lspconfig')['${s.name}'].setup(${s.config or "{}"})\n"))); - } - - (nvim-treesitter.withPlugins (p: with p; [ - tree-sitter-nix - tree-sitter-c - tree-sitter-lua - tree-sitter-zig - tree-sitter-markdown - tree-sitter-markdown-inline - ])) - - base16-nvim - telescope-nvim - telescope-fzf-native-nvim - ]; - extraLuaConfig = '' - ${builtins.readFile ./settings.lua} - ${builtins.readFile ./keybinds.lua} - ''; - }; - }; -} diff --git a/modules/nvim/keybinds.lua b/modules/nvim/keybinds.lua deleted file mode 100644 index 1c1c512..0000000 --- a/modules/nvim/keybinds.lua +++ /dev/null @@ -1,41 +0,0 @@ -local map = vim.keymap.set - -local function nmap(lhs, rhs, opts) - map('n', lhs, rhs, opts) -end - -local function swap(mode, bind1, bind2) - local tmp=bind1 - map(mode, bind1, bind2) - map(mode, bind2, tmp) -end - -local function swapnv(bind1, bind2) - swap({'n', 'v'}, bind1, bind2) -end - -swapnv('m', 'h') -swapnv('n', 'j') -swapnv('e', 'k') -swapnv('i', 'l') - -swapnv('M', 'H') -swapnv('N', 'J') ---swapnv('E', 'K') -swapnv('I', 'L') - -nmap('tn', ':tabnew', { desc = "Open a new tab" }) -nmap('tc', ':tabc', { desc = "Close the current tab" }) -nmap('tm', ':tabp', { desc = "Go to previous tab" }) -nmap('ti', ':tabn', { desc = "Go to next tab" }) - -nmap('wv', ':vne', { desc = "Create vertical split" }) -nmap('wh', ':new', { desc = "Create horizontal split" }) -nmap('wc', ':clo', { desc = "Close current window" }) - -nmap('wm', '', { desc = "Focus window left of the current one" }) -nmap('wn', '', { desc = "Focus window below the current one" }) -nmap('we', '', { desc = "Focus window above the current one" }) -nmap('wi', '', { desc = "Focus window right of the current one" }) - -nmap('fo', 'Telescope find_files', { silent = true }) diff --git a/modules/nvim/settings.lua b/modules/nvim/settings.lua deleted file mode 100644 index 816757c..0000000 --- a/modules/nvim/settings.lua +++ /dev/null @@ -1,50 +0,0 @@ -vim.g.mapleader = ' ' - -vim.o.number = true -vim.o.relativenumber = true -vim.o.splitright = true -vim.o.splitbelow = true -vim.o.scrolloff = 15 -vim.o.wrap = false -vim.o.lbr = true -vim.o.shortmess = vim.o.shortmess .. "I" -vim.o.termguicolors = true -vim.opt.fillchars = {eob = " "} ---vim.o.smd = false ---vim.opt.laststatus = 3 -vim.opt.pumheight = 6 -vim.opt.shiftwidth = 8 -vim.opt.tabstop = 8 -vim.opt.expandtab = true -vim.o.mouse="" -vim.o.guicursor="" -vim.o.swapfile=false - -vim.cmd[[ - colorscheme base16-mountain - hi LineNr guifg=#ceb188 - hi LineNrAbove guifg=#262626 - hi LineNrBelow guifg=#262626 - hi CursorLineNr guifg=#ceb188 guibg=#191919 gui=bold - hi FloatBorder guifg=#4c4c4c - hi Pmenu guibg=#0d0d0d - hi PmenuSel guibg=#191919 guifg=#cacaca - hi WinBar guifg=#4c4c4c - hi WinSeparator guifg=#191919 - - " status line - hi StatusLine guibg=#191919 guifg=#4c4c4c - hi StatuslineInactive guibg=#191919 guifg=#4c4c4c gui=NONE - hi StatuslineAccent guifg=#0f0f0f guibg=#aca98a gui=bold - hi StatuslineInsertAccent guifg=#0f0f0f guibg=#8aabac gui=bold - hi StatuslineVisualAccent guifg=#0f0f0f guibg=#8f8aac gui=bold - hi StatuslineReplaceAccent guifg=#0f0f0f guibg=#ac8a8c gui=bold - hi StatuslineTerminalAccent guifg=#0f0f0f guibg=#ac8a8c gui=bold - hi StatuslineCommandAccent guifg=#0f0f0f guibg=#8aac8b gui=bold - hi StatuslineFileIcon guibg=#191919 guifg=#8f8aac - hi StatuslineInfo guibg=#191919 guifg=#4c4c4c - hi LspError guibg=#191919 guifg=#c49ea0 - hi LspWarn guibg=#191919 guifg=#8f8aac - hi LspInfo guibg=#191919 guifg=#8f8aac - hi LspHint guibg=#191919 guifg=#8aabac -]] diff --git a/modules/qutebrowser/default.nix b/modules/qutebrowser/default.nix new file mode 100644 index 0000000..283ea80 --- /dev/null +++ b/modules/qutebrowser/default.nix @@ -0,0 +1,13 @@ +{ config, lib, pkgs, inputs, ... }: +let + cfg = config.modules.qutebrowser; +in +{ + config = { + programs.qutebrowser = { + enable = true; + package = config.lib.nixGL.wrap pkgs.qutebrowser; + loadAutoconfig = true; + }; + }; +} diff --git a/modules/sway/default.nix b/modules/sway/default.nix index 6a21685..d48ef32 100644 --- a/modules/sway/default.nix +++ b/modules/sway/default.nix @@ -1,19 +1,28 @@ -{ config, lib, pkgs, ... }: +{ self, config, lib, pkgs, nixgl, ... }: let cfg = config.modules.sway; in { options.modules.sway = { enable = lib.mkEnableOption "sway"; - package = lib.mkOption { - type = with lib.types; nullOr package; - default = pkgs.sway; - }; + wrapWithNixGL = lib.mkEnableOption "NixGL wrapper"; }; config = { + home.packages = with pkgs; [(writeShellScriptBin "browser" '' + swaymsg 'set $PROP newcont:tabbed ; exec qutebrowser --target window' + '')]; wayland.windowManager.sway = lib.mkIf cfg.enable { enable = true; - package = cfg.package; +# package = if cfg.wrapWithNixGL then config.lib.nixGL.wrap pkgs.sway else pkgs.sway; + package = config.lib.nixGL.wrap pkgs.sway; +# package = c +# package = pkgs.sway; +# package = pkgs.writeShellScriptBin "sway" '' +# ${pkgs.nixgl.auto.nixGLDefault}/bin/nixGL ${pkgs.sway}/bin/sway +# ''; +# extraSessionCommands='' +# source ${pkgs.nixgl.auto.nixGLDefault}/bin/nixGL +# ''; config = rec { modifier = "Mod1"; @@ -24,7 +33,7 @@ in fonts = { names = [ "ComicShannsMono Nerd Font Mono" ]; # material - size = 11.0; + size = 10.0; }; terminal = "foot"; @@ -248,4 +257,3 @@ in }; }; } - -- cgit v1.2.3