From 615cf82b524b2b5025d29f00e556fa03ee7b515d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Sun, 23 Mar 2025 21:44:28 +0100 Subject: [PATCH 1/4] feat: switch to fish as an interactive shell Now that it is written in Rust I am interested! --- modules/hm/default.nix | 15 +-- modules/hm/gui/default.nix | 6 +- modules/nixos/default.nix | 14 ++- modules/nixvim/dev-plugins.nix | 4 +- modules/nixvim/plugins.nix | 213 ++++++++++++++------------------- 5 files changed, 115 insertions(+), 137 deletions(-) diff --git a/modules/hm/default.nix b/modules/hm/default.nix index 4332866..3f31f26 100644 --- a/modules/hm/default.nix +++ b/modules/hm/default.nix @@ -58,6 +58,11 @@ in git = true; icons = "auto"; }; + # Shell + fish = { + enable = true; + preferAbbrs = true; # when defining an alias, prefer instead to define an abbreviation + }; # GnuPG gpg = { enable = true; @@ -75,16 +80,6 @@ in ssh.enable = true; # cd replacement zoxide.enable = true; - # Shell - zsh = { - enable = true; - autosuggestion.enable = true; - enableCompletion = true; - autocd = true; - dotDir = ".config/zsh"; - history.path = "${config.xdg.dataHome}/zsh/zsh_history"; - syntaxHighlighting.enable = true; - }; }; services = { diff --git a/modules/hm/gui/default.nix b/modules/hm/gui/default.nix index 00d70ea..308cdbf 100644 --- a/modules/hm/gui/default.nix +++ b/modules/hm/gui/default.nix @@ -129,11 +129,11 @@ in # PDF reader zathura.enable = true; # Auto start sway - zsh.loginExtra = - lib.optionalString cfg.sway.autostart # sh + fish.loginShellInit = + lib.optionalString cfg.sway.autostart # fish '' # Start Sway on login to TTY 1 - if [ "$TTY" = /dev/tty1 ]; then + if [ $TTY = /dev/tty1 ]; then exec sway fi ''; diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 18c44c4..d6eeff7 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -35,6 +35,17 @@ in ]; programs = { + # Launch fish if shell is interactive (from https://wiki.nixos.org/wiki/Fish) + bash.interactiveShellInit = # bash + '' + if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]] + then + shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION="" + exec ${pkgs.fish}/bin/fish $LOGIN_OPTION + fi + ''; + # Default shell + fish.enable = true; # Shell prompt starship = { enable = true; @@ -58,8 +69,6 @@ in (import ./starship-shorter-text.nix) ]; }; - # Default shell - zsh.enable = true; }; environment.etc = keysFromGithub; @@ -74,7 +83,6 @@ in builtins.attrNames keysFromGithub ); }; - users.defaultUserShell = pkgs.zsh; # Open ports for spotifyd networking.firewall = { allowedUDPPorts = [ 5353 ]; diff --git a/modules/nixvim/dev-plugins.nix b/modules/nixvim/dev-plugins.nix index 7659912..f44c09b 100644 --- a/modules/nixvim/dev-plugins.nix +++ b/modules/nixvim/dev-plugins.nix @@ -21,6 +21,7 @@ let "typos_lsp" # "typst_lsp" # Not using it "zls" + "fish_lsp" ]; in { @@ -95,6 +96,7 @@ in pkgs.stylua pkgs.taplo pkgs.yamlfmt + pkgs.fish ]; plugins.conform-nvim = { enable = true; @@ -111,6 +113,7 @@ in toml = [ "taplo" ]; yaml = [ "yamlfmt" ]; zig = [ "zigfmt" ]; + fish = [ "fish_indent" ]; }; }; }; @@ -127,7 +130,6 @@ in # latex = [ "chktex" ]; # Not in use nix = [ "statix" ]; sh = [ "dash" ]; - zsh = [ "zsh" ]; }; }; } diff --git a/modules/nixvim/plugins.nix b/modules/nixvim/plugins.nix index f843db6..8943c56 100644 --- a/modules/nixvim/plugins.nix +++ b/modules/nixvim/plugins.nix @@ -4,129 +4,102 @@ let in { config.plugins = { - cmp = { - enable = true; - cmdline = { - "/" = { - mapping = - mkRaw - # lua - '' - cmp.mapping.preset.cmdline() - ''; - sources = [ - { name = "rg"; } - { name = "buffer"; } - ]; + cmp = + let + srcWithIndex = groupIndex: name: { inherit name groupIndex; }; + in + { + enable = true; + cmdline = { + "/" = { + mapping = + mkRaw + # lua + '' + cmp.mapping.preset.cmdline() + ''; + sources = [ + { name = "rg"; } + { name = "buffer"; } + ]; + }; + ":" = { + mapping = + mkRaw + # lua + "cmp.mapping.preset.cmdline()"; + sources = [ + { name = "path"; } + { name = "cmdline"; } + ]; + }; }; - ":" = { - mapping = - mkRaw - # lua - '' - cmp.mapping.preset.cmdline() - ''; - sources = [ - { name = "path"; } - { name = "cmdline"; } - ]; - }; - }; - settings = { - # Snippets - snippet.expand = - # lua - '' - function(args) require('luasnip').lsp_expand(args.body) end - ''; - # Completion Sources - sources = [ - { - name = "buffer"; - groupIndex = 3; - } - { - name = "calc"; - groupIndex = 2; - } - { - name = "conventionalcommits"; - groupIndex = 1; - } - { - name = "crates"; - groupIndex = 1; - } - { - name = "luasnip"; - groupIndex = 1; - } - { - name = "nvim_lsp"; - groupIndex = 1; - } - { - name = "nvim_lsp_document_symbol"; - groupIndex = 1; - } - { - name = "nvim_lsp_signature_help"; - groupIndex = 1; - } - { - name = "path"; - groupIndex = 2; - } - { - name = "spell"; - groupIndex = 2; - } - { - name = "treesitter"; - groupIndex = 2; - } - ]; - mapping = - mkRaw + settings = { + # Snippets + snippet.expand = # lua - '' - cmp.mapping.preset.insert({ - [""] = function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif require("luasnip").expand_or_jumpable() then - require("luasnip").expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, - [""] = function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif require("luasnip").jumpable(-1) then - require("luasnip").jump(-1) - else - fallback() - end - end, - [""] = cmp.mapping(function(fallback) - if require("luasnip").choice_active() then - require("luasnip").next_choice() - else - fallback() - end - end), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete { }, - [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm { select = true }, - }) - ''; + "function(args) require('luasnip').lsp_expand(args.body) end"; + # Completion Sources + sources = [ + # very specific (not noisy) + (srcWithIndex 1 "calc") + (srcWithIndex 1 "crates") + (srcWithIndex 1 "fish") + (srcWithIndex 1 "luasnip") + (srcWithIndex 1 "nvim_lsp") + # Generally ok + (srcWithIndex 2 "conventionalcommits") + (srcWithIndex 2 "nvim_lsp_document_symbol") + (srcWithIndex 2 "nvim_lsp_signature_help") + # Noisy + (srcWithIndex 2 "path") + (srcWithIndex 3 "spell") + (srcWithIndex 3 "treesitter") + # Very noisy + (srcWithIndex 4 "buffer") + ]; + mapping = + mkRaw + # lua + '' + cmp.mapping.preset.insert({ + [""] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + require("luasnip").expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, + [""] = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + require("luasnip").jump(-1) + else + fallback() + end + end, + [""] = cmp.mapping(function(fallback) + if require("luasnip").choice_active() then + require("luasnip").next_choice() + else + fallback() + end + end), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete { }, + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm { select = true }, + }) + ''; + }; }; - }; + cmp-fish.enable = true; gitsigns.enable = true; lualine = { enable = true; From d089abd113e6cfcdd160bcfabab6703acab813d1 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 24 Mar 2025 00:00:10 +0100 Subject: [PATCH 2/4] chore(deps): lock file maintenance --- flake.lock | 12 ++++++------ scripts/jpassmenu/Cargo.lock | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index 153017d..720481f 100644 --- a/flake.lock +++ b/flake.lock @@ -319,11 +319,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1742456341, - "narHash": "sha256-yvdnTnROddjHxoQqrakUQWDZSzVchczfsuuMOxg476c=", + "lastModified": 1742606399, + "narHash": "sha256-NAxwF5cjgh8o5aylhePXWNQETCWYaTpNvdO2bMfINpQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "7344a3b78128f7b1765dba89060b015fb75431a7", + "rev": "0740f6f238767d4caf9afe774d3e88105766dfc6", "type": "github" }, "original": { @@ -342,11 +342,11 @@ "nuschtosSearch": [] }, "locked": { - "lastModified": 1742559284, - "narHash": "sha256-PSSjCCqpJPkCagkkdLODBVVonGxgwU5dN2CYlFPNVNw=", + "lastModified": 1742732006, + "narHash": "sha256-ZIBMfPNb/hfoFf79MRnhDXGKl0yGhjlYEpy3+/jbxFI=", "owner": "nix-community", "repo": "nixvim", - "rev": "c980271267ef146a6c30394c611a97e077471cf2", + "rev": "7776e37b67e7875c3cd56d9d20fd050798071706", "type": "github" }, "original": { diff --git a/scripts/jpassmenu/Cargo.lock b/scripts/jpassmenu/Cargo.lock index a83122b..6f351ae 100644 --- a/scripts/jpassmenu/Cargo.lock +++ b/scripts/jpassmenu/Cargo.lock @@ -293,9 +293,9 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "jiff" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d699bc6dfc879fb1bf9bdff0d4c56f0884fc6f0d0eb0fba397a6d00cd9a6b85e" +checksum = "c102670231191d07d37a35af3eb77f1f0dbf7a71be51a962dcd57ea607be7260" dependencies = [ "jiff-static", "log", @@ -306,9 +306,9 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d16e75759ee0aa64c57a56acbf43916987b20c77373cb7e808979e02b93c9f9" +checksum = "4cdde31a9d349f1b1f51a0b3714a5940ac022976f4b49485fc04be052b183b4c" dependencies = [ "proc-macro2", "quote", From 6bf3851d5a9c46b4f16af2f20e36b1ed45ca16c7 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 24 Mar 2025 10:50:11 +0100 Subject: [PATCH 3/4] fix(deps): update rust crate log to v0.4.27 | datasource | package | from | to | | ---------- | ------- | ------ | ------ | | crate | log | 0.4.26 | 0.4.27 | --- scripts/jpassmenu/Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/jpassmenu/Cargo.lock b/scripts/jpassmenu/Cargo.lock index 6f351ae..e91f9c0 100644 --- a/scripts/jpassmenu/Cargo.lock +++ b/scripts/jpassmenu/Cargo.lock @@ -341,9 +341,9 @@ checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413" [[package]] name = "log" -version = "0.4.26" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "memchr" From cd4fb19335dc4add8cf215cbef45b421aae98f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Sun, 23 Mar 2025 21:44:28 +0100 Subject: [PATCH 4/4] feat: switch to fish as an interactive shell Now that it is written in Rust I am interested! --- flake-modules/example-vm.nix | 2 +- modules/hm/default.nix | 15 +-- modules/hm/gui/default.nix | 8 +- modules/nixos/default.nix | 14 ++- modules/nixvim/dev-plugins.nix | 4 +- modules/nixvim/plugins.nix | 213 ++++++++++++++------------------- 6 files changed, 117 insertions(+), 139 deletions(-) diff --git a/flake-modules/example-vm.nix b/flake-modules/example-vm.nix index d6b88de..b21085d 100644 --- a/flake-modules/example-vm.nix +++ b/flake-modules/example-vm.nix @@ -12,7 +12,7 @@ in modules = [ inputs.self.nixosModules.default ../example-vm # import vm configuration - { nix.registry.nixpkgs.flake = inputs.nixpkgs; } + { nix.registry.nixpkgs.flake = inputs.nixpkgs; } # pin nixpkgs to the one used by the system ]; }; diff --git a/modules/hm/default.nix b/modules/hm/default.nix index 4332866..3f31f26 100644 --- a/modules/hm/default.nix +++ b/modules/hm/default.nix @@ -58,6 +58,11 @@ in git = true; icons = "auto"; }; + # Shell + fish = { + enable = true; + preferAbbrs = true; # when defining an alias, prefer instead to define an abbreviation + }; # GnuPG gpg = { enable = true; @@ -75,16 +80,6 @@ in ssh.enable = true; # cd replacement zoxide.enable = true; - # Shell - zsh = { - enable = true; - autosuggestion.enable = true; - enableCompletion = true; - autocd = true; - dotDir = ".config/zsh"; - history.path = "${config.xdg.dataHome}/zsh/zsh_history"; - syntaxHighlighting.enable = true; - }; }; services = { diff --git a/modules/hm/gui/default.nix b/modules/hm/gui/default.nix index 00d70ea..d885697 100644 --- a/modules/hm/gui/default.nix +++ b/modules/hm/gui/default.nix @@ -129,13 +129,13 @@ in # PDF reader zathura.enable = true; # Auto start sway - zsh.loginExtra = - lib.optionalString cfg.sway.autostart # sh + fish.loginShellInit = + lib.optionalString cfg.sway.autostart # fish '' # Start Sway on login to TTY 1 - if [ "$TTY" = /dev/tty1 ]; then + if test "$(tty)" = /dev/tty1 exec sway - fi + end ''; }; services = { diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 18c44c4..d6eeff7 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -35,6 +35,17 @@ in ]; programs = { + # Launch fish if shell is interactive (from https://wiki.nixos.org/wiki/Fish) + bash.interactiveShellInit = # bash + '' + if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]] + then + shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION="" + exec ${pkgs.fish}/bin/fish $LOGIN_OPTION + fi + ''; + # Default shell + fish.enable = true; # Shell prompt starship = { enable = true; @@ -58,8 +69,6 @@ in (import ./starship-shorter-text.nix) ]; }; - # Default shell - zsh.enable = true; }; environment.etc = keysFromGithub; @@ -74,7 +83,6 @@ in builtins.attrNames keysFromGithub ); }; - users.defaultUserShell = pkgs.zsh; # Open ports for spotifyd networking.firewall = { allowedUDPPorts = [ 5353 ]; diff --git a/modules/nixvim/dev-plugins.nix b/modules/nixvim/dev-plugins.nix index 7659912..f44c09b 100644 --- a/modules/nixvim/dev-plugins.nix +++ b/modules/nixvim/dev-plugins.nix @@ -21,6 +21,7 @@ let "typos_lsp" # "typst_lsp" # Not using it "zls" + "fish_lsp" ]; in { @@ -95,6 +96,7 @@ in pkgs.stylua pkgs.taplo pkgs.yamlfmt + pkgs.fish ]; plugins.conform-nvim = { enable = true; @@ -111,6 +113,7 @@ in toml = [ "taplo" ]; yaml = [ "yamlfmt" ]; zig = [ "zigfmt" ]; + fish = [ "fish_indent" ]; }; }; }; @@ -127,7 +130,6 @@ in # latex = [ "chktex" ]; # Not in use nix = [ "statix" ]; sh = [ "dash" ]; - zsh = [ "zsh" ]; }; }; } diff --git a/modules/nixvim/plugins.nix b/modules/nixvim/plugins.nix index f843db6..8943c56 100644 --- a/modules/nixvim/plugins.nix +++ b/modules/nixvim/plugins.nix @@ -4,129 +4,102 @@ let in { config.plugins = { - cmp = { - enable = true; - cmdline = { - "/" = { - mapping = - mkRaw - # lua - '' - cmp.mapping.preset.cmdline() - ''; - sources = [ - { name = "rg"; } - { name = "buffer"; } - ]; + cmp = + let + srcWithIndex = groupIndex: name: { inherit name groupIndex; }; + in + { + enable = true; + cmdline = { + "/" = { + mapping = + mkRaw + # lua + '' + cmp.mapping.preset.cmdline() + ''; + sources = [ + { name = "rg"; } + { name = "buffer"; } + ]; + }; + ":" = { + mapping = + mkRaw + # lua + "cmp.mapping.preset.cmdline()"; + sources = [ + { name = "path"; } + { name = "cmdline"; } + ]; + }; }; - ":" = { - mapping = - mkRaw - # lua - '' - cmp.mapping.preset.cmdline() - ''; - sources = [ - { name = "path"; } - { name = "cmdline"; } - ]; - }; - }; - settings = { - # Snippets - snippet.expand = - # lua - '' - function(args) require('luasnip').lsp_expand(args.body) end - ''; - # Completion Sources - sources = [ - { - name = "buffer"; - groupIndex = 3; - } - { - name = "calc"; - groupIndex = 2; - } - { - name = "conventionalcommits"; - groupIndex = 1; - } - { - name = "crates"; - groupIndex = 1; - } - { - name = "luasnip"; - groupIndex = 1; - } - { - name = "nvim_lsp"; - groupIndex = 1; - } - { - name = "nvim_lsp_document_symbol"; - groupIndex = 1; - } - { - name = "nvim_lsp_signature_help"; - groupIndex = 1; - } - { - name = "path"; - groupIndex = 2; - } - { - name = "spell"; - groupIndex = 2; - } - { - name = "treesitter"; - groupIndex = 2; - } - ]; - mapping = - mkRaw + settings = { + # Snippets + snippet.expand = # lua - '' - cmp.mapping.preset.insert({ - [""] = function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif require("luasnip").expand_or_jumpable() then - require("luasnip").expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, - [""] = function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif require("luasnip").jumpable(-1) then - require("luasnip").jump(-1) - else - fallback() - end - end, - [""] = cmp.mapping(function(fallback) - if require("luasnip").choice_active() then - require("luasnip").next_choice() - else - fallback() - end - end), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete { }, - [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm { select = true }, - }) - ''; + "function(args) require('luasnip').lsp_expand(args.body) end"; + # Completion Sources + sources = [ + # very specific (not noisy) + (srcWithIndex 1 "calc") + (srcWithIndex 1 "crates") + (srcWithIndex 1 "fish") + (srcWithIndex 1 "luasnip") + (srcWithIndex 1 "nvim_lsp") + # Generally ok + (srcWithIndex 2 "conventionalcommits") + (srcWithIndex 2 "nvim_lsp_document_symbol") + (srcWithIndex 2 "nvim_lsp_signature_help") + # Noisy + (srcWithIndex 2 "path") + (srcWithIndex 3 "spell") + (srcWithIndex 3 "treesitter") + # Very noisy + (srcWithIndex 4 "buffer") + ]; + mapping = + mkRaw + # lua + '' + cmp.mapping.preset.insert({ + [""] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + require("luasnip").expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, + [""] = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + require("luasnip").jump(-1) + else + fallback() + end + end, + [""] = cmp.mapping(function(fallback) + if require("luasnip").choice_active() then + require("luasnip").next_choice() + else + fallback() + end + end), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete { }, + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm { select = true }, + }) + ''; + }; }; - }; + cmp-fish.enable = true; gitsigns.enable = true; lualine = { enable = true;