diff --git a/README.md b/README.md index 8c0f12f..70281d4 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # nixos-hetzner-cloud-starter This repository is intended to be a sane, batteries-included starter template -for running a LunarVim-powered remote NixOS development environment on Hetzner -Cloud. It exists as a sister-project of +for running a [JeezyVim](https://github.com/LGUG2Z/JeezyVim)-powered NixOS +development environment on Hetzner Cloud. It exists as a sister-project of [nixos-wsl-starter](https://github.com/lgug2z/nixos-wsl-starter). If you don't want to dig into NixOS too much right now, the only file you need @@ -15,7 +15,7 @@ in other package managers. `unstable-packages` is for packages that you want to always keep at the latest released versions, and `stable-packages` is for packages that you want to track -with the current release of NixOS (currently 23.11). +with the current release of NixOS (currently 24.05). If you want to update the versions of the available `unstable-packages`, run `nix flake update` to pull the latest version of the Nixpkgs repository and @@ -35,56 +35,58 @@ This starter is a lightly-opinionated take on a productive terminal-driven development environment based on my own preferences. However, it is trivial to customize to your liking both by removing and adding tools that you prefer. -* The default editor is `lvim` -* The default shell is `zsh` -* `docker` is enabled by default -* The prompt is [Starship](https://starship.rs/) -* [`fzf`](https://github.com/junegunn/fzf), +- The default editor is [JeezyVim](https://github.com/LGUG2Z/JeezyVim) +- The default shell is `fish` +- `docker` is enabled by default +- The prompt is [Starship](https://starship.rs/) +- [`fzf`](https://github.com/junegunn/fzf), [`lsd`](https://github.com/lsd-rs/lsd), [`zoxide`](https://github.com/ajeetdsouza/zoxide), and - [`broot`](https://github.com/Canop/broot) are integrated into `zsh` by + [`broot`](https://github.com/Canop/broot) are integrated into `fish` by default - * These can all be disabled easily by setting `enable = false` in - [home.nix](home.nix), or just removing the lines all together -* [`direnv`](https://github.com/direnv/direnv) is integrated into `zsh` by + - These can all be disabled easily by setting `enable = false` in + [home.nix](home.nix), or just removing the lines all together +- [`direnv`](https://github.com/direnv/direnv) is integrated into `fish` by default -* `git` config is generated in [home.nix](home.nix) with options provided to +- `git` config is generated in [home.nix](home.nix) with options provided to enable private HTTPS clones with secret tokens -* `zsh` config is generated in [home.nix](home.nix) and includes git aliases, - useful WSL aliases, and - [sensible`$WORDCHARS`](https://lgug2z.com/articles/sensible-wordchars-for-most-developers/) +- `fish` config is generated in [home.nix](home.nix), and includes useful + navigiation and git aliases ## Quickstart [![Watch the walkthrough video](https://img.youtube.com/vi/wr22CyoyRo4/hqdefault.jpg)](https://www.youtube.com/watch?v=wr22CyoyRo4) - -* Create a server on Hetzner Cloud - * Location: Any - * Image: Ubuntu 22.04 - * Type: Any (Shared vCPU `CPX11` is a good starting point) - * SSH: Use your "default" SSH public key for ease - * Architecture: x86 - * Volumes: Not required - * Firewalls: Not required - * Backups: Not required - * Placement Groups: Not required - * Labels: Not required - * Cloud Config: Leave blank - * Name: Any -* `cp ~/.ssh/id_rsa.pub .` to make sure you have your SSH public key in this +- Create a server on Hetzner Cloud + - Location: Any + - Image: Ubuntu 22.04 + - Type: Any (Shared vCPU `CPX11` is a good starting point) + - SSH: Use your "default" SSH public key for ease + - Architecture: x86 + - Volumes: Not required + - Firewalls: Not required + - Backups: Not required + - Placement Groups: Not required + - Labels: Not required + - Cloud Config: Leave blank + - Name: Any +- `cp ~/.ssh/id_rsa.pub .` to make sure you have your SSH public key in this repo -* Go through all the `FIXME:` notices in this repo and make changes wherever +- Go through all the `FIXME:` notices in this repo and make changes wherever you want -* Run [`nixos-anywhere`](https://github.com/nix-community/nixos-anywhere) +- Run [`nixos-anywhere`](https://github.com/nix-community/nixos-anywhere) against `root@` + ```bash nix run github:numtide/nixos-anywhere -- --flake .#nixos root@ ``` -* Wait for the installation to complete -* Try to SSH into the server with `ssh @` -* You'll probably receive an error like the one below; follow the steps to remove the ip address from `known_hosts` -``` + +- Wait for the installation to complete +- Try to SSH into the server with `ssh @` +- You'll probably receive an error like the one below; follow the steps to + remove the ip address from `known_hosts` + +```text @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ -101,37 +103,40 @@ Offending ECDSA key in ~/.ssh/known_hosts:6 Host key for has changed and you have requested strict checking. Host key verification failed. ``` -* Now you can SSH into the server -* In a local terminal window, apply updated configurations to the remote server + +- Now you can SSH into the server +- In a local terminal window, apply updated configurations to the remote server + ```bash nixos-rebuild switch --flake .#nixos --target-host root@ ``` -Note: If developing in Rust, you'll still be managing your toolchains and components like `rust-analyzer` with `rustup`! +Note: If developing in Rust, you'll still be managing your toolchains and +components like `rust-analyzer` with `rustup`! ## Project Layout In order to keep the template as approachable as possible for new NixOS users, this project uses a flat layout without any nesting or modularization. -* `flake.nix` is where dependencies are specified - * `nixpkgs` is the current release of NixOS - * `nixpkgs-unstable` is the current trunk branch of NixOS (ie. all the - latest packages) - * `home-manager` is used to manage everything related to your home - directory (dotfiles etc.) - * `nur` is the community-maintained [Nix User - Repositories](https://nur.nix-community.org/) for packages that may not - be available in the NixOS repository - * `nix-index-database` tells you how to install a package when you run a - command which requires a binary not in the `$PATH` - * `disko` is used to prepare VM storage for NixOS -* `hetzner.nix` is where OpenSSH is configured and where the `root` SSH public +- `flake.nix` is where dependencies are specified + - `nixpkgs` is the current release of NixOS + - `nixpkgs-unstable` is the current trunk branch of NixOS (ie. all the + latest packages) + - `home-manager` is used to manage everything related to your home + directory (dotfiles etc.) + - `nur` is the community-maintained [Nix User + Repositories](https://nur.nix-community.org/) for packages that may not + be available in the NixOS repository + - `nix-index-database` tells you how to install a package when you run a + command which requires a binary not in the `$PATH` + - `disko` is used to prepare VM storage for NixOS +- `hetzner.nix` is where OpenSSH is configured and where the `root` SSH public key is set -* `linux.nix` is where the VM is configured - * The hostname is set here - * The default shell is set here - * User groups are set here - * NixOS options are set here -* `home.nix` is where packages, dotfiles, terminal tools, environment variables +- `linux.nix` is where the VM is configured + - The hostname is set here + - The default shell is set here + - User groups are set here + - NixOS options are set here +- `home.nix` is where packages, dotfiles, terminal tools, environment variables and aliases are configured diff --git a/flake.lock b/flake.lock index 1716c50..ed68eda 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,28 @@ { "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "jeezyvim", + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713532798, + "narHash": "sha256-wtBhsdMJA3Wa32Wtm1eeo84GejtI43pMrFrmwLXrsEc=", + "owner": "numtide", + "repo": "devshell", + "rev": "12e914740a25ea1891ec619bb53cf5e6ca922e40", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, "disko": { "inputs": { "nixpkgs": [ @@ -20,6 +43,132 @@ "type": "github" } }, + "flake-compat": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1715865404, + "narHash": "sha256-/GJvTdTpuDjNn84j82cU6bXztE0MSkdnTWClUCRub78=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "8dc45382d5206bd292f9c2768b8058a8fd8311d9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": [ + "jeezyvim", + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1715865404, + "narHash": "sha256-/GJvTdTpuDjNn84j82cU6bXztE0MSkdnTWClUCRub78=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "8dc45382d5206bd292f9c2768b8058a8fd8311d9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "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" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "jeezyvim", + "nixvim", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -27,20 +176,84 @@ ] }, "locked": { - "lastModified": 1706981411, - "narHash": "sha256-cLbLPTL1CDmETVh4p0nQtvoF+FSEjsnJTFpTxhXywhQ=", + "lastModified": 1720042825, + "narHash": "sha256-A0vrUB6x82/jvf17qPCpxaM+ulJnD8YZwH9Ci0BsAzE=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "e1391fb22e18a36f57e6999c7a9f966dc80ac073", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-24.05", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "jeezyvim", + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1715930644, + "narHash": "sha256-W9pyM3/vePxrffHtzlJI6lDS3seANQ+Nqp+i58O46LI=", "owner": "nix-community", "repo": "home-manager", - "rev": "652fda4ca6dafeb090943422c34ae9145787af37", + "rev": "e3ad5108f54177e6520535768ddbf1e6af54b59d", "type": "github" }, "original": { "owner": "nix-community", - "ref": "release-23.11", "repo": "home-manager", "type": "github" } }, + "jeezyvim": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "nixvim": "nixvim" + }, + "locked": { + "lastModified": 1717462994, + "narHash": "sha256-HfcBCFzuqAgYH8lK9ft5lk7IrTlCcDuUAC3wFPw6+Ro=", + "owner": "LGUG2Z", + "repo": "JeezyVim", + "rev": "e6124607d42d67465bd2382f55619899aef99aad", + "type": "github" + }, + "original": { + "owner": "LGUG2Z", + "repo": "JeezyVim", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "jeezyvim", + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1715901937, + "narHash": "sha256-eMyvWP56ZOdraC2IOvZo0/RTDcrrsqJ0oJWDC76JTak=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "ffc01182f90118119930bdfc528c1ee9a39ecef8", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, "nix-index-database": { "inputs": { "nixpkgs": [ @@ -63,20 +276,32 @@ }, "nixpkgs": { "locked": { - "lastModified": 1707347730, - "narHash": "sha256-0etC/exQIaqC9vliKhc3eZE2Mm2wgLa0tj93ZF/egvM=", + "lastModified": 1716330097, + "narHash": "sha256-8BO3B7e3BiyIDsaKA0tY8O88rClYRTjvAp66y+VBUeU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "6832d0d99649db3d65a0e15fa51471537b2c56a6", + "rev": "5710852ba686cc1fd0d3b8e22b3117d43ba374c2", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-23.11", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1714640452, + "narHash": "sha256-QBx10+k6JWz6u7VsohfSw8g8hjdBZEf8CFzXH1/1Z94=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz" + } + }, "nixpkgs-unstable": { "locked": { "lastModified": 1707268954, @@ -93,6 +318,64 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1715961556, + "narHash": "sha256-+NpbZRCRisUHKQJZF3CT+xn14ZZQO+KjxIIanH3Pvn4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4a6b83b05df1a8bd7d99095ec4b4d271f2956b64", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1720386169, + "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixvim": { + "inputs": { + "devshell": "devshell", + "flake-compat": "flake-compat", + "flake-parts": "flake-parts_2", + "flake-root": "flake-root", + "home-manager": "home-manager_2", + "nix-darwin": "nix-darwin", + "nixpkgs": "nixpkgs_2", + "pre-commit-hooks": "pre-commit-hooks", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1716326274, + "narHash": "sha256-1LyTvpjb8Cmlg3TRnP56rvqK1WSNa518pD6F0tjgM+U=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "5d2e01495944dcf7cf7ee53a7074c4010165d756", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, "nur": { "locked": { "lastModified": 1707488227, @@ -108,15 +391,82 @@ "type": "github" } }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "gitignore": "gitignore", + "nixpkgs": [ + "jeezyvim", + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": [ + "jeezyvim", + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1715870890, + "narHash": "sha256-nacSOeXtUEM77Gn0G4bTdEOeFIrkCBXiyyFZtdGwuH0=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "fa606cccd7b0ccebe2880051208e4a0f61bfc8c1", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "disko": "disko", "home-manager": "home-manager", + "jeezyvim": "jeezyvim", "nix-index-database": "nix-index-database", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_3", "nixpkgs-unstable": "nixpkgs-unstable", "nur": "nur" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "jeezyvim", + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1715940852, + "narHash": "sha256-wJqHMg/K6X3JGAE9YLM0LsuKrKb4XiBeVaoeMNlReZg=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "2fba33a182602b9d49f0b2440513e5ee091d838b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 68e742e..64dcb05 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,10 @@ { description = "NixOS configuration"; - inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; inputs.nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; - inputs.home-manager.url = "github:nix-community/home-manager/release-23.11"; + inputs.home-manager.url = "github:nix-community/home-manager/release-24.05"; inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs"; inputs.nur.url = "github:nix-community/NUR"; @@ -15,19 +15,24 @@ inputs.disko.url = "github:nix-community/disko"; inputs.disko.inputs.nixpkgs.follows = "nixpkgs"; + inputs.jeezyvim.url = "github:LGUG2Z/JeezyVim"; + outputs = inputs: with inputs; let secrets = builtins.fromJSON (builtins.readFile "${self}/secrets.json"); - nixpkgsWithOverlays = with inputs; rec { + nixpkgsWithOverlays = system: (import nixpkgs rec { + inherit system; config = { allowUnfree = true; permittedInsecurePackages = [ # FIXME:: add any insecure packages you absolutely need here ]; }; + overlays = [ nur.overlay + jeezyvim.overlays.default (_final: prev: { # this allows us to reference pkgs.unstable unstable = import nixpkgs-unstable { @@ -36,10 +41,9 @@ }; }) ]; - }; + }); configurationDefaults = args: { - nixpkgs = nixpkgsWithOverlays; home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.backupFileExtension = "hm-backup"; @@ -64,6 +68,7 @@ in nixpkgs.lib.nixosSystem { inherit system specialArgs; + pkgs = nixpkgsWithOverlays system; modules = [ (configurationDefaults specialArgs) diff --git a/home.nix b/home.nix index b815eea..a4eb4bf 100644 --- a/home.nix +++ b/home.nix @@ -1,7 +1,6 @@ { # FIXME: uncomment the next line if you want to reference your GitHub/GitLab access tokens and other secrets # secrets, - config, pkgs, username, nix-index-database, @@ -22,9 +21,7 @@ htop jq killall - lunarvim mosh - neovim procs ripgrep sd @@ -39,17 +36,16 @@ stable-packages = with pkgs; [ # FIXME: customize these stable packages to your liking for the languages that you use + # FIXME: you can add plugins, change keymaps etc using (jeezyvim.nixvimExtend {}) + # https://github.com/LGUG2Z/JeezyVim#extending + jeezyvim + # key tools gh # for bootstrapping just # core languages rustup - go - lua - nodejs - python3 - typescript # rust stuff cargo-cache @@ -63,28 +59,17 @@ tree-sitter # language servers - ccls # c / c++ - gopls - nodePackages.typescript-language-server pkgs.nodePackages.vscode-langservers-extracted # html, css, json, eslint nodePackages.yaml-language-server - sumneko-lua-language-server nil # nix - nodePackages.pyright # formatters and linters alejandra # nix - black # python - ruff # python deadnix # nix - golangci-lint - lua52Packages.luacheck nodePackages.prettier shellcheck shfmt statix # nix - sqlfluff - tflint ]; in { imports = [ @@ -98,9 +83,9 @@ in { homeDirectory = "/home/${username}"; # FIXME: set your preferred $EDITOR - sessionVariables.EDITOR = "lvim"; + sessionVariables.EDITOR = "nvim"; # FIXME: set your preferred $SHELL - sessionVariables.SHELL = "/etc/profiles/per-user/${username}/bin/zsh"; + sessionVariables.SHELL = "/etc/profiles/per-user/${username}/bin/fish"; }; home.packages = @@ -119,7 +104,7 @@ in { programs = { home-manager.enable = true; nix-index.enable = true; - nix-index.enableZshIntegration = true; + nix-index.enableFishIntegration = true; nix-index-database.comma.enable = true; # FIXME: disable this if you don't want to use the starship prompt @@ -140,16 +125,16 @@ in { # FIXME: disable whatever you don't want fzf.enable = true; - fzf.enableZshIntegration = true; + fzf.enableFishIntegration = true; lsd.enable = true; lsd.enableAliases = true; zoxide.enable = true; - zoxide.enableZshIntegration = true; + zoxide.enableFishIntegration = true; + zoxide.options = ["--cmd cd"]; broot.enable = true; - broot.enableZshIntegration = true; + broot.enableFishIntegration = true; direnv.enable = true; - direnv.enableZshIntegration = true; direnv.nix-direnv.enable = true; git = { @@ -186,142 +171,77 @@ in { }; }; - # FIXME: This is my .zshrc - you can fiddle with it if you want - zsh = { + # FIXME: This is my fish config - you can fiddle with it if you want + fish = { enable = true; - autocd = true; - enableAutosuggestions = true; - enableCompletion = true; - defaultKeymap = "emacs"; - history.size = 10000; - history.save = 10000; - history.expireDuplicatesFirst = true; - history.ignoreDups = true; - history.ignoreSpace = true; - historySubstringSearch.enable = true; - - plugins = [ + interactiveShellInit = '' + ${pkgs.any-nix-shell}/bin/any-nix-shell fish --info-right | source + ${pkgs.lib.strings.fileContents (pkgs.fetchFromGitHub { + owner = "rebelot"; + repo = "kanagawa.nvim"; + rev = "de7fb5f5de25ab45ec6039e33c80aeecc891dd92"; + sha256 = "sha256-f/CUR0vhMJ1sZgztmVTPvmsAgp0kjFov843Mabdzvqo="; + } + + "/extras/kanagawa.fish")} + set -U fish_greeting + ''; + functions = { + refresh = "source $HOME/.config/fish/config.fish"; + take = ''mkdir -p -- "$1" && cd -- "$1"''; + ttake = "cd $(mktemp -d)"; + show_path = "echo $PATH | tr ' ' '\n'"; + posix-source = '' + for i in (cat $argv) + set arr (echo $i |tr = \n) + set -gx $arr[1] $arr[2] + end + ''; + }; + shellAbbrs = { - name = "fast-syntax-highlighting"; - src = "${pkgs.zsh-fast-syntax-highlighting}/share/zsh/site-functions"; + gc = "nix-collect-garbage --delete-old"; } - { - name = "zsh-nix-shell"; - file = "nix-shell.plugin.zsh"; - src = pkgs.fetchFromGitHub { - owner = "chisui"; - repo = "zsh-nix-shell"; - rev = "v0.5.0"; - sha256 = "0za4aiwwrlawnia4f29msk822rj9bgcygw6a8a6iikiwzjjz0g91"; - }; + # navigation shortcuts + // { + ".." = "cd .."; + "..." = "cd ../../"; + "...." = "cd ../../../"; + "....." = "cd ../../../../"; } - ]; - + # git shortcuts + // { + gapa = "git add --patch"; + grpa = "git reset --patch"; + gst = "git status"; + gdh = "git diff HEAD"; + gp = "git push"; + gph = "git push -u origin HEAD"; + gco = "git checkout"; + gcob = "git checkout -b"; + gcm = "git checkout master"; + gcd = "git checkout develop"; + gsp = "git stash push -m"; + gsa = "git stash apply stash^{/"; + gsl = "git stash list"; + }; shellAliases = { - "..." = "./.."; - "...." = "././.."; - cd = "z"; - gc = "nix-collect-garbage --delete-old"; - refresh = "source ${config.home.homeDirectory}/.zshrc"; - show_path = "echo $PATH | tr ':' '\n'"; - - # FIXME: add more git aliases here if you want them - gapa = "git add --patch"; - grpa = "git reset --patch"; - gst = "git status"; - gdh = "git diff HEAD"; - gp = "git push"; - gph = "git push -u origin HEAD"; - gco = "git checkout"; - gcob = "git checkout -b"; - gcm = "git checkout master"; - gcd = "git checkout develop"; + jvim = "nvim"; + lvim = "nvim"; }; - - envExtra = '' - export PATH=$PATH:$HOME/.local/bin - ''; - - initExtra = '' - bindkey '^p' history-search-backward - bindkey '^n' history-search-forward - bindkey '^e' end-of-line - bindkey '^w' forward-word - bindkey "^[[3~" delete-char - bindkey ";5C" forward-word - bindkey ";5D" backward-word - - zstyle ':completion:*:*:*:*:*' menu select - - # Complete . and .. special directories - zstyle ':completion:*' special-dirs true - - zstyle ':completion:*' list-colors "" - zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' - - # disable named-directories autocompletion - zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories - - # Use caching so that commands like apt and dpkg complete are useable - zstyle ':completion:*' use-cache on - zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/.zcompcache" - - # Don't complete uninteresting users - zstyle ':completion:*:*:*:users' ignored-patterns \ - adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \ - clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \ - gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \ - ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \ - named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \ - operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \ - rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \ - usbmux uucp vcsa wwwrun xfs '_*' - # ... unless we really want to. - zstyle '*' single-ignored complete - - # https://thevaluable.dev/zsh-completion-guide-examples/ - zstyle ':completion:*' completer _extensions _complete _approximate - zstyle ':completion:*:descriptions' format '%F{green}-- %d --%f' - zstyle ':completion:*' group-name "" - zstyle ':completion:*:*:-command-:*:*' group-order alias builtins functions commands - zstyle ':completion:*' squeeze-slashes true - zstyle ':completion:*' matcher-list "" 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' - - # mkcd is equivalent to takedir - function mkcd takedir() { - mkdir -p $@ && cd ''${@:$#} - } - - function takeurl() { - local data thedir - data="$(mktemp)" - curl -L "$1" > "$data" - tar xf "$data" - thedir="$(tar tf "$data" | head -n 1)" - rm "$data" - cd "$thedir" + plugins = [ + { + inherit (pkgs.fishPlugins.autopair) src; + name = "autopair"; } - - function takegit() { - git clone "$1" - cd "$(basename ''${1%%.git})" + { + inherit (pkgs.fishPlugins.done) src; + name = "done"; } - - function take() { - if [[ $1 =~ ^(https?|ftp).*\.(tar\.(gz|bz2|xz)|tgz)$ ]]; then - takeurl "$1" - elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then - takegit "$1" - else - takedir "$@" - fi + { + inherit (pkgs.fishPlugins.sponge) src; + name = "sponge"; } - - WORDCHARS='*?[]~=&;!#$%^(){}<>' - - # fixes duplication of commands when using tab-completion - export LANG=C.UTF-8 - ''; + ]; }; }; }