Skip to content

Commit

Permalink
feat(nix): update nixos-wsl, simplify bootstrap instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
LGUG2Z committed Sep 30, 2023
1 parent 37828f6 commit 45893ec
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 350 deletions.
48 changes: 28 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ customize to your liking both by removing and adding tools that you prefer.
* `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),
[`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
default
* These can all be disabled easily by setting `enable = false` in
[home.nix](home.nix) or just removing the lines all together
[home.nix](home.nix), or just removing the lines all together
* [`direnv`](https://github.com/direnv/direnv) is integrated into `zsh` by
default
* `git` config is generated in [home.nix](home.nix) with options provided to
Expand All @@ -60,7 +61,7 @@ customize to your liking both by removing and adding tools that you prefer.
installer](https://github.com/nix-community/NixOS-WSL)
* Install it (tweak the command to your desired paths):
```powershell
wsl --import NixOS .\NixOS\ .\nixos-wsl-installer.tar.gz --version 2
wsl --import NixOS .\NixOS\ .\nixos-wsl.tar.gz --version 2
```

Expand All @@ -69,44 +70,51 @@ wsl --import NixOS .\NixOS\ .\nixos-wsl-installer.tar.gz --version 2
wsl -d NixOs
```

* Get a copy of this repo:
* Set up a channel:
```bash
cd ~
nix-shell -p busybox
curl -L https://github.com/LGUG2Z/nixos-wsl-starter/archive/refs/heads/master.zip | unzip -
mv nixos-wsl-starter-master configuration
sudo nix-channel --add https://nixos.org/channels/nixos-23.05 nixos
sudo nix-channel --update
```

* Change the username to your desired username in `flake.nix`
* Get a copy of this repo (you'll probably want to fork it eventually):
```bash
nix-shell -p git neovim
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
```bash
sudo nixos-rebuild switch --flake ~/configuration
sudo nixos-rebuild switch --flake /tmp/configuration
```

* Restart and reconnect to the current WSL shell
```bash
wsl -t NixOS
wsl -d NixOS
```

* Disconnect from your current WSL shell and then reconnect again with `wsl -d
NixOS`
* `cd ~` and then `pwd` should now show `/home/<YOUR_USERNAME>`
* Do this bit again because the temporary initial home directory was blown away
when we applied our configuration
* Move the configuration to your new home directory
```bash
cd ~
nix-shell -p busybox
curl -L https://github.com/LGUG2Z/nixos-wsl-starter/archive/refs/heads/master.zip | unzip -
mv nixos-wsl-starter-master configuration
mv /tmp/configuration ~/configuration
```

* Install LunarVim (select "no" for all dependency prompts)
```bash
LV_BRANCH='release-1.3/neovim-0.9' bash <(curl -s https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh)
```
* Change the username to your desired username in `flake.nix` one last time
* Run `lvim` once and let it the long first-time setup run to completion
* You can now set `sessionVariables.EDITOR = "lvim";` in [home.nix](home.nix)
* Go through all the `FIXME:` notices in `~/configuration` and make changes
wherever you want
* Apply the configuration
```bash
sudo nixos-rebuild switch --flake ~/configuration
sudo nixos-rebuild switch --flake ~/configuration
```

Note: If you will be 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

Expand Down
38 changes: 12 additions & 26 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
inputs.nur.url = "github:nix-community/NUR";

inputs.nixos-wsl.url = "github:nix-community/NixOS-WSL";
inputs.nixos-wsl.inputs.nixpkgs.follows = "nixpkgs";

inputs.nix-index-database.url = "github:Mic92/nix-index-database";
inputs.nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
Expand Down Expand Up @@ -76,7 +77,7 @@

nixosConfigurations.nixos = mkNixosConfiguration {
hostname = "nixos";
username = "example-user"; # FIXME: replace with your own username!
username = "nixos"; # FIXME: replace with your own username!
modules = [
nixos-wsl.nixosModules.wsl
./wsl.nix
Expand Down
17 changes: 13 additions & 4 deletions home.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
# FIXME: uncomment this if you want to reference your GitHub/GitLab access tokens and other secrets
# FIXME: uncomment the next line if you want to reference your GitHub/GitLab access tokens and other secrets
# secrets,
config,
pkgs,
Expand Down Expand Up @@ -104,9 +104,18 @@ in {
sessionVariables.SHELL = "/etc/profiles/per-user/${username}/bin/zsh";
};

home.packages = stable-packages ++ unstable-packages;
home.packages =
stable-packages
++ unstable-packages
++
# FIXME: you can add anything else that doesn't fit into the above two lists in here
[
# pkgs.some-package
# pkgs.unstable.some-other-package
];

home.file.".config/lvim/config.lua".source = ./lvim_config.lua;
# 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;
Expand Down Expand Up @@ -156,7 +165,7 @@ in {
userEmail = ""; # FIXME: set your git email
userName = ""; #FIXME: set your git username
extraConfig = {
# FIXME: uncomment this if you want to be able to clone private https repos
# FIXME: uncomment the next lines if you want to be able to clone private https repos
# url = {
# "https://oauth2:${secrets.github_token}@github.com" = {
# insteadOf = "https://github.com";
Expand Down
Loading

0 comments on commit 45893ec

Please sign in to comment.