From 9d7f36dbae9ea45d141ddb07860273d5eb85f6a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 8 Nov 2024 19:39:26 +0100 Subject: [PATCH 1/6] refactor(lazygit): move into own module --- modules/profiles/base.nix | 61 +---------------------- modules/programs/lazygit.nix | 95 ++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 60 deletions(-) create mode 100644 modules/programs/lazygit.nix diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index 9aa5607..41c4a1c 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -187,7 +187,6 @@ in rs = "sudo systemctl"; uj = "journalctl --user"; rj = "sudo journalctl"; - lg = "lazygit"; }; aliases = { ls = "${getExe pkgs.eza} -lh --icons --git"; @@ -198,6 +197,7 @@ in variables = { EDITOR = "vim"; }; }; programs = { + lazygit.enable = true; direnv.enable = true; fish.enable = true; git.enable = true; @@ -299,65 +299,6 @@ in ]; }; starship.enable = true; - lazygit.enable = true; - lazygit.settings = { - customCommands = [ - { - key = ""; - context = "global"; - description = "Create new conventional commit"; - prompts = [ - { - type = "menu"; - key = "Type"; - title = "Type of change"; - options = [ - { name = "build"; description = "Changes that affect the build system or external dependencies"; value = "build"; } - { name = "feat"; description = "A new feature"; value = "feat"; } - { name = "fix"; description = "A bug fix"; value = "fix"; } - { name = "chore"; description = "Other changes that don't modify src or test files"; value = "chore"; } - { name = "ci"; description = "Changes to CI configuration files and scripts"; value = "ci"; } - { name = "docs"; description = "Documentation only changes"; value = "docs"; } - { name = "perf"; description = "A code change that improves performance"; value = "perf"; } - { name = "refactor"; description = "A code change that neither fixes a bug nor adds a feature"; value = "refactor"; } - { name = "revert"; description = "Reverts a previous commit"; value = "revert"; } - { name = "style"; description = "Changes that do not affect the meaning of the code"; value = "style"; } - { name = "test"; description = "Adding missing tests or correcting existing tests"; value = "test"; } - ]; - } - { - type = "input"; - title = "Scope"; - key = "Scope"; - initialValue = ""; - } - { - type = "menu"; - key = "Breaking"; - title = "Breaking change"; - options = [ - { name = "no"; value = ""; } - { name = "yes"; value = "!"; } - ]; - } - { - type = "input"; - title = "message"; - key = "Message"; - initialValue = ""; - } - { - type = "confirm"; - key = "Confirm"; - title = "Commit"; - body = "Are you sure you want to commit?"; - } - ]; - command = "git commit --message '{{.Form.Type}}{{ if .Form.Scope }}({{ .Form.Scope }}){{ end }}{{.Form.Breaking}}: {{.Form.Message}}'"; - loadingText = "Creating conventional commit..."; - } - ]; - }; }; home = { username = "moritz"; diff --git a/modules/programs/lazygit.nix b/modules/programs/lazygit.nix new file mode 100644 index 0000000..e3a07ca --- /dev/null +++ b/modules/programs/lazygit.nix @@ -0,0 +1,95 @@ +{ config +, lib +, pkgs +, ... +}: + +with lib; +let + cfg = config.my.programs.lazygit; + + wrapper = pkgs.writeShellApplication { + name = "lg"; + text = '' + export LAZYGIT_NEW_DIR_FILE="$HOME/.lazygit/newdir" + + lazygit "$@" + + if [ -f "$LAZYGIT_NEW_DIR_FILE" ]; then + cd "$(cat "$LAZYGIT_NEW_DIR_FILE")" + rm -f "$LAZYGIT_NEW_DIR_FILE" > /dev/null + fi + ''; + runtimeInputs = [ pkgs.lazygit ]; + }; +in +{ + options.my.programs.lazygit.enable = mkEnableOption "lazygit"; + + config = mkIf cfg.enable { + home-manager.users.moritz.home.packages = [ + wrapper + ]; + home-manager.users.moritz.programs.lazygit = { + enable = true; + settings = { + customCommands = [ + { + key = ""; + context = "global"; + description = "Create new conventional commit"; + prompts = [ + { + type = "menu"; + key = "Type"; + title = "Type of change"; + options = [ + { name = "build"; description = "Changes that affect the build system or external dependencies"; value = "build"; } + { name = "feat"; description = "A new feature"; value = "feat"; } + { name = "fix"; description = "A bug fix"; value = "fix"; } + { name = "chore"; description = "Other changes that don't modify src or test files"; value = "chore"; } + { name = "ci"; description = "Changes to CI configuration files and scripts"; value = "ci"; } + { name = "docs"; description = "Documentation only changes"; value = "docs"; } + { name = "perf"; description = "A code change that improves performance"; value = "perf"; } + { name = "refactor"; description = "A code change that neither fixes a bug nor adds a feature"; value = "refactor"; } + { name = "revert"; description = "Reverts a previous commit"; value = "revert"; } + { name = "style"; description = "Changes that do not affect the meaning of the code"; value = "style"; } + { name = "test"; description = "Adding missing tests or correcting existing tests"; value = "test"; } + ]; + } + { + type = "input"; + title = "Scope"; + key = "Scope"; + initialValue = ""; + } + { + type = "menu"; + key = "Breaking"; + title = "Breaking change"; + options = [ + { name = "no"; value = ""; } + { name = "yes"; value = "!"; } + ]; + } + { + type = "input"; + title = "message"; + key = "Message"; + initialValue = ""; + } + { + type = "confirm"; + key = "Confirm"; + title = "Commit"; + body = "Are you sure you want to commit?"; + } + ]; + command = "git commit --message '{{.Form.Type}}{{ if .Form.Scope }}({{ .Form.Scope }}){{ end }}{{.Form.Breaking}}: {{.Form.Message}}'"; + loadingText = "Creating conventional commit..."; + } + ]; + }; + }; + }; +} From 05e34bcfc9c257dd051afdf6ece80cbcdd501053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 8 Nov 2024 19:40:51 +0100 Subject: [PATCH 2/6] feat!: switch to lix --- modules/programs/nix.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/nix.nix b/modules/programs/nix.nix index c98c643..b158709 100644 --- a/modules/programs/nix.nix +++ b/modules/programs/nix.nix @@ -49,7 +49,7 @@ in nix = { nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; - package = pkgs.nix; + package = pkgs.lix; extraOptions = '' !include ${config.age.secrets.nix-github-token.path} From e93f7ce742fa9c444bf15160d0f1176e618009e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 8 Nov 2024 19:41:56 +0100 Subject: [PATCH 3/6] fix: use first nixosConfiguration instead of hardcoded name --- modules/programs/nvim/new_plugins/lsp.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/nvim/new_plugins/lsp.nix b/modules/programs/nvim/new_plugins/lsp.nix index 8a001f5..99b13e0 100644 --- a/modules/programs/nvim/new_plugins/lsp.nix +++ b/modules/programs/nvim/new_plugins/lsp.nix @@ -18,7 +18,7 @@ in }; options = { nixos = { - expr = ''(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.nixos-desktop.options''; + expr = ''builtins.head (builtins.attrValues ((builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations).options''; }; "flake-parts" = { expr = ''(builtins.getFlake ("git+file://" + toString ./.)).debug.options''; From a31054750a05d77f18845a2097d7ea9d8923eebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 8 Nov 2024 20:00:36 +0100 Subject: [PATCH 4/6] feat: add nh --- modules/profiles/base.nix | 4 ++++ modules/programs/nix.nix | 15 --------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index 41c4a1c..6d301d6 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -265,6 +265,10 @@ in programs = { mtr.enable = true; command-not-found.enable = false; + nh = { + enable = true; + flake = "/home/moritz/Documents/dotfiles/"; + }; }; services = { diff --git a/modules/programs/nix.nix b/modules/programs/nix.nix index b158709..2dfc969 100644 --- a/modules/programs/nix.nix +++ b/modules/programs/nix.nix @@ -10,12 +10,6 @@ let inherit (lib) mkEnableOption mkOption types; cfg = config.my.programs.nix; - mkNom = system: nix: - inputs.nix-monitored.packages.${system}.default.override - { - withNotify = false; - nix = nix; - }; in { options.my.programs.nix = { @@ -31,15 +25,6 @@ in }; config = { - my.nixpkgs.overlays = [ - (final: prev: - { - nixos-rebuild = prev.nixos-rebuild.override { - nix = mkNom final.system final.nix; - }; - }) - ]; - home-manager.users.moritz.programs.direnv.nix-direnv.package = pkgs.nix-direnv.override { nix = config.nix.package; }; From 50c6072ee9ea5972bb2a5cc3b6432ea00e298142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 8 Nov 2024 20:02:11 +0100 Subject: [PATCH 5/6] feat: enable mullvad on laptop --- hosts/nixos-laptop/default.nix | 1 + modules/profiles/impermanence.nix | 1 + 2 files changed, 2 insertions(+) diff --git a/hosts/nixos-laptop/default.nix b/hosts/nixos-laptop/default.nix index 658b9e2..48f97f7 100644 --- a/hosts/nixos-laptop/default.nix +++ b/hosts/nixos-laptop/default.nix @@ -22,6 +22,7 @@ }; terminal.package = pkgs.kitty; programs.exercism.enable = true; + services.mullvad.enable = true; }; users.users.moritz.packages = [ pkgs.poetry ]; diff --git a/modules/profiles/impermanence.nix b/modules/profiles/impermanence.nix index c5113e7..93568f7 100644 --- a/modules/profiles/impermanence.nix +++ b/modules/profiles/impermanence.nix @@ -27,6 +27,7 @@ in "/var/lib/nixos" "/var/lib/systemd" "/var/log" + "/etc/mullvad-vpn/" ]; files = [ "/etc/machine-id" From df2ffacc0f0db2685477d7d9428522171264f9fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 8 Nov 2024 20:13:24 +0100 Subject: [PATCH 6/6] feat: add rust_analyzer --- modules/programs/nvim/new_plugins/lsp.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/programs/nvim/new_plugins/lsp.nix b/modules/programs/nvim/new_plugins/lsp.nix index 99b13e0..afc64ab 100644 --- a/modules/programs/nvim/new_plugins/lsp.nix +++ b/modules/programs/nvim/new_plugins/lsp.nix @@ -8,6 +8,11 @@ in plugins.lsp = { enable = true; inlayHints = true; + servers.rust_analyzer = { + enable = true; + installRustc = false; + installCargo = false; + }; servers.elixirls.enable = true; servers.nextls.enable = true; servers.nil_ls.enable = true;