From 8557f1118303ae9d4323a4be38d06cec799de11d Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 30 May 2024 17:13:28 -0700 Subject: [PATCH] feat(nix): upgrade to 24.05, switch to fish + jeezyvim --- .github/workflows/build.yml | 15 +- README.md | 132 +++++++------ flake.lock | 379 +++++++++++++++++++++++++++++++++--- flake.nix | 18 +- home.nix | 237 ++++++++-------------- statix.toml | 3 + win32yank.nix | 22 --- wsl.nix | 21 +- 8 files changed, 536 insertions(+), 291 deletions(-) create mode 100644 statix.toml delete mode 100644 win32yank.nix diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78d53c5..4287c6e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,11 +1,13 @@ -name: 'build' +name: "build" on: push: - branches: + branches: - master - feature/* - hotfix/* + tags: + - nixos-wsl-starter-* pull_request: {} workflow_call: {} @@ -21,7 +23,7 @@ jobs: - uses: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 with: - extra_nix_config: 'access-tokens = github.com=${{ github.token }}' + extra_nix_config: "access-tokens = github.com=${{ github.token }}" - name: Build tarball run: | @@ -31,5 +33,10 @@ jobs: - name: Upload tarball uses: actions/upload-artifact@v3 with: - name: nixos-wsl-starter + name: nixos-wsl.tar.gz path: nixos-wsl.tar.gz + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: nixos-wsl.tar.gz diff --git a/README.md b/README.md index 6063b94..fb89669 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # nixos-wsl-starter This repository is intended to be a sane, batteries-included starter template -for running a LunarVim-powered NixOS development environment on WSL. +for running a [JeezyVim](https://github.com/LGUG2Z/JeezyVim)-powered NixOS +development environment on WSL. If you don't want to dig into NixOS too much right now, the only file you need to concern yourself with is [home.nix](home.nix). This is where you can add and @@ -13,7 +14,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 @@ -33,106 +34,123 @@ 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` -* `win32yank` is used to ensure perfect bi-directional copying and pasting to +- The default editor is [JeezyVim](https://github.com/LGUG2Z/JeezyVim) +- `win32yank` is used to ensure perfect bi-directional copying and pasting to and from Windows GUI applications and LunarVim running in WSL -* The default shell is `zsh` -* Native `docker` (ie. Linux, not Windows) is enabled by default -* The prompt is [Starship](https://starship.rs/) -* [`fzf`](https://github.com/junegunn/fzf), +- The default shell is `fish` +- Native `docker` (ie. Linux, not Windows) 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 git aliases, + useful WSL aliases + +### win32yank + +There have been some recent changes in WSL2 that make running `win32yank` +within WSL2 very slow. You should install this on Windows by running `scoop +install win32yank` or compiling it from source, and then adding it to your `$PATH`: + +```nix +{ + programs.fish = { + interactiveShellInit = '' + fish_add_path --append /mnt/c/Users//scoop/apps/win32yank/0.1.1 + ''; + }; +} +``` ## Quickstart [![Watch the walkthrough video](https://img.youtube.com/vi/UmRXXYxq8k4/hqdefault.jpg)](https://www.youtube.com/watch?v=UmRXXYxq8k4) -* Get the [latest NixOS-WSL - installer](https://github.com/nix-community/NixOS-WSL) -* Install it (tweak the command to your desired paths): +- Get the [latest + release](https://github.com/LGUG2Z/nixos-wsl-starter/releases) and unzip it +- Install it (tweak the command to your desired paths): + ```powershell wsl --import NixOS .\NixOS\ .\nixos-wsl.tar.gz --version 2 - ``` -* Enter the distro: +- Enter the distro: + ```powershell wsl -d NixOS ``` -* Set up a channel: -```bash -sudo nix-channel --add https://nixos.org/channels/nixos-23.11 nixos -sudo nix-channel --update -``` +- Get a copy of this repo (you'll probably want to fork it eventually): -* Get a copy of this repo (you'll probably want to fork it eventually): ```bash -nix-shell -p git neovim +nix-shell -p git git clone https://github.com/LGUG2Z/nixos-wsl-starter.git /tmp/configuration cd /tmp/configuration ``` -* Change the username to your desired username in `flake.nix` with `nvim` (or whichever editor you prefer) -* Apply the configuration +- Change the username to your desired username in `flake.nix` with `nvim` (or + whichever editor you prefer) +- Install `win32yank` with `scoop` and add it to your `$PATH` in NixOS +- Apply the configuration and shutdown the WSL2 VM + ```bash -sudo nixos-rebuild switch --flake /tmp/configuration +sudo nixos-rebuild switch --flake /tmp/configuration && sudo shutdown -h now ``` -* Restart and reconnect to the current WSL shell +- Reconnect to the WSL2 VM + ```bash -wsl -t NixOS wsl -d NixOS ``` -* `cd ~` and then `pwd` should now show `/home/` -* Move the configuration to your new home directory +- `cd ~` and then `pwd` should now show `/home/` +- Move the configuration to your new home directory + ```bash mv /tmp/configuration ~/configuration ``` -* Go through all the `FIXME:` notices in `~/configuration` and make changes +- Go through all the `FIXME:` notices in `~/configuration` and make changes wherever you want -* Apply the configuration +- Apply the configuration + ```bash sudo nixos-rebuild switch --flake ~/configuration ``` -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 - * `nixos-wsl` exposes important WSL-specific configuration options - * `nix-index-database` tells you how to install a package when you run a - command which requires a binary not in the `$PATH` -* `wsl.nix` is where the VM is configured - * The hostname is set here - * The default shell is set here - * User groups are set here - * WSL configuration options are set here - * NixOS options are set here -* `home.nix` is where packages, dotfiles, terminal tools, environment variables +- `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 + - `nixos-wsl` exposes important WSL-specific configuration options + - `nix-index-database` tells you how to install a package when you run a + command which requires a binary not in the `$PATH` +- `wsl.nix` is where the VM is configured + - The hostname is set here + - The default shell is set here + - User groups are set here + - WSL configuration options 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 9561db8..30d3e0b 100644 --- a/flake.lock +++ b/flake.lock @@ -1,9 +1,58 @@ { "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "jeezyvim", + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "narHash": "sha256-wtBhsdMJA3Wa32Wtm1eeo84GejtI43pMrFrmwLXrsEc=", + "owner": "numtide", + "repo": "devshell", + "rev": "12e914740a25ea1891ec619bb53cf5e6ca922e40", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, "flake-compat": { + "locked": { + "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": { + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_3": { "flake": false, "locked": { - "lastModified": 1696426674, "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", "repo": "flake-compat", @@ -16,16 +65,84 @@ "type": "github" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "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": { + "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": { + "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": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -34,6 +151,28 @@ "type": "github" } }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "jeezyvim", + "nixvim", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "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": [ @@ -41,20 +180,80 @@ ] }, "locked": { - "lastModified": 1706981411, - "narHash": "sha256-cLbLPTL1CDmETVh4p0nQtvoF+FSEjsnJTFpTxhXywhQ=", + "narHash": "sha256-rNObca6dm7Qs524O4st8VJH6pZ/Xe1gxl+Rx6mcWYo0=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "a631666f5ec18271e86a5cde998cba68c33d9ac6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-24.05", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "jeezyvim", + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "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": { + "narHash": "sha256-SohCTu6E55OACHKVT4JF2cp6y/qcTIDNd/mod9ayMB8=", + "owner": "LGUG2Z", + "repo": "JeezyVim", + "rev": "a0613f7e08eb0d5df21e4d25a891e6d57877d26e", + "type": "github" + }, + "original": { + "owner": "LGUG2Z", + "repo": "JeezyVim", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "jeezyvim", + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "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": [ @@ -62,11 +261,10 @@ ] }, "locked": { - "lastModified": 1707016097, - "narHash": "sha256-V4lHr6hFQ3rK650dh64Xffxsf4kse9vUYWsM+ldjkco=", + "narHash": "sha256-Idcye44UW+EgjbjCoklf2IDF+XrehV6CVYvxR1omst4=", "owner": "Mic92", "repo": "nix-index-database", - "rev": "3e3dad2808379c522138e2e8b0eb73500721a237", + "rev": "ff80cb4a11bb87f3ce8459be6f16a25ac86eb2ac", "type": "github" }, "original": { @@ -77,18 +275,17 @@ }, "nixos-wsl": { "inputs": { - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", + "flake-compat": "flake-compat_3", + "flake-utils": "flake-utils_2", "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1707476384, - "narHash": "sha256-9YortZTCO9r7wFHX92t+npUDmD5VcKrkVmwaPCvEiXI=", + "narHash": "sha256-AZKQs+KrL70le0RZH8XqZJMc2SahU4LpfEJ2Vd5SWzM=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "76ca59d8d4423b27c0238bc31401692ebc571365", + "rev": "020cd466170204e448b24b246045599fce69ad91", "type": "github" }, "original": { @@ -99,27 +296,36 @@ }, "nixpkgs": { "locked": { - "lastModified": 1707347730, - "narHash": "sha256-0etC/exQIaqC9vliKhc3eZE2Mm2wgLa0tj93ZF/egvM=", + "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": { + "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, - "narHash": "sha256-2en1kvde3cJVc3ZnTy8QeD2oKcseLFjYPLKhIGDanQ0=", + "narHash": "sha256-SzDKxseEcHR5KzPXLwsemyTR/kaM9whxeiJohbL04rs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "f8e2ebd66d097614d51a56a755450d4ae1632df1", + "rev": "ad57eef4ef0659193044870c731987a6df5cf56b", "type": "github" }, "original": { @@ -129,13 +335,67 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "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": { + "narHash": "sha256-I5dlFm936SkuUu9haYabEBCUPeX6EuXLT1uFkEM/lbY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "fafeae3d248c41c6c8a2ab5e09f9e2d3de706ef8", + "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": { + "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, - "narHash": "sha256-CJavI6VIk12u8mntxepDDinX2TX5et1I2phRm9mObtI=", + "narHash": "sha256-dW9KCBupH1pFBlXPKEHNGzi288QYOMWfIlPaTeSoHtE=", "owner": "nix-community", "repo": "NUR", - "rev": "7401f12518027ed8ea1d8f7634a446ac3269c3c4", + "rev": "a5f0ef2970d5045041d56733b6772942747042d9", "type": "github" }, "original": { @@ -144,19 +404,47 @@ "type": "github" } }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "gitignore": "gitignore", + "nixpkgs": [ + "jeezyvim", + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": [ + "jeezyvim", + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "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": { "home-manager": "home-manager", + "jeezyvim": "jeezyvim", "nix-index-database": "nix-index-database", "nixos-wsl": "nixos-wsl", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_3", "nixpkgs-unstable": "nixpkgs-unstable", "nur": "nur" } }, "systems": { "locked": { - "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "owner": "nix-systems", "repo": "default", @@ -168,6 +456,41 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "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": { + "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 24c8741..a59dcde 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,31 +15,36 @@ inputs.nix-index-database.url = "github:Mic92/nix-index-database"; inputs.nix-index-database.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 { inherit (prev) system; inherit config; }; }) ]; - }; + }); configurationDefaults = args: { - nixpkgs = nixpkgsWithOverlays; home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.backupFileExtension = "hm-backup"; @@ -64,6 +69,7 @@ in nixpkgs.lib.nixosSystem { inherit system specialArgs; + pkgs = nixpkgsWithOverlays system; modules = [ (configurationDefaults specialArgs) diff --git a/home.nix b/home.nix index 6555130..48b938f 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.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 = [ @@ -97,9 +82,9 @@ in { username = "${username}"; homeDirectory = "/home/${username}"; - 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 = @@ -112,13 +97,10 @@ in { # pkgs.unstable.some-other-package ]; - # FIXME: if you want to version your LunarVim config, add it to the root of this repo and uncomment the next line - # home.file.".config/lvim/config.lua".source = ./lvim_config.lua; - 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 @@ -139,16 +121,15 @@ 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 = { @@ -185,146 +166,84 @@ 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 = [ + # FIXME: run 'scoop install win32yank' on Windows, then add this line with your Windows username to the bottom of interactiveShellInit + # fish_add_path --append /mnt/c/Users//scoop/apps/win32yank/0.1.1 + 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"; pbcopy = "/mnt/c/Windows/System32/clip.exe"; pbpaste = "/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -command 'Get-Clipboard'"; explorer = "/mnt/c/Windows/explorer.exe"; }; - - 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 - ''; + ]; }; }; } diff --git a/statix.toml b/statix.toml new file mode 100644 index 0000000..2e56d7f --- /dev/null +++ b/statix.toml @@ -0,0 +1,3 @@ +disabled = ["repeated_keys"] +nix_version = '2.4' +ignore = ['.direnv'] diff --git a/win32yank.nix b/win32yank.nix deleted file mode 100644 index 42f8784..0000000 --- a/win32yank.nix +++ /dev/null @@ -1,22 +0,0 @@ -{pkgs ? import }: let - pname = "win32yank"; - version = "0.1.1"; - bin = "win32yank.exe"; -in - pkgs.stdenv.mkDerivation { - inherit pname version; - - src = pkgs.fetchzip { - url = "https://github.com/equalsraf/win32yank/releases/download/v${version}/win32yank-x64.zip"; - sha256 = "sha256-4ivE1cYZhYs4ibx5oiYMOhbse9bdOomk7RjgdVl5lD0="; - stripRoot = false; - }; - - inherit bin; - - installPhase = '' - mkdir -p $out/bin - cp $bin $out/bin - chmod +x $out/bin/* - ''; - } diff --git a/wsl.nix b/wsl.nix index 981e5cd..f906ffd 100644 --- a/wsl.nix +++ b/wsl.nix @@ -12,15 +12,10 @@ networking.hostName = "${hostname}"; - systemd.tmpfiles.rules = [ - "d /home/${username}/.config 0755 ${username} users" - "d /home/${username}/.config/lvim 0755 ${username} users" - ]; - - # FIXME: change your shell here if you don't want zsh - programs.zsh.enable = true; - environment.pathsToLink = ["/share/zsh"]; - environment.shells = [pkgs.zsh]; + # FIXME: change your shell here if you don't want fish + programs.fish.enable = true; + environment.pathsToLink = ["/share/fish"]; + environment.shells = [pkgs.fish]; environment.enableAllTerminfo = true; @@ -31,8 +26,8 @@ users.users.${username} = { isNormalUser = true; - # FIXME: change your shell here if you don't want zsh - shell = pkgs.zsh; + # FIXME: change your shell here if you don't want fish + shell = pkgs.fish; extraGroups = [ "wheel" # FIXME: uncomment the next line if you want to run docker without sudo @@ -46,10 +41,6 @@ # ]; }; - environment.systemPackages = [ - (import ./win32yank.nix {inherit pkgs;}) - ]; - home-manager.users.${username} = { imports = [ ./home.nix