From 6ce28c8b54776948949248842f38668aed8331c7 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 31 May 2024 22:52:54 +0100 Subject: [PATCH 01/15] fixed ssh ownership issue & removed hypr swapescape --- flake.lock | 32 +++++++++---------- .../optional/desktop/hyprland/default.nix | 1 - hosts/common/users/media/default.nix | 12 +++++++ hosts/common/users/sam/default.nix | 12 +++++++ 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/flake.lock b/flake.lock index 0aa38c0..d75fa14 100644 --- a/flake.lock +++ b/flake.lock @@ -29,11 +29,11 @@ ] }, "locked": { - "lastModified": 1717032306, - "narHash": "sha256-s3Sis+M1qTSVIehHrEKBzHBpqprIFJli5V6WojkJnYE=", + "lastModified": 1717177033, + "narHash": "sha256-G3CZJafCO8WDy3dyA2EhpUJEmzd5gMJ2IdItAg0Hijw=", "owner": "nix-community", "repo": "disko", - "rev": "8ea5bcccc03111bdedaeaae9380dfab61e9deb33", + "rev": "0274af4c92531ebfba4a5bd493251a143bc51f3c", "type": "github" }, "original": { @@ -182,11 +182,11 @@ ] }, "locked": { - "lastModified": 1717052710, - "narHash": "sha256-LRhOxzXmOza5SymhOgnEzA8EAQp+94kkeUYWKKpLJ/U=", + "lastModified": 1717097707, + "narHash": "sha256-HC5vJ3oYsjwsCaSbkIPv80e4ebJpNvFKQTBOGlHvjLs=", "owner": "nix-community", "repo": "home-manager", - "rev": "29c69d9a466e41d46fd3a7a9d0591ef9c113c2ae", + "rev": "0eb314b4f0ba337e88123e0b1e57ef58346aafd9", "type": "github" }, "original": { @@ -255,11 +255,11 @@ "nix-secrets": { "flake": false, "locked": { - "lastModified": 1717081517, - "narHash": "sha256-Pvennf20SmdaJ7mZK4I3jjQX8jQy9Hd/KeE64e2uqHU=", + "lastModified": 1717190678, + "narHash": "sha256-Dz7bJS76gW/yhTBx6n96d/ZN03gsTNY+GCwZXaMlKTg=", "ref": "refs/heads/master", - "rev": "c9a84172f898001d8e1732e7b6872be9d9352cef", - "revCount": 80, + "rev": "6e50c8300596629cee6aa72cbb3ab606e68660e8", + "revCount": 83, "type": "git", "url": "ssh://git@git.bitlab21.com/sam/nix-secrets.git" }, @@ -270,11 +270,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1716977081, - "narHash": "sha256-pFe5jLeIPlKEln5n2h998d7cpzXFdbrBMRe3suz4K1o=", + "lastModified": 1717112898, + "narHash": "sha256-7R2ZvOnvd9h8fDd65p0JnB7wXfUvreox3xFdYWd1BnY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ac82a513e55582291805d6f09d35b6d8b60637a1", + "rev": "6132b0f6e344ce2fe34fc051b72fb46e34f668e0", "type": "github" }, "original": { @@ -329,11 +329,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1717081007, - "narHash": "sha256-GNr1i6itjFKGXSco3lcdKe8GxEwrmSYFDUpZyXsXWp4=", + "lastModified": 1717188043, + "narHash": "sha256-qg8Tq7OcKtc0BS4RVUYrMZ+KofgMv6DiXOnqz7TN8CA=", "owner": "nix-community", "repo": "nixvim", - "rev": "da9bd1f2e8fc8cd8553a76a9e22afd386c18f205", + "rev": "1bbd58b6b293840716355e63fb3d5aa5af00d389", "type": "github" }, "original": { diff --git a/home/common/optional/desktop/hyprland/default.nix b/home/common/optional/desktop/hyprland/default.nix index a431480..e9fb092 100644 --- a/home/common/optional/desktop/hyprland/default.nix +++ b/home/common/optional/desktop/hyprland/default.nix @@ -36,7 +36,6 @@ kb_layout = gb kb_variant = kb_model = - kb_options = caps:swapescape kb_rules = follow_mouse = 1 diff --git a/hosts/common/users/media/default.nix b/hosts/common/users/media/default.nix index 8ed72dd..f1e1f3a 100644 --- a/hosts/common/users/media/default.nix +++ b/hosts/common/users/media/default.nix @@ -61,6 +61,18 @@ in }; }; + # The containing ssh folders are created as root and if this is the first ~/.ssh/ entry when writing keys, + # the ownership is busted and home-manager can't target because it can't write into .ssh... + # FIXME: We might not need this depending on how https://github.com/Mic92/sops-nix/issues/381 is fixed + system.activationScripts.sopsSetSshOwnwership = let + sshFolder = "/home/${username}/.ssh"; + user = config.users.users.${username}.name; + group = config.users.users.${username}.group; + in '' + mkdir -p ${sshFolder} || true + chown -R ${user}:${group} /home/${username}/.ssh + ''; + services.flatpak.enable = true; programs.zsh.enable = true; diff --git a/hosts/common/users/sam/default.nix b/hosts/common/users/sam/default.nix index c2f3672..51a660d 100644 --- a/hosts/common/users/sam/default.nix +++ b/hosts/common/users/sam/default.nix @@ -37,6 +37,18 @@ in }; }; + # The containing ssh folders are created as root and if this is the first ~/.ssh/ entry when writing keys, + # the ownership is busted and home-manager can't target because it can't write into .ssh... + # FIXME: We might not need this depending on how https://github.com/Mic92/sops-nix/issues/381 is fixed + system.activationScripts.sopsSetSshOwnwership = let + sshFolder = "/home/${username}/.ssh"; + user = config.users.users.${username}.name; + group = config.users.users.${username}.group; + in '' + mkdir -p ${sshFolder} || true + chown -R ${user}:${group} /home/${username}/.ssh + ''; + programs.zsh.enable = true; home-manager = { From 768116810971a24724a3a9bbf9e713490c2399ae Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 1 Jun 2024 00:50:17 +0100 Subject: [PATCH 02/15] various changes --- home/common/core/default.nix | 2 ++ .../optional/desktop/common/default.nix | 1 + .../optional/desktop/hyprland/default.nix | 29 +++++++++---------- home/semita.nix | 12 ++++---- hosts/common/optional/pipewire.nix | 18 ++++++------ hosts/common/users/sam/default.nix | 10 +++++++ hosts/semita/default.nix | 9 ------ 7 files changed, 41 insertions(+), 40 deletions(-) diff --git a/home/common/core/default.nix b/home/common/core/default.nix index bbb9e43..71712c1 100644 --- a/home/common/core/default.nix +++ b/home/common/core/default.nix @@ -17,6 +17,8 @@ tree jq coreutils + btop + htop ;}; home.stateVersion = "23.11"; } diff --git a/home/common/optional/desktop/common/default.nix b/home/common/optional/desktop/common/default.nix index f349273..90c09b3 100644 --- a/home/common/optional/desktop/common/default.nix +++ b/home/common/optional/desktop/common/default.nix @@ -8,5 +8,6 @@ pkgs.zathura pkgs.xfce.thunar pkgs.wofi + pkgs.kcolorchooser ]; } diff --git a/home/common/optional/desktop/hyprland/default.nix b/home/common/optional/desktop/hyprland/default.nix index e9fb092..d73886f 100644 --- a/home/common/optional/desktop/hyprland/default.nix +++ b/home/common/optional/desktop/hyprland/default.nix @@ -37,9 +37,9 @@ kb_variant = kb_model = kb_rules = - + repeat_delay = 280 + repeat_rate = 60 follow_mouse = 1 - touchpad { natural_scroll = no } @@ -48,20 +48,18 @@ general { - gaps_in = 5 - gaps_out = 20 + gaps_in = 10 + gaps_out = 10 border_size = 2 - col.active_border = #22ff00 - col.inactive_border = #aecbb4 - + col.active_border = rgba(22ff00ee) + col.inactive_border = rgba(aecbb4ee) layout = dwindle - allow_tearing = false } decoration { - rounding = 10 + rounding = 5 blur { enabled = true @@ -112,18 +110,17 @@ $mainMod = SUPER - bind = $mainMod, Q, exec, $terminal - bind = $mainMod, C, killactive, + bind = $mainMod, RETURN, exec, $terminal + bind = $mainMod, Q, killactive, bind = $mainMod, M, exit, bind = $mainMod, E, exec, $fileManager bind = $mainMod, V, togglefloating, bind = $mainMod, R, exec, $menu - bind = $mainMod, S, exec, rofi -show drun -show-icons - bind = $mainMod, left, movefocus, l - bind = $mainMod, right, movefocus, r - bind = $mainMod, up, movefocus, u - bind = $mainMod, down, movefocus, d + bind = $mainMod, h, movefocus, l + bind = $mainMod, l, movefocus, r + bind = $mainMod, k, movefocus, u + bind = $mainMod, j, movefocus, d bind = $mainMod, 1, workspace, 1 bind = $mainMod, 2, workspace, 2 diff --git a/home/semita.nix b/home/semita.nix index b5e71b1..9d8e616 100644 --- a/home/semita.nix +++ b/home/semita.nix @@ -26,19 +26,19 @@ monitors = [ { - name = "Virtual-1"; - width = 1920; + name = "DP-1"; + width = 2560; height = 1440; - refreshRate = 75; + refreshRate = 144; x = 0; primary = true; } { - name = "Virtual-2"; - width = 1920; + name = "DP-2"; + width = 2560; height = 1440; refreshRate = 75; - x = 1920; + x = 2560; } ]; } diff --git a/hosts/common/optional/pipewire.nix b/hosts/common/optional/pipewire.nix index fb0fbd8..7791d92 100644 --- a/hosts/common/optional/pipewire.nix +++ b/hosts/common/optional/pipewire.nix @@ -1,17 +1,17 @@ { pkgs, ... }: { sound.enable = true; - hardware.pulseaudio.enable = false; + hardware.pulseaudio.enable = true; security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; +# services.pipewire = { +# enable = true; +# alsa.enable = true; # alsa.support32Bit = true; - pulse.enable = true; - wireplumber.enable = true; - jack.enable = true; - - }; +# pulse.enable = true; +# wireplumber.enable = true; +# jack.enable = true; +# +# }; environment.systemPackages = [ pkgs.pamixer diff --git a/hosts/common/users/sam/default.nix b/hosts/common/users/sam/default.nix index 51a660d..90e93ef 100644 --- a/hosts/common/users/sam/default.nix +++ b/hosts/common/users/sam/default.nix @@ -49,6 +49,16 @@ in chown -R ${user}:${group} /home/${username}/.ssh ''; + environment.persistence."/persist" = { + hideMounts = true; + users.${username} = { + directories = [ + "." + ]; + }; + }; + + programs.zsh.enable = true; home-manager = { diff --git a/hosts/semita/default.nix b/hosts/semita/default.nix index 36ae3c1..dbaff18 100644 --- a/hosts/semita/default.nix +++ b/hosts/semita/default.nix @@ -42,15 +42,6 @@ in }; }; - environment.persistence."/persist" = { - hideMounts = true; - users.${user} = { - directories = [ - "/home/${user}" - ]; - }; - }; - networking = { hostName = "semita"; networkmanager.enable = true; From 7d5e5cd6cadadc1b07c5793542e3ccac75e91024 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 1 Jun 2024 15:42:59 +0100 Subject: [PATCH 03/15] create wallpaper dir if missing & fix home dir persistance --- .../wallpaper-changer/swww-wallpaper-changer/default.nix | 7 ++++--- hosts/common/users/sam/default.nix | 9 +++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/home/common/optional/desktop/wallpaper-changer/swww-wallpaper-changer/default.nix b/home/common/optional/desktop/wallpaper-changer/swww-wallpaper-changer/default.nix index 3ca13d1..d0b135f 100644 --- a/home/common/optional/desktop/wallpaper-changer/swww-wallpaper-changer/default.nix +++ b/home/common/optional/desktop/wallpaper-changer/swww-wallpaper-changer/default.nix @@ -13,16 +13,17 @@ WantedBy = [ "default.target" ]; }; Service = { - Type = [ "oneshot" ]; + Type = [ "simple" ]; ExecStart = "${pkgs.writeShellScript "swww-wallpaper-changer" '' export WAYLAND_DISPLAY="wayland-1" wallpaper_dir="$HOME/.local/share/bg/" - + [ -d "$wallpaper_dir" ] || mkdir -p "$wallpaper_dir" + # Allow some time for desktop to start sleep 3 echo "starting daemon..." ${pkgs.swww}/bin/swww-daemon & - + while true; do find "$wallpaper_dir" -type f -follow \( -iname \*.jpg -o -iname \*.png -o -iname \*.gif -o -iname \*.bmp \) | shuf | while read -r file; do ${pkgs.swww}/bin/swww img "$file" --transition-step 10 --transition-fps 60 diff --git a/hosts/common/users/sam/default.nix b/hosts/common/users/sam/default.nix index 90e93ef..0548e85 100644 --- a/hosts/common/users/sam/default.nix +++ b/hosts/common/users/sam/default.nix @@ -50,12 +50,9 @@ in ''; environment.persistence."/persist" = { - hideMounts = true; - users.${username} = { - directories = [ - "." - ]; - }; + directories = [ + "/home/${username}" + ]; }; From e06d88e7ac9b04ffe973984dc4472d9f610f62ad Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 1 Jun 2024 15:55:54 +0100 Subject: [PATCH 04/15] alacritty config --- .../optional/desktop/common/alacritty.nix | 20 +++++++++++++++++++ .../optional/desktop/common/default.nix | 3 ++- home/semita.nix | 6 ------ 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 home/common/optional/desktop/common/alacritty.nix diff --git a/home/common/optional/desktop/common/alacritty.nix b/home/common/optional/desktop/common/alacritty.nix new file mode 100644 index 0000000..0ee302f --- /dev/null +++ b/home/common/optional/desktop/common/alacritty.nix @@ -0,0 +1,20 @@ +{ config, pkgs, lib, ... }: +let + user = config.home.username; +in +{ + home-manager.users.${user}.programs.alacritty = { + enable = true; + settings = { + + window.padding = { + x = 2; + y = 2; + }; + + shell.program = "${pkgs.zsh}/bin/zsh"; + + cursor.style = "Beam"; + }; + }; +} diff --git a/home/common/optional/desktop/common/default.nix b/home/common/optional/desktop/common/default.nix index 90c09b3..3bbbc74 100644 --- a/home/common/optional/desktop/common/default.nix +++ b/home/common/optional/desktop/common/default.nix @@ -1,10 +1,11 @@ {pkgs, ... }: { imports = [ ./firefox.nix + ./alacritty.nix ]; # Global packages for desktop environments home.packages = [ - pkgs.kitty + pkgs.alacritty pkgs.zathura pkgs.xfce.thunar pkgs.wofi diff --git a/home/semita.nix b/home/semita.nix index 9d8e616..9d87d88 100644 --- a/home/semita.nix +++ b/home/semita.nix @@ -18,12 +18,6 @@ ]; - home.packages = [ - pkgs.alacritty - pkgs.zathura - pkgs.xfce.thunar - ]; - monitors = [ { name = "DP-1"; From 2c8dcf74e428d9e00a8e9b860aadbb59c2bc01f7 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 1 Jun 2024 16:39:14 +0100 Subject: [PATCH 05/15] added semita sound firmware --- home/common/optional/desktop/common/alacritty.nix | 6 +++--- hosts/common/optional/pipewire.nix | 1 + hosts/semita/default.nix | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/home/common/optional/desktop/common/alacritty.nix b/home/common/optional/desktop/common/alacritty.nix index 0ee302f..71dd7c0 100644 --- a/home/common/optional/desktop/common/alacritty.nix +++ b/home/common/optional/desktop/common/alacritty.nix @@ -3,13 +3,13 @@ let user = config.home.username; in { - home-manager.users.${user}.programs.alacritty = { + programs.alacritty = { enable = true; settings = { window.padding = { - x = 2; - y = 2; + x = 5; + y = 5; }; shell.program = "${pkgs.zsh}/bin/zsh"; diff --git a/hosts/common/optional/pipewire.nix b/hosts/common/optional/pipewire.nix index 7791d92..26948ee 100644 --- a/hosts/common/optional/pipewire.nix +++ b/hosts/common/optional/pipewire.nix @@ -3,6 +3,7 @@ sound.enable = true; hardware.pulseaudio.enable = true; security.rtkit.enable = true; + hardware.pulseaudio.package = pkgs.pulseaudioFull; # services.pipewire = { # enable = true; # alsa.enable = true; diff --git a/hosts/semita/default.nix b/hosts/semita/default.nix index dbaff18..1a5e1f9 100644 --- a/hosts/semita/default.nix +++ b/hosts/semita/default.nix @@ -35,6 +35,8 @@ in ]; boot = { + blacklistedKernelModules = [ "snd_hda_intel" "snd_soc_skl" ]; + kernelPackages = pkgs.linuxPackagesFor pkgs.linux_latest; loader = { systemd-boot.enable = true; efi.canTouchEfiVariables = true; @@ -42,6 +44,10 @@ in }; }; + hardware.firmware = [ + pkgs.sof-firmware + ]; + networking = { hostName = "semita"; networkmanager.enable = true; From 33d41f425644e9d1bc1204e37d6ad8434c5e9d2d Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 2 Jun 2024 14:30:14 +0100 Subject: [PATCH 06/15] rice --- flake.lock | 51 +++++++++++++++++++ flake.nix | 5 +- home/common/core/default.nix | 4 +- home/common/core/nixvim.nix | 29 ++++++++++- home/common/core/zsh.nix | 39 ++++++++++---- .../optional/desktop/common/alacritty.nix | 32 +++++++++++- .../optional/desktop/common/default.nix | 1 + .../optional/desktop/hyprland/default.nix | 14 +++-- home/common/optional/desktop/mako.nix | 12 +++++ home/semita.nix | 3 ++ 10 files changed, 169 insertions(+), 21 deletions(-) create mode 100644 home/common/optional/desktop/mako.nix diff --git a/flake.lock b/flake.lock index d75fa14..4032baa 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "base16-schemes": { + "flake": false, + "locked": { + "lastModified": 1696158499, + "narHash": "sha256-5yIHgDTPjoX/3oDEfLSQ0eJZdFL1SaCfb9d6M0RmOTM=", + "owner": "tinted-theming", + "repo": "base16-schemes", + "rev": "a9112eaae86d9dd8ee6bb9445b664fba2f94037a", + "type": "github" + }, + "original": { + "owner": "tinted-theming", + "repo": "base16-schemes", + "type": "github" + } + }, "devshell": { "inputs": { "flake-utils": "flake-utils", @@ -231,6 +247,25 @@ "type": "github" } }, + "nix-colors": { + "inputs": { + "base16-schemes": "base16-schemes", + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1707825078, + "narHash": "sha256-hTfge2J2W+42SZ7VHXkf4kjU+qzFqPeC9k66jAUBMHk=", + "owner": "misterio77", + "repo": "nix-colors", + "rev": "b01f024090d2c4fc3152cd0cf12027a7b8453ba1", + "type": "github" + }, + "original": { + "owner": "misterio77", + "repo": "nix-colors", + "type": "github" + } + }, "nix-darwin": { "inputs": { "nixpkgs": [ @@ -282,6 +317,21 @@ "type": "indirect" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1697935651, + "narHash": "sha256-qOfWjQ2JQSQL15KLh6D7xQhx0qgZlYZTYlcEiRuAMMw=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "e1e11fdbb01113d85c7f41cada9d2847660e3902", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "nixpkgs-stable": { "locked": { "lastModified": 1716655032, @@ -347,6 +397,7 @@ "disko": "disko", "home-manager": "home-manager", "impermanence": "impermanence", + "nix-colors": "nix-colors", "nix-secrets": "nix-secrets", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", diff --git a/flake.nix b/flake.nix index dc26e45..69da67a 100644 --- a/flake.nix +++ b/flake.nix @@ -20,6 +20,9 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + # Nix colors + nix-colors.url = "github:misterio77/nix-colors"; + # Declarative partitioning and formatting disko = { url = "github:nix-community/disko"; @@ -49,7 +52,7 @@ disko, #impermanence, ... - } @ inputs: + } @ inputs: let inherit (self) outputs; systems = [ diff --git a/home/common/core/default.nix b/home/common/core/default.nix index 71712c1..b3dc7d5 100644 --- a/home/common/core/default.nix +++ b/home/common/core/default.nix @@ -1,12 +1,12 @@ -{ config, lib, pkgs, outputs, ... }: +{ config, lib, pkgs, outputs, inputs, ... }: { imports = [ + inputs.nix-colors.homeManagerModules.default ./zsh.nix ./nixvim.nix ./fonts.nix ] ; - # Global home packages without config go here (for all hosts and users) home.packages = builtins.attrValues { inherit (pkgs) diff --git a/home/common/core/nixvim.nix b/home/common/core/nixvim.nix index fde5a9c..9e66742 100644 --- a/home/common/core/nixvim.nix +++ b/home/common/core/nixvim.nix @@ -1,4 +1,4 @@ -{ inputs, pkgs, ... }: { +{ inputs, pkgs, config, ... }: { imports = [ inputs.nixvim.homeManagerModules.nixvim ]; @@ -23,6 +23,29 @@ }; }; + # Base16 colorscheme +# colorschemes.base16 = { +# enable = true; +# colorscheme = { +# base00 = "#${config.colorScheme.colors.base00}"; +# base01 = "#${config.colorScheme.colors.base01}"; +# base02 = "#${config.colorScheme.colors.base02}"; +# base03 = "#${config.colorScheme.colors.base03}"; +# base04 = "#${config.colorScheme.colors.base04}"; +# base05 = "#${config.colorScheme.colors.base05}"; +# base06 = "#${config.colorScheme.colors.base06}"; +# base07 = "#${config.colorScheme.colors.base07}"; +# base08 = "#${config.colorScheme.colors.base08}"; +# base09 = "#${config.colorScheme.colors.base09}"; +# base0A = "#${config.colorScheme.colors.base0A}"; +# base0B = "#${config.colorScheme.colors.base0B}"; +# base0C = "#${config.colorScheme.colors.base0C}"; +# base0D = "#${config.colorScheme.colors.base0D}"; +# base0E = "#${config.colorScheme.colors.base0E}"; +# base0F = "#${config.colorScheme.colors.base0F}"; +# }; +# }; + opts = { # # ========= General Appearance ========= @@ -101,6 +124,10 @@ fileTypes = [ "*" ]; }; + plugins.treesitter = { + enable = true; + }; + plugins.lualine = { enable = true; theme = "auto"; diff --git a/home/common/core/zsh.nix b/home/common/core/zsh.nix index 9facad2..c0cba1b 100644 --- a/home/common/core/zsh.nix +++ b/home/common/core/zsh.nix @@ -5,15 +5,15 @@ enableCompletion = true; autosuggestion.enable = true; syntaxHighlighting.enable = true; - + shellAliases = { ll = "ls -l"; }; history.size = 10000; history.path = "${config.xdg.dataHome}/zsh/history"; - initExtra = '' - bindkey -v + initExtra = '' + bindkey -v bindkey "^H" backward-delete-char bindkey "^?" backward-delete-char set -o vi @@ -22,11 +22,11 @@ if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then SESSION_TYPE="(ssh) " fi - + #### # Format prompt #### - + # Define colors COLOR_RED="red" COLOR_MAGENTA="92" @@ -34,20 +34,20 @@ COLOR_GREEN="36" COLOR_BLUE="4" COLOR_WHITE="7" - + # Format git colors autoload -Uz compinit && compinit autoload -Uz add-zsh-hook autoload -Uz vcs_info add-zsh-hook precmd vcs_info - + zstyle ':vcs_info:*' enable git zstyle ':vcs_info:*' formats " %F{cyan}%c%u(%b)%f" zstyle ':vcs_info:*' actionformats " %F{cyan}%c%u(%b)%f %a" zstyle ':vcs_info:*' stagedstr "%F{$COLOR_RED}" zstyle ':vcs_info:*' unstagedstr "%F{$COLOR_RED}" zstyle ':vcs_info:*' check-for-changes true - + zstyle ':vcs_info:git*+set-message:*' hooks git-untracked +vi-git-untracked() { if git --no-optional-locks status --porcelain 2> /dev/null | grep -q "^??"; then @@ -58,7 +58,7 @@ hook_com[staged]+="%F{$COLOR_GREEN}" fi } - + # Format prompt setopt PROMPT_SUBST PROMPT='%F{'$COLOR_GREEN'}'$(echo "$SESSION_TYPE")''' @@ -77,11 +77,28 @@ setopt autocd # Automatically cd into typed directory. stty stop undef # Disable ctrl-s to freeze terminal. setopt interactive_comments - + # General opts HISTSIZE=10000000 SAVEHIST=10000000 setopt appendhistory + + # Change cursor shape for different vi modes. + function zle-keymap-select () { + case $KEYMAP in + vicmd) echo -ne '\e[1 q';; # block + viins|main) echo -ne '\e[5 q';; # beam + esac + } + zle -N zle-keymap-select + zle-line-init() { + zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere) + echo -ne "\e[5 q" + } + zle -N zle-line-init + echo -ne '\e[5 q' # Use beam shape cursor on startup. + preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt. + ''; }; -} +} diff --git a/home/common/optional/desktop/common/alacritty.nix b/home/common/optional/desktop/common/alacritty.nix index 71dd7c0..20ecd39 100644 --- a/home/common/optional/desktop/common/alacritty.nix +++ b/home/common/optional/desktop/common/alacritty.nix @@ -7,6 +7,37 @@ in enable = true; settings = { + colors = with config.colorScheme.palette; { + bright = { + black = "0x${base03}"; + blue = "0x${base04}"; + cyan = "0x${base0F}"; + green = "0x${base01}"; + magenta = "0x${base06}"; + red = "0x${base09}"; + white = "0x${base07}"; + yellow = "0x${base02}"; + }; + cursor = { + cursor = "0x${base05}"; + text = "0x${base00}"; + }; + normal = { + black = "0x${base00}"; + blue = "0x${base0D}"; + cyan = "0x${base0C}"; + green = "0x${base0B}"; + magenta = "0x${base0E}"; + red = "0x${base08}"; + white = "0x${base05}"; + yellow = "0x${base0A}"; + }; + primary = { + background = "0x${base00}"; + foreground = "0x${base05}"; + }; + }; + window.padding = { x = 5; y = 5; @@ -14,7 +45,6 @@ in shell.program = "${pkgs.zsh}/bin/zsh"; - cursor.style = "Beam"; }; }; } diff --git a/home/common/optional/desktop/common/default.nix b/home/common/optional/desktop/common/default.nix index 3bbbc74..3c8fb38 100644 --- a/home/common/optional/desktop/common/default.nix +++ b/home/common/optional/desktop/common/default.nix @@ -6,6 +6,7 @@ # Global packages for desktop environments home.packages = [ pkgs.alacritty + pkgs.libnotify pkgs.zathura pkgs.xfce.thunar pkgs.wofi diff --git a/home/common/optional/desktop/hyprland/default.nix b/home/common/optional/desktop/hyprland/default.nix index d73886f..689b2eb 100644 --- a/home/common/optional/desktop/hyprland/default.nix +++ b/home/common/optional/desktop/hyprland/default.nix @@ -9,6 +9,7 @@ ../wallpaper-changer/swww-wallpaper-changer ../common ../waybar.nix + ../mako.nix ]; wayland.windowManager.hyprland = { enable = true; @@ -21,9 +22,12 @@ "systemctl --user start hyprland-session.target" ]; }; - extraConfig = let - monitor = "${toString (builtins.map (m: "monitor=${ m.name },${ toString( m.width ) }x${ toString( m.height ) }@${ toString( m.refreshRate ) },${ toString( m.x ) }x${ toString( m.y ) },${ toString( m.scale ) }\n") config.monitors)}"; - in '' + extraConfig = + let + monitor = "${toString (builtins.map (m: "monitor=${ m.name },${ toString( m.width ) }x${ toString( m.height ) }@${ toString( m.refreshRate ) },${ toString( m.x ) }x${ toString( m.y ) },${ toString( m.scale ) }\n") config.monitors)}"; + active = "rgba(${config.colorScheme.colors.base08}ee)"; + inactive = "rgba(${config.colorScheme.colors.base0C}ee)"; + in '' ${monitor} $terminal = alacritty @@ -51,8 +55,8 @@ gaps_in = 10 gaps_out = 10 border_size = 2 - col.active_border = rgba(22ff00ee) - col.inactive_border = rgba(aecbb4ee) + col.active_border = ${active} + col.inactive_border = ${inactive} layout = dwindle allow_tearing = false } diff --git a/home/common/optional/desktop/mako.nix b/home/common/optional/desktop/mako.nix new file mode 100644 index 0000000..77db759 --- /dev/null +++ b/home/common/optional/desktop/mako.nix @@ -0,0 +1,12 @@ +{ pkgs, config, ... }: +{ + services.mako = { + enable = true; + backgroundColor = "#${config.colorScheme.colors.base00}"; + borderColor = "#${config.colorScheme.colors.base0D}"; + borderRadius = 5; + borderSize = 2; + textColor = "#${config.colorScheme.colors.base05}"; + layer = "overlay"; + }; +} diff --git a/home/semita.nix b/home/semita.nix index 9d87d88..9d60cf1 100644 --- a/home/semita.nix +++ b/home/semita.nix @@ -2,6 +2,7 @@ pkgs, config, lib, + inputs, ... }: { imports = [ @@ -18,6 +19,8 @@ ]; + colorScheme = inputs.nix-colors.colorSchemes.kanagawa; + monitors = [ { name = "DP-1"; From d6dc868814566b294c482a1e83f46f6dac3459be Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 3 Jun 2024 11:05:46 +0100 Subject: [PATCH 07/15] modularise nixvim --- flake.lock | 77 +++- flake.nix | 2 + home/common/core/default.nix | 2 +- home/common/core/nixvim.nix | 383 ------------------ home/common/core/nixvim/default.nix | 43 ++ home/common/core/nixvim/keymaps.nix | 85 ++++ home/common/core/nixvim/options.nix | 35 ++ home/common/core/nixvim/plugins/colorizer.nix | 6 + home/common/core/nixvim/plugins/conform.nix | 21 + home/common/core/nixvim/plugins/default.nix | 30 ++ home/common/core/nixvim/plugins/gitsigns.nix | 35 ++ home/common/core/nixvim/plugins/harpoon.nix | 8 + home/common/core/nixvim/plugins/lsp.nix | 51 +++ home/common/core/nixvim/plugins/lspkind.nix | 13 + home/common/core/nixvim/plugins/lualine.nix | 22 + home/common/core/nixvim/plugins/nvim-tree.nix | 12 + home/common/core/nixvim/plugins/surround.nix | 3 + home/common/core/nixvim/plugins/telescope.nix | 6 + .../common/core/nixvim/plugins/treesitter.nix | 5 + home/common/core/nixvim/theme.nix | 15 + .../optional/desktop/common/default.nix | 2 +- .../optional/desktop/hyprland/default.nix | 4 +- .../optional/desktop/wayland/default.nix | 13 + .../optional/desktop/{ => wayland}/mako.nix | 0 .../swww-wallpaper-changer.nix} | 0 .../optional/desktop/{ => wayland}/waybar.nix | 0 pkgs/default.nix | 2 +- pkgs/sqlfmt.nix | 25 ++ 28 files changed, 506 insertions(+), 394 deletions(-) delete mode 100644 home/common/core/nixvim.nix create mode 100644 home/common/core/nixvim/default.nix create mode 100644 home/common/core/nixvim/keymaps.nix create mode 100644 home/common/core/nixvim/options.nix create mode 100644 home/common/core/nixvim/plugins/colorizer.nix create mode 100644 home/common/core/nixvim/plugins/conform.nix create mode 100644 home/common/core/nixvim/plugins/default.nix create mode 100644 home/common/core/nixvim/plugins/gitsigns.nix create mode 100644 home/common/core/nixvim/plugins/harpoon.nix create mode 100644 home/common/core/nixvim/plugins/lsp.nix create mode 100644 home/common/core/nixvim/plugins/lspkind.nix create mode 100644 home/common/core/nixvim/plugins/lualine.nix create mode 100644 home/common/core/nixvim/plugins/nvim-tree.nix create mode 100644 home/common/core/nixvim/plugins/surround.nix create mode 100644 home/common/core/nixvim/plugins/telescope.nix create mode 100644 home/common/core/nixvim/plugins/treesitter.nix create mode 100644 home/common/core/nixvim/theme.nix create mode 100644 home/common/optional/desktop/wayland/default.nix rename home/common/optional/desktop/{ => wayland}/mako.nix (100%) rename home/common/optional/desktop/{wallpaper-changer/swww-wallpaper-changer/default.nix => wayland/swww-wallpaper-changer.nix} (100%) rename home/common/optional/desktop/{ => wayland}/waybar.nix (100%) create mode 100644 pkgs/sqlfmt.nix diff --git a/flake.lock b/flake.lock index 4032baa..118224c 100644 --- a/flake.lock +++ b/flake.lock @@ -18,7 +18,7 @@ }, "devshell": { "inputs": { - "flake-utils": "flake-utils", + "flake-utils": "flake-utils_2", "nixpkgs": [ "nixvim", "nixpkgs" @@ -125,6 +125,21 @@ } }, "flake-utils": { + "locked": { + "lastModified": 1642700792, + "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { "inputs": { "systems": "systems" }, @@ -247,6 +262,26 @@ "type": "github" } }, + "mach-nix": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "pypi-deps-db": "pypi-deps-db" + }, + "locked": { + "lastModified": 1654084003, + "narHash": "sha256-j/XrVVistvM+Ua+0tNFvO5z83isL+LBgmBi9XppxuKA=", + "owner": "DavHau", + "repo": "mach-nix", + "rev": "7e14360bde07dcae32e5e24f366c83272f52923f", + "type": "github" + }, + "original": { + "id": "mach-nix", + "ref": "3.5.0", + "type": "indirect" + } + }, "nix-colors": { "inputs": { "base16-schemes": "base16-schemes", @@ -305,15 +340,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1717112898, - "narHash": "sha256-7R2ZvOnvd9h8fDd65p0JnB7wXfUvreox3xFdYWd1BnY=", + "lastModified": 1643805626, + "narHash": "sha256-AXLDVMG+UaAGsGSpOtQHPIKB+IZ0KSd9WS77aanGzgc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6132b0f6e344ce2fe34fc051b72fb46e34f668e0", + "rev": "554d2d8aa25b6e583575459c297ec23750adb6cb", "type": "github" }, "original": { "id": "nixpkgs", + "ref": "nixos-unstable", "type": "indirect" } }, @@ -364,6 +400,20 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1717112898, + "narHash": "sha256-7R2ZvOnvd9h8fDd65p0JnB7wXfUvreox3xFdYWd1BnY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6132b0f6e344ce2fe34fc051b72fb46e34f668e0", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, "nixvim": { "inputs": { "devshell": "devshell", @@ -392,14 +442,31 @@ "type": "github" } }, + "pypi-deps-db": { + "flake": false, + "locked": { + "lastModified": 1643877077, + "narHash": "sha256-jv8pIvRFTP919GybOxXE5TfOkrjTbdo9QiCO1TD3ZaY=", + "owner": "DavHau", + "repo": "pypi-deps-db", + "rev": "da53397f0b782b0b18deb72ef8e0fb5aa7c98aa3", + "type": "github" + }, + "original": { + "owner": "DavHau", + "repo": "pypi-deps-db", + "type": "github" + } + }, "root": { "inputs": { "disko": "disko", "home-manager": "home-manager", "impermanence": "impermanence", + "mach-nix": "mach-nix", "nix-colors": "nix-colors", "nix-secrets": "nix-secrets", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_2", "nixpkgs-unstable": "nixpkgs-unstable", "nixvim": "nixvim", "sops-nix": "sops-nix" diff --git a/flake.nix b/flake.nix index 69da67a..212e550 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,8 @@ # Nixpkgs nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + mach-nix.url = "mach-nix/3.5.0"; + # Home manager home-manager = { url = "github:nix-community/home-manager"; diff --git a/home/common/core/default.nix b/home/common/core/default.nix index b3dc7d5..8ac9325 100644 --- a/home/common/core/default.nix +++ b/home/common/core/default.nix @@ -3,7 +3,7 @@ imports = [ inputs.nix-colors.homeManagerModules.default ./zsh.nix - ./nixvim.nix + ./nixvim ./fonts.nix ] ; diff --git a/home/common/core/nixvim.nix b/home/common/core/nixvim.nix deleted file mode 100644 index 9e66742..0000000 --- a/home/common/core/nixvim.nix +++ /dev/null @@ -1,383 +0,0 @@ -{ inputs, pkgs, config, ... }: { - imports = [ - inputs.nixvim.homeManagerModules.nixvim - ]; - - programs.nixvim = { - enable = true; - enableMan = true; # install man pages for nixvim options - - clipboard.register = "unnamedplus"; # use system clipboard instead of internal registers - - colorschemes.kanagawa = { - enable = true; - settings = { - commentStyle = { - italic = true; - }; - dimInactive = true; - terminalColors = true; - theme = "wave"; - transparent = false; - undercurl = true; - }; - }; - - # Base16 colorscheme -# colorschemes.base16 = { -# enable = true; -# colorscheme = { -# base00 = "#${config.colorScheme.colors.base00}"; -# base01 = "#${config.colorScheme.colors.base01}"; -# base02 = "#${config.colorScheme.colors.base02}"; -# base03 = "#${config.colorScheme.colors.base03}"; -# base04 = "#${config.colorScheme.colors.base04}"; -# base05 = "#${config.colorScheme.colors.base05}"; -# base06 = "#${config.colorScheme.colors.base06}"; -# base07 = "#${config.colorScheme.colors.base07}"; -# base08 = "#${config.colorScheme.colors.base08}"; -# base09 = "#${config.colorScheme.colors.base09}"; -# base0A = "#${config.colorScheme.colors.base0A}"; -# base0B = "#${config.colorScheme.colors.base0B}"; -# base0C = "#${config.colorScheme.colors.base0C}"; -# base0D = "#${config.colorScheme.colors.base0D}"; -# base0E = "#${config.colorScheme.colors.base0E}"; -# base0F = "#${config.colorScheme.colors.base0F}"; -# }; -# }; - - opts = { - # - # ========= General Appearance ========= - # - background = ""; - number = true; # show line numbers - relativenumber = true; # show relative linenumbers - laststatus = 0; # Display status line always - history = 1000; # Store lots of :cmdline history - showcmd = true; # Show incomplete cmds down the bottom - showmode = true; # Show current mode down the bottom - autoread = true; # Reload files changed outside vim - lazyredraw = true; # Redraw only when needed - showmatch = true; # highlight matching braces - ruler = true; # show current line and column - visualbell = true; # No sounds - - listchars = "trail:·"; # Display tabs and trailing spaces visually - - # ========= Font ========= - guifont = "NotoSansMono:h9"; # fontname:fontsize - - # ========= Cursor ========= - guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20,n-v-i:blinkon0"; - - # ========= Redirect Temp Files ========= - # backup - backupdir = "$HOME/.local/state/vim/backup//,/tmp//,."; - writebackup = false; - # swap - directory = "$HOME/.local/vim/swap//,/tmp//,."; - - # ================ Indentation ====================== - autoindent = true; - cindent = true; # automatically indent braces - smartindent = true; - smarttab = true; - shiftwidth = 2; - softtabstop = 4; - tabstop = 2; - expandtab = true; - - # ================ Folds ============================ - foldmethod = "indent"; # fold based on indent - foldnestmax = 3; # deepest fold is 3 levels - foldenable = false; # don't fold by default - - # ================ Completion ======================= - wildmode = "list:longest"; - wildmenu = true; # enable ctrl-n and ctrl-p to scroll thru matches - - # stuff to ignore when tab completing - wildignore = "*.o,*.obj,*~,vim/backups,sass-cache,DS_Store,vendor/rails/**,vendor/cache/**,*.gem,log/**,tmp/**,*.png,*.jpg,*.gif"; - - # ================ Scrolling ======================== - scrolloff = 4; # Start scrolling when we're 4 lines away from margins - sidescrolloff = 15; - sidescroll = 1; - - # ================ Searching ======================== - incsearch = true; - hlsearch = true; - ignorecase = true; - smartcase = true; - - # ================ Movement ======================== - backspace = "indent,eol,start"; # allow backspace in insert mode - }; - - # - # ========= UI Plugins ========= - # - - plugins.nvim-colorizer = { - enable = true; - fileTypes = [ "*" ]; - }; - - plugins.treesitter = { - enable = true; - }; - - plugins.lualine = { - enable = true; - theme = "auto"; - componentSeparators = { - left = ""; - right = ""; - }; - sectionSeparators = { - left = ""; - right = ""; - }; - sections = { - lualine_a = [ "mode" ]; - lualine_b = [ "branch" "diff" "diagnostics" ]; - lualine_c = [ "filename" ]; - lualine_x = [ "encoding" "fileformat" "filetype" ]; - lualine_y = [ "progress" ]; - lualine_z = [ "locations" ]; - }; - }; - - # - # ========= File Search ========= - # - plugins.telescope = { - # https://github.com/nvim-telescope/telescope.nvim - enable = true; - extensions.fzy-native.enable = true; - }; - - # ========= File Nav =========== - # - plugins.harpoon = { - enable = true; - keymaps = { - toggleQuickMenu = "b"; - }; - }; - - plugins.nvim-tree = { - enable = true; - view.width = { - min = 30; - max = -1; - padding = 1; - }; - disableNetrw = true; - filters.dotfiles = true; - - }; - - # - # ========== Dev Tools ========= - # - plugins.surround.enable = true; # vim-surround - - plugins.gitsigns = { - enable = true; - settings.signs.add = { - hl = "GitSignsAdd"; - text = " ▎"; - numhl = "GitSignsAddNr"; - linehl = "GitSignsAddLn"; - }; - settings.signs.change = { - hl = "GitSignsChange"; - text = " ▎"; - numhl = "GitSignsChangeNr"; - linehl = "GitSignsChangeLn"; - }; - settings.signs.delete = { - hl = "GitSignsDelete"; - text = " ●"; - numhl = "GitSignsDeleteNr"; - linehl = "GitSignsDeleteLn"; - }; - settings.signs.topdelete = { - hl = "GitSignsDelete"; - text = " ●"; - numhl = "GitSignsDeleteNr"; - linehl = "GitSignsDeleteLn"; - }; - settings.signs.changedelete = { - hl = "GitSignsChange"; - text = " ▎"; - numhl = "GitSignsChangeNr"; - linehl = "GitSignsChangeLn"; - }; - }; - - # Load Plugins that aren't provided as modules by nixvim - extraPlugins = builtins.attrValues { - inherit (pkgs.vimPlugins) - ale - vim-numbertoggle# Use relative number on focused buffer only - vimade# Dim unfocused buffers - vimwiki# Vim Wiki - YouCompleteMe# Code completion engine - vim-dadbod - vim-dadbod-ui - - # Keep vim-devicons as last entry - vim-devicons; - }; - - # ========= Mapleader ========= - globals.mapleader = ";"; - - # - # ========= Key binds ========= - # - keymaps = [ - # Switching windows - { - mode = [ "n" ]; - action = "h"; - key = ""; - options = { - silent = true; - }; - } - { - mode = [ "n" ]; - action = "j"; - key = ""; - options = { - silent = true; - }; - } - { - mode = [ "n" ]; - action = "k"; - key = ""; - options = { - silent = true; - }; - } - { - mode = [ "n" ]; - action = "l"; - key = ""; - options = { - silent = true; - }; - } - # Toggle nvim-tree - { - mode = [ "n" ]; - action = "NvimTreeFindFileToggle"; - key = "tt"; - options = { - silent = true; - }; - } - { - # clear search highlighting - mode = [ "n" ]; - key = ""; - action = "nohlsearch"; - options = { noremap = true; }; - } - - # ========== Telescope Plugin ========= - { - # find files - mode = [ "n" ]; - key = "ff"; - action = "Telescope find_files"; - options = { noremap = true; }; - } - { - # live grep - mode = [ "n" ]; - key = "fg"; - action = "Telescope live_grep"; - options = { noremap = true; }; - } - { - # buffers - mode = [ "n" ]; - key = "fb"; - action = "Telescope buffers"; - options = { noremap = true; }; - } - { - # help tags - mode = [ "n" ]; - key = "fh"; - action = "Telescope help_tags"; - options = { noremap = true; }; - } - - ]; - extraConfigVim = '' - " ================ Persistent Undo ================== - " Keep undo history across sessions, by storing in file. - " Only works all the time. - if has('persistent_undo') - silent !mkdir ~/.vim/backups > /dev/null 2>&1 - set undodir=~/.vim/backups - set undofile - endif - - " ================ Vim Wiki config ================= - " See :h vimwiki_list for info on registering wiki paths - let wiki_0 = {} - let wiki_0.path = '~/dotfiles.wiki/' - let wiki_0.index = 'home' - let wiki_0.syntax = 'markdown' - let wiki_0.ext = '.md' - - " fill spaces in page names with _ in pathing - let wiki_0.links_space_char = '_' - - " ================ Ale ======================== - " linter and fixer packages have to be installed via AUR or pamac - let g:ale_linters = { - \ 'c': ['clang-tidy'], - \ 'python': ['flake8'], - \ 'vim': ['vint'], - \ 'markdown': ['markdownlint'], - \ } - - let g:ale_fixers = { - \ 'c': ['clang-format'], - \ 'javascript': ['prettier', 'eslint'], - \ 'json': ['fixjson', 'prettier'], - \ 'python': ['black', 'isort'], - \ } - - " Set global fixers for all file types except Markdown - " Why? because double spaces at the end of a line in markdown indicate a - " linebreak without creating a new paragraph - function! SetGlobalFixers() - let g:ale_fixers['*'] = ['trim_whitespace', 'remove_trailing_lines'] - endfunction - - augroup GlobalFixers - autocmd! - autocmd VimEnter * call SetGlobalFixers() - augroup END - - " Set buffer-local fixers for Markdown files - augroup MarkdownFixers - autocmd! - autocmd FileType markdown let b:ale_fixers = ['prettier'] - augroup END - - let g:ale_fix_on_save = 1 - ''; - - }; -} diff --git a/home/common/core/nixvim/default.nix b/home/common/core/nixvim/default.nix new file mode 100644 index 0000000..9974999 --- /dev/null +++ b/home/common/core/nixvim/default.nix @@ -0,0 +1,43 @@ +{ inputs, pkgs, ... }: { + imports = [ + inputs.nixvim.homeManagerModules.nixvim + ./plugins + ./options.nix + ./theme.nix + ./keymaps.nix + ]; + + # Install home packages needed for nixvim + home.packages = builtins.attrValues { + inherit (pkgs) + nixpkgs-fmt + prettierd + ;}; + + programs.nixvim = { + enable = true; + enableMan = true; # install man pages for nixvim options + clipboard.register = "unnamedplus"; # use system clipboard instead of internal registers + globals.mapleader = ";"; + + extraConfigVim = '' + " ================ Persistent Undo ================== + " Keep undo history across sessions, by storing in file. + " Only works all the time. + if has('persistent_undo') + silent !mkdir ~/.vim/backups > /dev/null 2>&1 + set undodir=~/.vim/backups + set undofile + endif + + " ================ Vim Wiki config ================= + " See :h vimwiki_list for info on registering wiki paths + let wiki_0 = {} + let wiki_0.path = '~/docs/wiki/' + let wiki_0.index = 'home' + let wiki_0.syntax = 'markdown' + let wiki_0.ext = '.md' + ''; + + }; +} diff --git a/home/common/core/nixvim/keymaps.nix b/home/common/core/nixvim/keymaps.nix new file mode 100644 index 0000000..a206604 --- /dev/null +++ b/home/common/core/nixvim/keymaps.nix @@ -0,0 +1,85 @@ +{ + programs.nixvim.keymaps = [ + # Switching buffers + { + mode = [ "n" ]; + action = "h"; + key = ""; + options = { + silent = true; + }; + } + { + mode = [ "n" ]; + action = "j"; + key = ""; + options = { + silent = true; + }; + } + { + mode = [ "n" ]; + action = "k"; + key = ""; + options = { + silent = true; + }; + } + { + mode = [ "n" ]; + action = "l"; + key = ""; + options = { + silent = true; + }; + } + + # Toggle nvim-tree + { + mode = [ "n" ]; + action = "NvimTreeFindFileToggle"; + key = "tt"; + options = { + silent = true; + }; + } + + # Clear search highlighting + { + mode = [ "n" ]; + key = ""; + action = "nohlsearch"; + options = { noremap = true; }; + } + + # Telescope Plugin + { + # find files + mode = [ "n" ]; + key = "ff"; + action = "Telescope find_files"; + options = { noremap = true; }; + } + { + # live grep + mode = [ "n" ]; + key = "fg"; + action = "Telescope live_grep"; + options = { noremap = true; }; + } + { + # buffers + mode = [ "n" ]; + key = "fb"; + action = "Telescope buffers"; + options = { noremap = true; }; + } + { + # help tags + mode = [ "n" ]; + key = "fh"; + action = "Telescope help_tags"; + options = { noremap = true; }; + } + ]; +} diff --git a/home/common/core/nixvim/options.nix b/home/common/core/nixvim/options.nix new file mode 100644 index 0000000..4b11f93 --- /dev/null +++ b/home/common/core/nixvim/options.nix @@ -0,0 +1,35 @@ +{ + programs.nixvim.opts = { + background = ""; + number = true; # show line numbers + relativenumber = true; # show relative linenumbers + laststatus = 0; # Display status line always + history = 1000; # Store lots of :cmdline history + showcmd = true; # Show incomplete cmds down the bottom + showmode = true; # Show current mode down the bottom + autoread = true; # Reload files changed outside vim + lazyredraw = true; # Redraw only when needed + showmatch = true; # highlight matching braces + ruler = true; # show current line and column + visualbell = true; # No sounds + listchars = "trail:·"; # Display tabs and trailing spaces visually + autoindent = true; + cindent = true; # automatically indent braces + smartindent = true; + smarttab = true; + shiftwidth = 2; + softtabstop = 4; + tabstop = 2; + expandtab = true; + wildmode = "list:longest"; + wildmenu = true; # enable ctrl-n and ctrl-p to scroll thru matches + scrolloff = 4; # Start scrolling when we're 4 lines away from margins + sidescrolloff = 15; + sidescroll = 1; + incsearch = true; + hlsearch = true; + ignorecase = true; + smartcase = true; + backspace = "indent,eol,start"; # allow backspace in insert mode + }; +} diff --git a/home/common/core/nixvim/plugins/colorizer.nix b/home/common/core/nixvim/plugins/colorizer.nix new file mode 100644 index 0000000..1022d83 --- /dev/null +++ b/home/common/core/nixvim/plugins/colorizer.nix @@ -0,0 +1,6 @@ +{ + programs.nixvim.plugins.nvim-colorizer = { + enable = true; + fileTypes = [ "*" ]; + }; +} diff --git a/home/common/core/nixvim/plugins/conform.nix b/home/common/core/nixvim/plugins/conform.nix new file mode 100644 index 0000000..7e27ea0 --- /dev/null +++ b/home/common/core/nixvim/plugins/conform.nix @@ -0,0 +1,21 @@ +{ + programs.nixvim.plugins.conform-nvim = { + enable = true; + formatOnSave = { + lspFallback = true; + timeoutMs = 500; + }; + notifyOnError = true; + formattersByFt = { + html = [["prettierd" "prettier"]]; + css = [["prettierd" "prettier"]]; + javascript = [["prettierd" "prettier"]]; + python = ["black"]; + lua = ["stylua"]; + nix = ["alejandra"]; + markdown = [["prettierd" "prettier"]]; + yaml = ["yamllint" "yamlfmt"]; + sql = ["sqlfmt"]; + }; + }; +} diff --git a/home/common/core/nixvim/plugins/default.nix b/home/common/core/nixvim/plugins/default.nix new file mode 100644 index 0000000..10fac20 --- /dev/null +++ b/home/common/core/nixvim/plugins/default.nix @@ -0,0 +1,30 @@ +{ pkgs, ... }: +{ + imports = [ + ./colorizer.nix + ./conform.nix + ./gitsigns.nix + ./harpoon.nix + ./lsp.nix + ./lualine.nix + ./nvim-tree.nix + ./surround.nix + ./telescope.nix + ./treesitter.nix + ]; + + # Load Plugins that aren't provided as modules by nixvim + programs.nixvim.extraPlugins = builtins.attrValues { + inherit (pkgs.vimPlugins) + ale + vim-numbertoggle + vimwiki + vim-dadbod + vim-dadbod-ui + + # Keep vim-devicons as last entry + vim-devicons; + }; + +} + diff --git a/home/common/core/nixvim/plugins/gitsigns.nix b/home/common/core/nixvim/plugins/gitsigns.nix new file mode 100644 index 0000000..d488015 --- /dev/null +++ b/home/common/core/nixvim/plugins/gitsigns.nix @@ -0,0 +1,35 @@ +{ + programs.nixvim.plugins.gitsigns = { + enable = true; + settings.signs.add = { + hl = "GitSignsAdd"; + text = " ▎"; + numhl = "GitSignsAddNr"; + linehl = "GitSignsAddLn"; + }; + settings.signs.change = { + hl = "GitSignsChange"; + text = " ▎"; + numhl = "GitSignsChangeNr"; + linehl = "GitSignsChangeLn"; + }; + settings.signs.delete = { + hl = "GitSignsDelete"; + text = " ●"; + numhl = "GitSignsDeleteNr"; + linehl = "GitSignsDeleteLn"; + }; + settings.signs.topdelete = { + hl = "GitSignsDelete"; + text = " ●"; + numhl = "GitSignsDeleteNr"; + linehl = "GitSignsDeleteLn"; + }; + settings.signs.changedelete = { + hl = "GitSignsChange"; + text = " ▎"; + numhl = "GitSignsChangeNr"; + linehl = "GitSignsChangeLn"; + }; + }; +} diff --git a/home/common/core/nixvim/plugins/harpoon.nix b/home/common/core/nixvim/plugins/harpoon.nix new file mode 100644 index 0000000..1462b1e --- /dev/null +++ b/home/common/core/nixvim/plugins/harpoon.nix @@ -0,0 +1,8 @@ +{ + programs.nixvim.plugins.harpoon = { + enable = true; + keymaps = { + toggleQuickMenu = "b"; + }; + }; +} diff --git a/home/common/core/nixvim/plugins/lsp.nix b/home/common/core/nixvim/plugins/lsp.nix new file mode 100644 index 0000000..9e6c7d2 --- /dev/null +++ b/home/common/core/nixvim/plugins/lsp.nix @@ -0,0 +1,51 @@ +{ + programs.nixvim.plugins.lsp = { + enable = true; + servers = { + lua-ls = {enable = true;}; + nixd = {enable = true;}; + bashls = {enable = true;}; + pyright = {enable = true;}; + html = {enable = true;}; + yamlls = {enable = true;}; + marksman = {enable = true;}; + #sqls = {enable = true;}; + }; + keymaps = { + lspBuf = { + gd = { + action = "definition"; + desc = "Goto Definition"; + }; + gr = { + action = "references"; + desc = "Goto References"; + }; + gD = { + action = "declaration"; + desc = "Goto Declaration"; + }; + gI = { + action = "implementation"; + desc = "Goto Implementation"; + }; + gT = { + action = "type_definition"; + desc = "Type Definition"; + }; + K = { + action = "hover"; + desc = "Hover"; + }; + "cw" = { + action = "workspace_symbol"; + desc = "Workspace Symbol"; + }; + "cr" = { + action = "rename"; + desc = "Rename"; + }; + }; + }; + }; +} diff --git a/home/common/core/nixvim/plugins/lspkind.nix b/home/common/core/nixvim/plugins/lspkind.nix new file mode 100644 index 0000000..8d7e15a --- /dev/null +++ b/home/common/core/nixvim/plugins/lspkind.nix @@ -0,0 +1,13 @@ +{ + # Add tiny pictograms to lsp + programs.nixvim.plugins.lspkind = { + enable = true; + symbolMap = { + Copilot = ""; + }; + extraOptions = { + maxwidth = 50; + ellipsis_char = "..."; + }; + }; +} diff --git a/home/common/core/nixvim/plugins/lualine.nix b/home/common/core/nixvim/plugins/lualine.nix new file mode 100644 index 0000000..f450ec9 --- /dev/null +++ b/home/common/core/nixvim/plugins/lualine.nix @@ -0,0 +1,22 @@ +{ + programs.nixvim.plugins.lualine = { + enable = true; + theme = "auto"; + componentSeparators = { + left = ""; + right = ""; + }; + sectionSeparators = { + left = ""; + right = ""; + }; + sections = { + lualine_a = [ "mode" ]; + lualine_b = [ "branch" "diff" "diagnostics" ]; + lualine_c = [ "filename" ]; + lualine_x = [ "encoding" "fileformat" "filetype" ]; + lualine_y = [ "progress" ]; + lualine_z = [ "locations" ]; + }; + }; +} diff --git a/home/common/core/nixvim/plugins/nvim-tree.nix b/home/common/core/nixvim/plugins/nvim-tree.nix new file mode 100644 index 0000000..1b55649 --- /dev/null +++ b/home/common/core/nixvim/plugins/nvim-tree.nix @@ -0,0 +1,12 @@ +{ + programs.nixvim.plugins.nvim-tree = { + enable = true; + view.width = { + min = 30; + max = -1; + padding = 1; + }; + disableNetrw = true; + filters.dotfiles = true; + }; +} diff --git a/home/common/core/nixvim/plugins/surround.nix b/home/common/core/nixvim/plugins/surround.nix new file mode 100644 index 0000000..cfee34b --- /dev/null +++ b/home/common/core/nixvim/plugins/surround.nix @@ -0,0 +1,3 @@ +{ + programs.nixvim.plugins.surround.enable = true; # vim-surround +} diff --git a/home/common/core/nixvim/plugins/telescope.nix b/home/common/core/nixvim/plugins/telescope.nix new file mode 100644 index 0000000..9582b09 --- /dev/null +++ b/home/common/core/nixvim/plugins/telescope.nix @@ -0,0 +1,6 @@ +{ + programs.nixvim.plugins.telescope = { + enable = true; + extensions.fzy-native.enable = true; + }; +} diff --git a/home/common/core/nixvim/plugins/treesitter.nix b/home/common/core/nixvim/plugins/treesitter.nix new file mode 100644 index 0000000..511d73a --- /dev/null +++ b/home/common/core/nixvim/plugins/treesitter.nix @@ -0,0 +1,5 @@ +{ + programs.nixvim.plugins.treesitter = { + enable = true; + }; +} diff --git a/home/common/core/nixvim/theme.nix b/home/common/core/nixvim/theme.nix new file mode 100644 index 0000000..82e5781 --- /dev/null +++ b/home/common/core/nixvim/theme.nix @@ -0,0 +1,15 @@ +{ + programs.nixvim.colorschemes.kanagawa = { + enable = true; + settings = { + commentStyle = { + italic = true; + }; + dimInactive = true; + terminalColors = true; + theme = "wave"; + transparent = false; + undercurl = true; + }; + }; +} diff --git a/home/common/optional/desktop/common/default.nix b/home/common/optional/desktop/common/default.nix index 3c8fb38..037c9d6 100644 --- a/home/common/optional/desktop/common/default.nix +++ b/home/common/optional/desktop/common/default.nix @@ -3,13 +3,13 @@ ./firefox.nix ./alacritty.nix ]; + # Global packages for desktop environments home.packages = [ pkgs.alacritty pkgs.libnotify pkgs.zathura pkgs.xfce.thunar - pkgs.wofi pkgs.kcolorchooser ]; } diff --git a/home/common/optional/desktop/hyprland/default.nix b/home/common/optional/desktop/hyprland/default.nix index 689b2eb..3a711a6 100644 --- a/home/common/optional/desktop/hyprland/default.nix +++ b/home/common/optional/desktop/hyprland/default.nix @@ -6,10 +6,8 @@ }: { imports = [ - ../wallpaper-changer/swww-wallpaper-changer ../common - ../waybar.nix - ../mako.nix + ../wayland ]; wayland.windowManager.hyprland = { enable = true; diff --git a/home/common/optional/desktop/wayland/default.nix b/home/common/optional/desktop/wayland/default.nix new file mode 100644 index 0000000..c7e1bc7 --- /dev/null +++ b/home/common/optional/desktop/wayland/default.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: +{ + imports = [ + ./mako.nix + ./waybar.nix + ./swww-wallpaper-changer.nix + ]; + + home.packages = [ + pkgs.wofi + pkgs.wl-clipboard + ]; +} diff --git a/home/common/optional/desktop/mako.nix b/home/common/optional/desktop/wayland/mako.nix similarity index 100% rename from home/common/optional/desktop/mako.nix rename to home/common/optional/desktop/wayland/mako.nix diff --git a/home/common/optional/desktop/wallpaper-changer/swww-wallpaper-changer/default.nix b/home/common/optional/desktop/wayland/swww-wallpaper-changer.nix similarity index 100% rename from home/common/optional/desktop/wallpaper-changer/swww-wallpaper-changer/default.nix rename to home/common/optional/desktop/wayland/swww-wallpaper-changer.nix diff --git a/home/common/optional/desktop/waybar.nix b/home/common/optional/desktop/wayland/waybar.nix similarity index 100% rename from home/common/optional/desktop/waybar.nix rename to home/common/optional/desktop/wayland/waybar.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index 4c7e6bb..b8a775a 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -2,5 +2,5 @@ # You can build them using 'nix build .#example' pkgs: { sddm-theme = pkgs.callPackage ./sddm-theme { }; - wallpaper_changer = pkgs.callPackage ./wallpaper-changer { }; + sqlfmt = pkgs.callPackage ./sqlfmt.nix { }; } diff --git a/pkgs/sqlfmt.nix b/pkgs/sqlfmt.nix new file mode 100644 index 0000000..74238d2 --- /dev/null +++ b/pkgs/sqlfmt.nix @@ -0,0 +1,25 @@ +{ pkgs, fetchFromGitHub, }: + +pkgs.stdenv.mkDerivation { + name = "sqlfmt-v0.21.3"; + src = fetchFromGitHub { + owner = "tconbeer"; + repo = "sqlfmt"; + rev = "v0.21.3"; + sha256 = "1sx8gf13pwsw63v5hfnml18fs2lnb2piigc1d4q8hmiywzmhzf85"; + }; + +#buildInputs = [ pkgs.python3 pkgs.isort pkgs.black pkgs.python311Packages.pytest pkgs.python311Packages.flake8 pkgs.python311Packages.mypy ]; + buildInputs = [ pkgs.python3 pkgs.python311Packages.pip pkgs.isort pkgs.black pkgs.python311Packages.pytest pkgs.python311Packages.flake8 pkgs.python311Packages.mypy ]; + + installPhase = '' + export PYTHONPATH="$\{python.sitePackages}:$PYTHONPATH" + $\{python}/bin/pip install --prefix $out . + ''; + + meta = { + description = "sqlfmt is a tool that autoformats your SQL queries."; + homepage = "https://github.com/tconbeer/sqlfmt"; + license = "Apache 2.0"; + }; +} From e9fde8a82b5fb124ce78f176717ef71bed7e0f1c Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 3 Jun 2024 19:14:07 +0100 Subject: [PATCH 08/15] removed sqlfmt --- flake.lock | 161 ++++++++++++++++++++++++++++++----------------- flake.nix | 4 -- pkgs/default.nix | 1 - pkgs/sqlfmt.nix | 25 -------- 4 files changed, 104 insertions(+), 87 deletions(-) delete mode 100644 pkgs/sqlfmt.nix diff --git a/flake.lock b/flake.lock index 118224c..a4d0caf 100644 --- a/flake.lock +++ b/flake.lock @@ -18,7 +18,7 @@ }, "devshell": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils", "nixpkgs": [ "nixvim", "nixpkgs" @@ -125,12 +125,15 @@ } }, "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1642700792, - "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", "owner": "numtide", "repo": "flake-utils", - "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "type": "github" }, "original": { @@ -141,14 +144,14 @@ }, "flake-utils_2": { "inputs": { - "systems": "systems" + "systems": "systems_2" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -262,26 +265,6 @@ "type": "github" } }, - "mach-nix": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "pypi-deps-db": "pypi-deps-db" - }, - "locked": { - "lastModified": 1654084003, - "narHash": "sha256-j/XrVVistvM+Ua+0tNFvO5z83isL+LBgmBi9XppxuKA=", - "owner": "DavHau", - "repo": "mach-nix", - "rev": "7e14360bde07dcae32e5e24f366c83272f52923f", - "type": "github" - }, - "original": { - "id": "mach-nix", - "ref": "3.5.0", - "type": "indirect" - } - }, "nix-colors": { "inputs": { "base16-schemes": "base16-schemes", @@ -322,6 +305,27 @@ "type": "github" } }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703863825, + "narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "5163432afc817cf8bd1f031418d1869e4c9d5547", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, "nix-secrets": { "flake": false, "locked": { @@ -340,16 +344,15 @@ }, "nixpkgs": { "locked": { - "lastModified": 1643805626, - "narHash": "sha256-AXLDVMG+UaAGsGSpOtQHPIKB+IZ0KSd9WS77aanGzgc=", + "lastModified": 1717112898, + "narHash": "sha256-7R2ZvOnvd9h8fDd65p0JnB7wXfUvreox3xFdYWd1BnY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "554d2d8aa25b6e583575459c297ec23750adb6cb", + "rev": "6132b0f6e344ce2fe34fc051b72fb46e34f668e0", "type": "github" }, "original": { "id": "nixpkgs", - "ref": "nixos-unstable", "type": "indirect" } }, @@ -400,20 +403,6 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1717112898, - "narHash": "sha256-7R2ZvOnvd9h8fDd65p0JnB7wXfUvreox3xFdYWd1BnY=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "6132b0f6e344ce2fe34fc051b72fb46e34f668e0", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, "nixvim": { "inputs": { "devshell": "devshell", @@ -442,19 +431,27 @@ "type": "github" } }, - "pypi-deps-db": { - "flake": false, + "poetry2nix": { + "inputs": { + "flake-utils": "flake-utils_2", + "nix-github-actions": "nix-github-actions", + "nixpkgs": [ + "nixpkgs" + ], + "systems": "systems_3", + "treefmt-nix": "treefmt-nix_2" + }, "locked": { - "lastModified": 1643877077, - "narHash": "sha256-jv8pIvRFTP919GybOxXE5TfOkrjTbdo9QiCO1TD3ZaY=", - "owner": "DavHau", - "repo": "pypi-deps-db", - "rev": "da53397f0b782b0b18deb72ef8e0fb5aa7c98aa3", + "lastModified": 1717250109, + "narHash": "sha256-MTivB5fsfaPtWwcibBhs20hHYEUe9o9bTRXsGJjQRso=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "11e97e742da5b4e43c27cfe13fca904e82fd4e56", "type": "github" }, "original": { - "owner": "DavHau", - "repo": "pypi-deps-db", + "owner": "nix-community", + "repo": "poetry2nix", "type": "github" } }, @@ -463,12 +460,12 @@ "disko": "disko", "home-manager": "home-manager", "impermanence": "impermanence", - "mach-nix": "mach-nix", "nix-colors": "nix-colors", "nix-secrets": "nix-secrets", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", "nixvim": "nixvim", + "poetry2nix": "poetry2nix", "sops-nix": "sops-nix" } }, @@ -508,6 +505,35 @@ "type": "github" } }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "id": "systems", + "type": "indirect" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ @@ -528,6 +554,27 @@ "repo": "treefmt-nix", "type": "github" } + }, + "treefmt-nix_2": { + "inputs": { + "nixpkgs": [ + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1717182148, + "narHash": "sha256-Hi09/RoizxubRf3PHToT2Nm7TL8B/abSVa6q82uEgNI=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "03b982b77df58d5974c61c6022085bafe780c1cf", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 212e550..7d08100 100644 --- a/flake.nix +++ b/flake.nix @@ -5,8 +5,6 @@ # Nixpkgs nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; - mach-nix.url = "mach-nix/3.5.0"; - # Home manager home-manager = { url = "github:nix-community/home-manager"; @@ -51,8 +49,6 @@ self, nixpkgs, home-manager, - disko, - #impermanence, ... } @ inputs: let diff --git a/pkgs/default.nix b/pkgs/default.nix index b8a775a..591d772 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -2,5 +2,4 @@ # You can build them using 'nix build .#example' pkgs: { sddm-theme = pkgs.callPackage ./sddm-theme { }; - sqlfmt = pkgs.callPackage ./sqlfmt.nix { }; } diff --git a/pkgs/sqlfmt.nix b/pkgs/sqlfmt.nix deleted file mode 100644 index 74238d2..0000000 --- a/pkgs/sqlfmt.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ pkgs, fetchFromGitHub, }: - -pkgs.stdenv.mkDerivation { - name = "sqlfmt-v0.21.3"; - src = fetchFromGitHub { - owner = "tconbeer"; - repo = "sqlfmt"; - rev = "v0.21.3"; - sha256 = "1sx8gf13pwsw63v5hfnml18fs2lnb2piigc1d4q8hmiywzmhzf85"; - }; - -#buildInputs = [ pkgs.python3 pkgs.isort pkgs.black pkgs.python311Packages.pytest pkgs.python311Packages.flake8 pkgs.python311Packages.mypy ]; - buildInputs = [ pkgs.python3 pkgs.python311Packages.pip pkgs.isort pkgs.black pkgs.python311Packages.pytest pkgs.python311Packages.flake8 pkgs.python311Packages.mypy ]; - - installPhase = '' - export PYTHONPATH="$\{python.sitePackages}:$PYTHONPATH" - $\{python}/bin/pip install --prefix $out . - ''; - - meta = { - description = "sqlfmt is a tool that autoformats your SQL queries."; - homepage = "https://github.com/tconbeer/sqlfmt"; - license = "Apache 2.0"; - }; -} From 9b205b2c1c5eeed98da4753af355c57b4c71dcd9 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 4 Jun 2024 01:32:43 +0100 Subject: [PATCH 09/15] added sqlfmt --- flake.lock | 82 ++++++++++++++++++++++++++++-- flake.nix | 3 ++ hosts/common/users/sam/default.nix | 1 + 3 files changed, 82 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index a4d0caf..09594a7 100644 --- a/flake.lock +++ b/flake.lock @@ -160,6 +160,24 @@ "type": "github" } }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "git-hooks": { "inputs": { "flake-compat": "flake-compat_2", @@ -308,6 +326,7 @@ "nix-github-actions": { "inputs": { "nixpkgs": [ + "sqlfmt", "poetry2nix", "nixpkgs" ] @@ -403,6 +422,22 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1717394157, + "narHash": "sha256-xI6YE/VM1w5DQKxPK6VSEdV4JOx72LWIWx8+fV424L4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "518daacfe2ee732432b4a7dac19b72eda037d44d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable-small", + "repo": "nixpkgs", + "type": "github" + } + }, "nixvim": { "inputs": { "devshell": "devshell", @@ -433,12 +468,13 @@ }, "poetry2nix": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_3", "nix-github-actions": "nix-github-actions", "nixpkgs": [ + "sqlfmt", "nixpkgs" ], - "systems": "systems_3", + "systems": "systems_4", "treefmt-nix": "treefmt-nix_2" }, "locked": { @@ -465,8 +501,8 @@ "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", "nixvim": "nixvim", - "poetry2nix": "poetry2nix", - "sops-nix": "sops-nix" + "sops-nix": "sops-nix", + "sqlfmt": "sqlfmt" } }, "sops-nix": { @@ -490,6 +526,28 @@ "type": "github" } }, + "sqlfmt": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2", + "poetry2nix": "poetry2nix" + }, + "locked": { + "dir": "sqlfmt", + "lastModified": 1717438253, + "narHash": "sha256-esXZz2AE95t/D8lptEVORys0g68wVuIrFrqmdXsSbXI=", + "ref": "refs/heads/master", + "rev": "5d1d966349841b18d7933843ed96a5a4fb300075", + "revCount": 1, + "type": "git", + "url": "https://git.bitlab21.com/sam/flake-packages?dir=sqlfmt" + }, + "original": { + "dir": "sqlfmt", + "type": "git", + "url": "https://git.bitlab21.com/sam/flake-packages?dir=sqlfmt" + } + }, "systems": { "locked": { "lastModified": 1681028828, @@ -521,6 +579,21 @@ } }, "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_4": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", @@ -558,6 +631,7 @@ "treefmt-nix_2": { "inputs": { "nixpkgs": [ + "sqlfmt", "poetry2nix", "nixpkgs" ] diff --git a/flake.nix b/flake.nix index 7d08100..ef35c23 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,9 @@ # Nixpkgs nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + # Import personal packages repo + sqlfmt.url = "git+https://git.bitlab21.com/sam/flake-packages?dir=sqlfmt"; + # Home manager home-manager = { url = "github:nix-community/home-manager"; diff --git a/hosts/common/users/sam/default.nix b/hosts/common/users/sam/default.nix index 0548e85..827f255 100644 --- a/hosts/common/users/sam/default.nix +++ b/hosts/common/users/sam/default.nix @@ -66,5 +66,6 @@ in }; environment.systemPackages = [ + inputs.sqlfmt.packages.x86_64-linux.sqlfmt ]; } From c754aa2fba8e9660f7a98e6f849cdcdb57a5bdeb Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 4 Jun 2024 11:47:56 +0100 Subject: [PATCH 10/15] added new plugins to nixvim --- home/common/core/nixvim/default.nix | 3 +- home/common/core/nixvim/plugins/cmp.nix | 105 ++++++++++++++++++++ home/common/core/nixvim/plugins/default.nix | 16 +-- home/common/core/nixvim/plugins/luasnip.nix | 15 +++ 4 files changed, 131 insertions(+), 8 deletions(-) create mode 100644 home/common/core/nixvim/plugins/cmp.nix create mode 100644 home/common/core/nixvim/plugins/luasnip.nix diff --git a/home/common/core/nixvim/default.nix b/home/common/core/nixvim/default.nix index 9974999..32c6445 100644 --- a/home/common/core/nixvim/default.nix +++ b/home/common/core/nixvim/default.nix @@ -12,7 +12,8 @@ inherit (pkgs) nixpkgs-fmt prettierd - ;}; + ; + }; programs.nixvim = { enable = true; diff --git a/home/common/core/nixvim/plugins/cmp.nix b/home/common/core/nixvim/plugins/cmp.nix new file mode 100644 index 0000000..e1dc978 --- /dev/null +++ b/home/common/core/nixvim/plugins/cmp.nix @@ -0,0 +1,105 @@ +{ + programs.nixvim.plugins = { + cmp-emoji = { enable = true; }; + cmp = { + enable = true; + settings = { + autoEnableSources = true; + experimental = { ghost_text = true; }; + performance = { + debounce = 60; + fetchingTimeout = 200; + maxViewEntries = 30; + }; + snippet = { expand = "luasnip"; }; + formatting = { + fields = [ "kind" "abbr" "menu" ]; + }; + sources = [ + { name = "nvim_lsp"; } + { name = "nvim_lua"; } + { name = "luasnip"; } + { name = "buffer"; } + { name = "path"; } + { name = "vim-dadbod-completion"; } + ]; + window = { + completion = { border = "solid"; }; + documentation = { border = "solid"; }; + }; + mapping = { + "" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; + "" = "cmp.mapping.select_next_item()"; + "" = "cmp.mapping.select_prev_item()"; + "" = "cmp.mapping.abort()"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.confirm({ select = true })"; + "" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })"; + }; + }; + }; + cmp-nvim-lsp = { enable = true; }; # lsp + cmp-buffer = { enable = true; }; + cmp-path = { enable = true; }; # file system paths + cmp_luasnip = { enable = true; }; # snippets + cmp-cmdline = { enable = false; }; # autocomplete for cmdline + }; + programs.nixvim.extraConfigLua = '' + luasnip = require("luasnip") + kind_icons = { + Text = "󰊄", + Method = "", + Function = "󰡱", + Constructor = "", + Field = "", + Variable = "󱀍", + Class = "", + Interface = "", + Module = "󰕳", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", + } + + local cmp = require'cmp' + + -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({'/', "?" }, { + sources = { + { name = 'buffer' } + } + }) + + -- Set configuration for specific filetype. + cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. + }, { + { name = 'buffer' }, + }) + }) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }), + }) ''; +} diff --git a/home/common/core/nixvim/plugins/default.nix b/home/common/core/nixvim/plugins/default.nix index 10fac20..b2196e6 100644 --- a/home/common/core/nixvim/plugins/default.nix +++ b/home/common/core/nixvim/plugins/default.nix @@ -1,16 +1,18 @@ { pkgs, ... }: { imports = [ + ./cmp.nix ./colorizer.nix ./conform.nix - ./gitsigns.nix - ./harpoon.nix + ./gitsigns.nix + ./harpoon.nix ./lsp.nix - ./lualine.nix - ./nvim-tree.nix - ./surround.nix - ./telescope.nix - ./treesitter.nix + ./lualine.nix + ./luasnip.nix + ./nvim-tree.nix + ./surround.nix + ./telescope.nix + ./treesitter.nix ]; # Load Plugins that aren't provided as modules by nixvim diff --git a/home/common/core/nixvim/plugins/luasnip.nix b/home/common/core/nixvim/plugins/luasnip.nix new file mode 100644 index 0000000..ef93822 --- /dev/null +++ b/home/common/core/nixvim/plugins/luasnip.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: { + programs.nixvim.plugins.luasnip = { + enable = true; + extraConfig = { + enable_autosnippets = true; + store_selection_keys = ""; + }; + fromVscode = [ + { + lazyLoad = true; + paths = "${pkgs.vimPlugins.friendly-snippets}"; + } + ]; + }; +} From a0f084a4652695cf947b2c755cfb102a7d7dce82 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 4 Jun 2024 12:37:26 +0100 Subject: [PATCH 11/15] nixvim buffer_manager --- home/common/core/nixvim/plugins/default.nix | 72 ++++++++++++++++++--- home/common/core/nixvim/plugins/harpoon.nix | 2 +- 2 files changed, 63 insertions(+), 11 deletions(-) diff --git a/home/common/core/nixvim/plugins/default.nix b/home/common/core/nixvim/plugins/default.nix index b2196e6..73d8f02 100644 --- a/home/common/core/nixvim/plugins/default.nix +++ b/home/common/core/nixvim/plugins/default.nix @@ -16,17 +16,69 @@ ]; # Load Plugins that aren't provided as modules by nixvim - programs.nixvim.extraPlugins = builtins.attrValues { - inherit (pkgs.vimPlugins) - ale - vim-numbertoggle - vimwiki - vim-dadbod - vim-dadbod-ui + programs.nixvim.extraPlugins = [ + pkgs.vimPlugins.vim-numbertoggle + pkgs.vimPlugins.vimwiki + pkgs.vimPlugins.vim-dadbod + pkgs.vimPlugins.vim-dadbod-ui - # Keep vim-devicons as last entry - vim-devicons; - }; + # Keep vim-devicons as last entry + pkgs.vimPlugins.vim-devicons + (pkgs.vimUtils.buildVimPlugin + { + name = "buffer_manager.nvim"; + src = pkgs.fetchFromGitHub { + owner = "j-morano"; + repo = "buffer_manager.nvim"; + rev = "fd36131"; + sha256 = "sha256-abe9ZGmL7U9rC+LxC3LO5/bOn8lHke1FCKO0V3TZGs0="; + }; + }) + ]; + programs.nixvim.extraConfigLua = '' + -- buffer_manager.nvim + local opts = {noremap = true} + + require("buffer_manager").setup( + { + line_keys = "1234567890", + select_menu_item_commands = { + edit = { + key = "", + command = "edit" + } + }, + focus_alternate_buffer = true, + short_file_names = false, + short_term_names = true, + height = 15, + width = 0.8, + loop_nav = true, + highlight = "", + win_extra_options = {}, + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + order_buffers = "lastused", + show_indicators = "before", + } + ) + + -- Custom color for modified buffers + vim.api.nvim_set_hl(0, "BufferManagerModified", { fg = "#988100" }) + + local bmui = require("buffer_manager.ui") + vim.keymap.set('n', 'b', bmui.toggle_quick_menu, opts) + vim.keymap.set('n', 'n', bmui.nav_next, opts) + vim.keymap.set('n', 'p', bmui.nav_prev, opts) + + local keys="1234567890" + for i = 1, #keys do + local key = keys:sub(i,i) + vim.keymap.set('n', string.format('%s', key), + function () bmui.nav_file(i) end, + opts + ) + end + ''; } diff --git a/home/common/core/nixvim/plugins/harpoon.nix b/home/common/core/nixvim/plugins/harpoon.nix index 1462b1e..0080b57 100644 --- a/home/common/core/nixvim/plugins/harpoon.nix +++ b/home/common/core/nixvim/plugins/harpoon.nix @@ -2,7 +2,7 @@ programs.nixvim.plugins.harpoon = { enable = true; keymaps = { - toggleQuickMenu = "b"; + toggleQuickMenu = "h"; }; }; } From cd7b3c9d0d0e0c54cc2532714fc929c2491590b3 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 5 Jun 2024 12:30:55 +0100 Subject: [PATCH 12/15] dbui connections.json as sops-nix template --- flake.lock | 74 ++++++++++--------------- home/common/core/default.nix | 26 +++++---- home/common/core/nixvim/plugins/cmp.nix | 14 +++++ home/common/optional/sops.nix | 18 ++++-- home/semita.nix | 8 +-- home/users/sam/default.nix | 18 +++--- hosts/common/users/sam/default.nix | 41 ++++++++++---- 7 files changed, 110 insertions(+), 89 deletions(-) diff --git a/flake.lock b/flake.lock index 09594a7..b32a886 100644 --- a/flake.lock +++ b/flake.lock @@ -45,11 +45,11 @@ ] }, "locked": { - "lastModified": 1717177033, - "narHash": "sha256-G3CZJafCO8WDy3dyA2EhpUJEmzd5gMJ2IdItAg0Hijw=", + "lastModified": 1717574802, + "narHash": "sha256-TprJdvfwdjj3co7CGZ4jPIlAdZPFwYrQjamvt2B2L4g=", "owner": "nix-community", "repo": "disko", - "rev": "0274af4c92531ebfba4a5bd493251a143bc51f3c", + "rev": "7fc7009c892509b9bf81cb73c6575f3f9e6321f5", "type": "github" }, "original": { @@ -109,21 +109,6 @@ "type": "github" } }, - "flake-root": { - "locked": { - "lastModified": 1713493429, - "narHash": "sha256-ztz8JQkI08tjKnsTpfLqzWoKFQF4JGu2LRz8bkdnYUk=", - "owner": "srid", - "repo": "flake-root", - "rev": "bc748b93b86ee76e2032eecda33440ceb2532fcd", - "type": "github" - }, - "original": { - "owner": "srid", - "repo": "flake-root", - "type": "github" - } - }, "flake-utils": { "inputs": { "systems": "systems" @@ -234,11 +219,11 @@ ] }, "locked": { - "lastModified": 1717097707, - "narHash": "sha256-HC5vJ3oYsjwsCaSbkIPv80e4ebJpNvFKQTBOGlHvjLs=", + "lastModified": 1717525419, + "narHash": "sha256-5z2422pzWnPXHgq2ms8lcCfttM0dz+hg+x1pCcNkAws=", "owner": "nix-community", "repo": "home-manager", - "rev": "0eb314b4f0ba337e88123e0b1e57ef58346aafd9", + "rev": "a7117efb3725e6197dd95424136f79147aa35e5b", "type": "github" }, "original": { @@ -348,11 +333,11 @@ "nix-secrets": { "flake": false, "locked": { - "lastModified": 1717190678, - "narHash": "sha256-Dz7bJS76gW/yhTBx6n96d/ZN03gsTNY+GCwZXaMlKTg=", + "lastModified": 1717581732, + "narHash": "sha256-mBkVq89pmsOGRIBVANJYILV81YXHBmK3xHbhqxvoR8s=", "ref": "refs/heads/master", - "rev": "6e50c8300596629cee6aa72cbb3ab606e68660e8", - "revCount": 83, + "rev": "0d2708ad195b6ec5e8ede2a6bc3876c855710d26", + "revCount": 86, "type": "git", "url": "ssh://git@git.bitlab21.com/sam/nix-secrets.git" }, @@ -363,12 +348,10 @@ }, "nixpkgs": { "locked": { - "lastModified": 1717112898, + "lastModified": 0, "narHash": "sha256-7R2ZvOnvd9h8fDd65p0JnB7wXfUvreox3xFdYWd1BnY=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "6132b0f6e344ce2fe34fc051b72fb46e34f668e0", - "type": "github" + "path": "/nix/store/l4wskml8vcs49mg6w9la715cx10sviwh-source", + "type": "path" }, "original": { "id": "nixpkgs", @@ -392,11 +375,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1716655032, - "narHash": "sha256-kQ25DAiCGigsNR/Quxm3v+JGXAEXZ8I7RAF4U94bGzE=", + "lastModified": 1717265169, + "narHash": "sha256-IITcGd6xpNoyq9SZBigCkv4+qMHSqot0RDPR4xsZ2CA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "59a450646ec8ee0397f5fa54a08573e8240eb91f", + "rev": "3b1b4895b2c5f9f5544d02132896aeb9ceea77bc", "type": "github" }, "original": { @@ -408,11 +391,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1716948383, - "narHash": "sha256-SzDKxseEcHR5KzPXLwsemyTR/kaM9whxeiJohbL04rs=", + "lastModified": 1717196966, + "narHash": "sha256-yZKhxVIKd2lsbOqYd5iDoUIwsRZFqE87smE2Vzf6Ck0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "ad57eef4ef0659193044870c731987a6df5cf56b", + "rev": "57610d2f8f0937f39dbd72251e9614b1561942d8", "type": "github" }, "original": { @@ -424,11 +407,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1717394157, - "narHash": "sha256-xI6YE/VM1w5DQKxPK6VSEdV4JOx72LWIWx8+fV424L4=", + "lastModified": 1717503908, + "narHash": "sha256-hsxbTeO6Dhobc2kELDwCgRJT9J5TotL6fS8z5P+OskI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "518daacfe2ee732432b4a7dac19b72eda037d44d", + "rev": "50a127f8fccd0d24712c8ab146ca251f27cc4cb0", "type": "github" }, "original": { @@ -443,7 +426,6 @@ "devshell": "devshell", "flake-compat": "flake-compat", "flake-parts": "flake-parts", - "flake-root": "flake-root", "git-hooks": "git-hooks", "home-manager": "home-manager_2", "nix-darwin": "nix-darwin", @@ -453,11 +435,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1717188043, - "narHash": "sha256-qg8Tq7OcKtc0BS4RVUYrMZ+KofgMv6DiXOnqz7TN8CA=", + "lastModified": 1717574948, + "narHash": "sha256-8C2S1WWC4ty1LePzFWp+D6re/pggCJj9tWslddJ/wUw=", "owner": "nix-community", "repo": "nixvim", - "rev": "1bbd58b6b293840716355e63fb3d5aa5af00d389", + "rev": "a54ee8ad64c91b587c3460126bad25a441c1118c", "type": "github" }, "original": { @@ -513,11 +495,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1716692524, - "narHash": "sha256-sALodaA7Zkp/JD6ehgwc0UCBrSBfB4cX66uFGTsqeFU=", + "lastModified": 1717455931, + "narHash": "sha256-8Q6mKSsto8gaGczXd4G0lvawdAYLa5Dlh3/g4hl5CaM=", "owner": "mic92", "repo": "sops-nix", - "rev": "962797a8d7f15ed7033031731d0bb77244839960", + "rev": "d4555e80d80d2fa77f0a44201ca299f9602492a0", "type": "github" }, "original": { diff --git a/home/common/core/default.nix b/home/common/core/default.nix index 8ac9325..3de98b8 100644 --- a/home/common/core/default.nix +++ b/home/common/core/default.nix @@ -1,24 +1,26 @@ -{ config, lib, pkgs, outputs, inputs, ... }: +{ pkgs, inputs, ... }: { imports = [ inputs.nix-colors.homeManagerModules.default ./zsh.nix ./nixvim ./fonts.nix - ] ; + ]; # Global home packages without config go here (for all hosts and users) home.packages = builtins.attrValues { inherit (pkgs) - ripgrep - fzf - eza - pciutils - tree - jq - coreutils - btop - htop - ;}; + ripgrep + fzf + eza + pciutils + tree + jq + coreutils + btop + htop + postgresql + ; + }; home.stateVersion = "23.11"; } diff --git a/home/common/core/nixvim/plugins/cmp.nix b/home/common/core/nixvim/plugins/cmp.nix index e1dc978..44475cb 100644 --- a/home/common/core/nixvim/plugins/cmp.nix +++ b/home/common/core/nixvim/plugins/cmp.nix @@ -14,6 +14,20 @@ snippet = { expand = "luasnip"; }; formatting = { fields = [ "kind" "abbr" "menu" ]; + format = '' + function(entry, vim_item) + vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) + vim_item.menu = ({ + nvim_lsp = "[LSP]", + nvim_lua = "[Lua]", + luasnip = "[Snippet]", + buffer = "[Buffer]", + path = "[Path]", + ["vim-dadbod-completion"] = "[SQL-dadbod]" + })[entry.source.name] + return vim_item + end, + ''; }; sources = [ { name = "nvim_lsp"; } diff --git a/home/common/optional/sops.nix b/home/common/optional/sops.nix index 345bafd..935bd1e 100644 --- a/home/common/optional/sops.nix +++ b/home/common/optional/sops.nix @@ -1,10 +1,9 @@ -{ inputs, config, osConfig, ... }: +{ inputs, config, ... }: let secretsDirectory = builtins.toString inputs.nix-secrets; secretsFile = "${secretsDirectory}/secrets.yaml"; homeDirectory = config.home.homeDirectory; username = config.home.username; - hostname = osConfig.networking.hostName; in { imports = [ @@ -12,11 +11,18 @@ in ]; sops = { - age.sshKeyPaths = ["${homeDirectory}/.ssh/id_ed25519"]; + age = { + sshKeyPaths = [ "${homeDirectory}/.ssh/id_ed25519" ]; + generateKey = true; + keyFile = "/home/${username}/.config/sops/age/keys.txt"; + }; defaultSopsFile = "${secretsFile}"; validateSopsFiles = false; - secrets."ssh_keys/deploy_key/id_ed25519" = { - path = "/home/${username}/.ssh/deploy_key-ssh-ed25519"; - }; + + secrets = { + "ssh_keys/deploy_key/id_ed25519" = { + path = "/home/${username}/.ssh/deploy_key-ssh-ed25519"; + }; + }; }; } diff --git a/home/semita.nix b/home/semita.nix index 9d60cf1..c610e9b 100644 --- a/home/semita.nix +++ b/home/semita.nix @@ -1,9 +1,5 @@ -{ - pkgs, - config, - lib, - inputs, - ... +{ inputs +, ... }: { imports = [ # Import users diff --git a/home/users/sam/default.nix b/home/users/sam/default.nix index 05ea141..beeb764 100644 --- a/home/users/sam/default.nix +++ b/home/users/sam/default.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, outputs, ... }: +{ pkgs, outputs, ... }: { home.username = "sam"; @@ -16,8 +16,8 @@ enable = true; matchBlocks = { "git.bitlab21.com" = { - identitiesOnly = true; - identityFile = [ "~/.ssh/id_ed25519"]; + identitiesOnly = true; + identityFile = [ "~/.ssh/id_ed25519" ]; }; }; }; @@ -25,7 +25,7 @@ home.sessionPath = [ ]; - xdg.userDirs = { + xdg.userDirs = { enable = true; createDirectories = true; desktop = null; @@ -55,11 +55,11 @@ qt.style.package = pkgs.adwaita-qt; home.sessionVariables = { - EDITOR="nvim"; - TERMINAL="alacritty"; - READER="zathura"; - IMAGE_VIEWER=""; - IMAGE_EDITOR=""; + EDITOR = "nvim"; + TERMINAL = "alacritty"; + READER = "zathura"; + IMAGE_VIEWER = ""; + IMAGE_EDITOR = ""; }; } diff --git a/hosts/common/users/sam/default.nix b/hosts/common/users/sam/default.nix index 827f255..4ee6230 100644 --- a/hosts/common/users/sam/default.nix +++ b/hosts/common/users/sam/default.nix @@ -29,25 +29,46 @@ in path = "/home/${username}/.ssh/id_ed25519"; mode = "0600"; owner = "${username}"; - }; + }; "ssh_keys/${username}/id_ed25519.pub" = { path = "/home/${username}/.ssh/id_ed25519.pub"; mode = "0644"; owner = "${username}"; }; + "passwords/postgres" = { }; + }; + + # Setup postgres connections for db_ui + # Should be part of home-manager - waiting for templates functionality + # See here https://github.com/Mic92/sops-nix/issues/423 and here https://github.com/Mic92/sops-nix/issues/498 + # TODO migrate db_ui connection to home-manager when issue 423 and 498 are resolved in github:Mic92/sops-nix + sops.templates."dbui_connections.json" = { + path = "/home/${username}/.local/share/db_ui/connections.json"; + owner = "${username}"; + mode = "0600"; + content = '' + [ + { + "url": "postgresql://postgres:${config.sops.placeholder."passwords/postgres"}@10.0.10.100/btc_models", + "name": "btc_models" + } + ] + ''; }; # The containing ssh folders are created as root and if this is the first ~/.ssh/ entry when writing keys, # the ownership is busted and home-manager can't target because it can't write into .ssh... # FIXME: We might not need this depending on how https://github.com/Mic92/sops-nix/issues/381 is fixed - system.activationScripts.sopsSetSshOwnwership = let - sshFolder = "/home/${username}/.ssh"; - user = config.users.users.${username}.name; - group = config.users.users.${username}.group; - in '' - mkdir -p ${sshFolder} || true - chown -R ${user}:${group} /home/${username}/.ssh - ''; + system.activationScripts.sopsSetSshOwnwership = + let + sshFolder = "/home/${username}/.ssh"; + user = config.users.users.${username}.name; + group = config.users.users.${username}.group; + in + '' + mkdir -p ${sshFolder} || true + chown -R ${user}:${group} /home/${username}/.ssh + ''; environment.persistence."/persist" = { directories = [ @@ -66,6 +87,6 @@ in }; environment.systemPackages = [ - inputs.sqlfmt.packages.x86_64-linux.sqlfmt + inputs.sqlfmt.packages.x86_64-linux.sqlfmt ]; } From bd8fbdacd041bde24404ee82d43e5fe5372158c5 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 5 Jun 2024 12:36:22 +0100 Subject: [PATCH 13/15] dadbod-completion --- home/common/core/nixvim/plugins/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/home/common/core/nixvim/plugins/default.nix b/home/common/core/nixvim/plugins/default.nix index 73d8f02..6aafbd2 100644 --- a/home/common/core/nixvim/plugins/default.nix +++ b/home/common/core/nixvim/plugins/default.nix @@ -21,6 +21,7 @@ pkgs.vimPlugins.vimwiki pkgs.vimPlugins.vim-dadbod pkgs.vimPlugins.vim-dadbod-ui + pkgs.vimPlugins.vim-dadbod-completion # Keep vim-devicons as last entry pkgs.vimPlugins.vim-devicons From f60f4bee7af763803f7456ec1226cfd34ddb18b7 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 5 Jun 2024 23:27:36 +0100 Subject: [PATCH 14/15] waybar ricing and alacritty transparency --- home/common/core/nixvim/theme.nix | 2 +- .../optional/desktop/common/alacritty.nix | 15 +- .../optional/desktop/hyprland/default.nix | 32 +-- .../wayland/swww-wallpaper-changer.nix | 50 ++-- .../optional/desktop/wayland/waybar.nix | 242 +++++++++--------- pkgs/sddm-theme/default.nix | 9 +- 6 files changed, 171 insertions(+), 179 deletions(-) diff --git a/home/common/core/nixvim/theme.nix b/home/common/core/nixvim/theme.nix index 82e5781..7dd7112 100644 --- a/home/common/core/nixvim/theme.nix +++ b/home/common/core/nixvim/theme.nix @@ -8,7 +8,7 @@ dimInactive = true; terminalColors = true; theme = "wave"; - transparent = false; + transparent = true; undercurl = true; }; }; diff --git a/home/common/optional/desktop/common/alacritty.nix b/home/common/optional/desktop/common/alacritty.nix index 20ecd39..075811c 100644 --- a/home/common/optional/desktop/common/alacritty.nix +++ b/home/common/optional/desktop/common/alacritty.nix @@ -1,7 +1,4 @@ -{ config, pkgs, lib, ... }: -let - user = config.home.username; -in +{ config, pkgs, ... }: { programs.alacritty = { enable = true; @@ -38,9 +35,13 @@ in }; }; - window.padding = { - x = 5; - y = 5; + window = { + padding = { + x = 5; + y = 5; + }; + blur = true; + opacity = 0.9; }; shell.program = "${pkgs.zsh}/bin/zsh"; diff --git a/home/common/optional/desktop/hyprland/default.nix b/home/common/optional/desktop/hyprland/default.nix index 3a711a6..524fd37 100644 --- a/home/common/optional/desktop/hyprland/default.nix +++ b/home/common/optional/desktop/hyprland/default.nix @@ -1,8 +1,7 @@ -{ - lib, - config, - pkgs, - ... +{ lib +, config +, pkgs +, ... }: { imports = [ @@ -12,20 +11,21 @@ wayland.windowManager.hyprland = { enable = true; systemd = { - variables = ["--all"]; - enable = true; - # Same as default, but stop graphical-session too - extraCommands = lib.mkBefore [ - "systemctl --user stop graphical-session.target" - "systemctl --user start hyprland-session.target" - ]; + variables = [ "--all" ]; + enable = true; + # Same as default, but stop graphical-session too + extraCommands = lib.mkBefore [ + "systemctl --user stop graphical-session.target" + "systemctl --user start hyprland-session.target" + ]; }; extraConfig = let monitor = "${toString (builtins.map (m: "monitor=${ m.name },${ toString( m.width ) }x${ toString( m.height ) }@${ toString( m.refreshRate ) },${ toString( m.x ) }x${ toString( m.y ) },${ toString( m.scale ) }\n") config.monitors)}"; active = "rgba(${config.colorScheme.colors.base08}ee)"; inactive = "rgba(${config.colorScheme.colors.base0C}ee)"; - in '' + in + '' ${monitor} $terminal = alacritty @@ -155,7 +155,7 @@ bindm = $mainMod, mouse:272, movewindow bindm = $mainMod, mouse:273, resizewindow - exec-once=bash ~/.config/hypr/start.sh + exec-once=swww-wallpaper-changer ''; - }; - } + }; +} diff --git a/home/common/optional/desktop/wayland/swww-wallpaper-changer.nix b/home/common/optional/desktop/wayland/swww-wallpaper-changer.nix index d0b135f..af7d4b4 100644 --- a/home/common/optional/desktop/wayland/swww-wallpaper-changer.nix +++ b/home/common/optional/desktop/wayland/swww-wallpaper-changer.nix @@ -1,37 +1,19 @@ +{ pkgs, ... }: { - pkgs, - ... -}: -{ - systemd.user.services.wallpaper-changer = { - Unit = { - Description = "Script to change wallpaper using swww"; - PartOf = [ "hyprland-session.target" ]; - After = [ "hyprland-session.target" ]; # or "wayland.target", depending on your system setup - }; - Install = { - WantedBy = [ "default.target" ]; - }; - Service = { - Type = [ "simple" ]; - ExecStart = "${pkgs.writeShellScript "swww-wallpaper-changer" '' - export WAYLAND_DISPLAY="wayland-1" - wallpaper_dir="$HOME/.local/share/bg/" - [ -d "$wallpaper_dir" ] || mkdir -p "$wallpaper_dir" + home.packages = with pkgs; [ + (writeShellScriptBin "swww-wallpaper-changer" '' + export WAYLAND_DISPLAY="wayland-1" + wallpaper_dir="$HOME/.local/share/bg/" + [ -d "$wallpaper_dir" ] || mkdir -p "$wallpaper_dir" + ${swww}/bin/swww-daemon & - # Allow some time for desktop to start - sleep 3 - echo "starting daemon..." - ${pkgs.swww}/bin/swww-daemon & - - while true; do - find "$wallpaper_dir" -type f -follow \( -iname \*.jpg -o -iname \*.png -o -iname \*.gif -o -iname \*.bmp \) | shuf | while read -r file; do - ${pkgs.swww}/bin/swww img "$file" --transition-step 10 --transition-fps 60 - [ $? != 0 ] && echo "swww failed, reloading daemon" && ${pkgs.swww}/bin/swww-daemon & - sleep 600 - done - done - ''}"; - }; - }; + while true; do + find "$wallpaper_dir" -type f -follow \( -iname \*.jpg -o -iname \*.png -o -iname \*.gif -o -iname \*.bmp \) | shuf | while read -r file; do + ${swww}/bin/swww img "$file" --transition-step 10 --transition-fps 60 + [ $? != 0 ] && echo "swww failed, exiting" && exit 1 + sleep 600 + done + done + '') + ]; } diff --git a/home/common/optional/desktop/wayland/waybar.nix b/home/common/optional/desktop/wayland/waybar.nix index f0175b6..d32118e 100644 --- a/home/common/optional/desktop/wayland/waybar.nix +++ b/home/common/optional/desktop/wayland/waybar.nix @@ -1,8 +1,7 @@ -{ - lib, - config, - pkgs, - ... +{ lib +, config +, pkgs +, ... }: { # Let it try to start a few more times systemd.user.services.waybar = { @@ -12,121 +11,132 @@ enable = true; systemd.enable = true; - settings = { - primary = { - mode = "dock"; - height = 30; - margin = "6"; - spacing = 5; - modules-left = [ - "custom/menu" - "wlr/workspaces"]; - modules-center = [ - "clock" - ]; - modules-right = [ - "cpu" - "memory" - "network" - "pulseaudio" - "battery" - "tray" - "custom/exit" - "custom/hostname" - ]; - "wlr/workspaces" = { - "format" = "{icon}"; - "on-click" = "activate"; - "format-icons"= { - "1" = ""; - "2" = ""; - "3" = ""; - "4" = ""; - "5" = ""; - "urgent" = ""; - "active" = ""; - "default" = ""; - }; - }; - "clock" = { - "format" = "{:%m/%d %H:%M}"; - "tooltip-format" = "{:%B %Y}\n{calendar}"; - "on-click" = "calendar"; - }; - "cpu"= { - "interval" = 10; - "format" = " {}%"; - "max-length" = 10; - "on-click" = ""; - }; - "memory" = { - "interval" = 30; - "format" = " {}%"; - "format-alt" = " {used:0.1f}G"; - "max-length" = 10; - }; + settings = { + primary = { + mode = "dock"; + height = 30; + margin = "6"; + spacing = 5; + modules-left = [ + "custom/menu" + "hyprland/workspaces" + "hyprland/window" + ]; - "network" = { - "format-wifi" = "直 {signalStrength}%"; - "format-ethernet" = " wired"; - "format-disconnected" = "睊"; - "on-click" = "bash ~/.config/waybar/scripts/rofi-wifi-menu.sh"; - }; + modules-center = [ + "clock" + ]; - "battery" = { - "bat" = "BAT0"; - "adapter" = "ADP0"; - "interval" = 60; - "states" = { - "warning" = 30; - "critical" = 15; - }; - "max-length" = 20; - "format" = "{icon} {capacity}%"; - "format-warning" = "{icon} {capacity}%"; - "format-critical" = "{icon} {capacity}%"; - "format-charging" = " {capacity}%"; - "format-plugged" = " {capacity}%"; - "format-alt" = "{icon} {time}"; - "format-full" = " {capacity}%"; - "format-icons" = [" " " " " " " " " "]; - }; - - "tray" = { - "spacing" = 10; - }; - - "custom/menu" = { - "format" = ""; - "on-click" = "rofi -show drun"; - }; - - "custom/hostname" = { - "exec" = "echo $USER@$(hostname)"; - "on-click" = "alacritty"; - }; - - "custom/exit" = { - "format" = ""; - "on-click" = "wlogout"; - }; - - "pulseaudio" = { - "format" = "{icon} {volume}%"; - "format-muted" = " 0%"; - "format-icons" = { - "headphone" = ""; - "headset" = ""; - "portable" = ""; - "default" = [ "" "" "" ]; - }; - "on-click" = "pavucontrol"; - }; + modules-right = [ + "cpu" + "memory" + "network" + "pulseaudio" + "battery" + "tray" + "custom/exit" + "custom/hostname" + "custom/ip" + ]; + "hyprland/window" = { + "format" = "{}"; + "rewrite" = { + "(.*) — Mozilla Firefox" = "$1"; + }; + "separate-outputs" = true; }; + + "hyprland/workspaces" = { + "format" = "{name}"; + "on-click" = "activate"; + "format-icons" = { + "urgent" = ""; + "active" = ""; + "default" = ""; + }; + }; + + "clock" = { + "format" = "{:%y-%m-%d %H:%M:%S}"; + "tooltip-format" = "{:%B %Y}\n{calendar}"; + "on-click" = "calendar"; + }; + + "cpu" = { + "interval" = 10; + "format" = " {}%"; + "max-length" = 10; + "on-click" = ""; + }; + + "memory" = { + "interval" = 30; + "format" = " {}%"; + "format-alt" = " {used:0.1f}G"; + "max-length" = 10; + }; + + "network" = { + "format-wifi" = "直 {signalStrength}%"; + "format-ethernet" = " wired ({ipaddr})"; + "format-disconnected" = "睊"; + }; + + "battery" = { + "bat" = "BAT0"; + "adapter" = "ADP0"; + "interval" = 60; + "states" = { + "warning" = 30; + "critical" = 15; + }; + "max-length" = 20; + "format" = "{icon} {capacity}%"; + "format-warning" = "{icon} {capacity}%"; + "format-critical" = "{icon} {capacity}%"; + "format-charging" = " {capacity}%"; + "format-plugged" = " {capacity}%"; + "format-alt" = "{icon} {time}"; + "format-full" = " {capacity}%"; + "format-icons" = [ " " " " " " " " " " ]; + }; + + "tray" = { + "spacing" = 10; + }; + + "custom/menu" = { + "format" = " Nixos"; + "on-click" = "wofi --show drun"; + }; + + "custom/hostname" = { + "exec" = "echo $USER@$(hostname)"; + "on-click" = "$TERMINAL"; + }; + + "custom/exit" = { + "format" = ""; + "on-click" = "wlogout"; + }; + + "pulseaudio" = { + "format" = "{icon} {volume}%"; + "format-muted" = " 0%"; + "format-icons" = { + "headphone" = ""; + "headset" = ""; + "portable" = ""; + "default" = [ "" "" "" ]; + }; + "on-click" = "pavucontrol"; + }; + + }; }; - style = '' + style = '' * { font-family: JetBrainsMono Nerd Font; font-size: 12pt; @@ -213,8 +223,8 @@ border-radius: 10px; } - ''; - }; + ''; + }; } diff --git a/pkgs/sddm-theme/default.nix b/pkgs/sddm-theme/default.nix index 0bf4421..526225a 100644 --- a/pkgs/sddm-theme/default.nix +++ b/pkgs/sddm-theme/default.nix @@ -1,16 +1,15 @@ -{ pkgs ? import { }, stdenv, fetchFromGitHub }: -pkgs.stdenv.mkDerivation rec { +{ pkgs ? import { }, fetchFromGitHub }: +pkgs.stdenv.mkDerivation { pname = "sddm-theme"; version = "1.6"; dontBuild = true; -# nativeBuildInputs = with pkgs; [ -# sddm -# ]; + installPhase = '' mkdir -p $out/share/sddm/themes cp -aR $src $out/share/sddm/themes/sugar-candy touch $out/share/sddm/themes/balls ''; + src = fetchFromGitHub { owner = "Kangie"; repo = "sddm-sugar-candy"; From 861f58946b33b55930e4c54bd45c7d9dfa43e8c0 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 6 Jun 2024 18:07:59 +0100 Subject: [PATCH 15/15] added zotero package and persist cinnamon-monitors.xml --- .../optional/desktop/common/default.nix | 3 +- home/sparky.nix | 10 ++-- hosts/common/users/media/default.nix | 53 ++++++++++--------- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/home/common/optional/desktop/common/default.nix b/home/common/optional/desktop/common/default.nix index 037c9d6..15bf3dc 100644 --- a/home/common/optional/desktop/common/default.nix +++ b/home/common/optional/desktop/common/default.nix @@ -1,4 +1,4 @@ -{pkgs, ... }: { +{ pkgs, ... }: { imports = [ ./firefox.nix ./alacritty.nix @@ -11,5 +11,6 @@ pkgs.zathura pkgs.xfce.thunar pkgs.kcolorchooser + pkgs.zotero ]; } diff --git a/home/sparky.nix b/home/sparky.nix index fec9160..8b938dd 100644 --- a/home/sparky.nix +++ b/home/sparky.nix @@ -1,15 +1,11 @@ -{ - pkgs, - config, - lib, - ... +{ inputs +, ... }: { imports = [ # Import users ./users/media ./common/core - ./common/optional/sops.nix # Import optional ./common/optional/git.nix @@ -17,4 +13,6 @@ ./common/optional/desktop/cinnamon ]; + + colorScheme = inputs.nix-colors.colorSchemes.kanagawa; } diff --git a/hosts/common/users/media/default.nix b/hosts/common/users/media/default.nix index f1e1f3a..3a8f470 100644 --- a/hosts/common/users/media/default.nix +++ b/hosts/common/users/media/default.nix @@ -16,9 +16,9 @@ in openssh.authorizedKeys.keys = lib.lists.forEach pubKeys (key: builtins.readFile key); extraGroups = - [ - "wheel" - ]; + [ + "wheel" + ]; packages = with pkgs; [ flatpak @@ -28,19 +28,20 @@ in environment.persistence."/persist" = { hideMounts = true; - users.${username}= { - directories = [ - "Sync" - "Keep" - ".ssh" - ".config/dconf" - ".config/cinnamon" - ".config/nemo" - ".mozilla" - ".local" - ]; - files = [ - ]; + users.${username} = { + directories = [ + "Sync" + "Keep" + ".ssh" + ".config/dconf" + ".config/cinnamon" + ".config/nemo" + ".mozilla" + ".local" + ]; + files = [ + ".config/cinnamon-monitors.xml" + ]; }; }; @@ -53,7 +54,7 @@ in path = "/home/${username}/.ssh/id_ed25519"; mode = "0600"; owner = "${username}"; - }; + }; "ssh_keys/${username}/id_ed25519.pub" = { path = "/home/${username}/.ssh/id_ed25519.pub"; mode = "0644"; @@ -64,14 +65,16 @@ in # The containing ssh folders are created as root and if this is the first ~/.ssh/ entry when writing keys, # the ownership is busted and home-manager can't target because it can't write into .ssh... # FIXME: We might not need this depending on how https://github.com/Mic92/sops-nix/issues/381 is fixed - system.activationScripts.sopsSetSshOwnwership = let - sshFolder = "/home/${username}/.ssh"; - user = config.users.users.${username}.name; - group = config.users.users.${username}.group; - in '' - mkdir -p ${sshFolder} || true - chown -R ${user}:${group} /home/${username}/.ssh - ''; + system.activationScripts.sopsSetSshOwnwership = + let + sshFolder = "/home/${username}/.ssh"; + user = config.users.users.${username}.name; + group = config.users.users.${username}.group; + in + '' + mkdir -p ${sshFolder} || true + chown -R ${user}:${group} /home/${username}/.ssh + ''; services.flatpak.enable = true;