some bash runbook to illustrate mounting errors on nixos-wsl

nix-components
pegasust 2022-11-07 10:15:12 +00:00
parent 8fb58aeb35
commit 202e250cbf
6 changed files with 43 additions and 10 deletions

View File

@ -20,7 +20,6 @@
};
programs.tmux = {
enable = true;
shell = "zsh";
extraConfig = builtins.readFile ../tmux/.tmux.conf;
};
programs.exa = {
@ -66,6 +65,7 @@
a="add"; c="commit"; ca="commit --ammend"; cm="commit -m";
lol="log --graph --decorate --pretty=oneline --abbrev-commit";
lola="log --graph --decorate --pretty=oneline --abbrev-commit --all";
sts="status";
};
extraConfig = {
merge = {tool="vimdiff"; conflictstyle="diff3";};

View File

@ -18,7 +18,7 @@ in
automountPath = "/mnt";
defaultUser = "nixos"; # if change defaultUser, make sure uid to be 1000 (first user)
startMenuLaunchers = true;
automountOptions = "drvfs,metadata,uid=1000,gid=100";
# Enable native Docker support
# docker-native.enable = true;

View File

@ -18,12 +18,12 @@
fileSystems."/usr/lib/wsl/drivers" =
{ device = "drivers";
fsType = "9p";
fsType = "drvfs";
};
fileSystems."/usr/lib/wsl/lib" =
{ device = "lib";
fsType = "9p";
fsType = "drvfs";
};
fileSystems."/mnt/wsl" =
@ -32,18 +32,18 @@
};
fileSystems."/mnt/c" =
{ device = "C:\134";
fsType = "9p";
{ device = "C:";
fsType = "drvfs";
};
fileSystems."/mnt/d" =
{ device = "D:\134";
fsType = "9p";
{ device = "D:";
fsType = "drvfs";
};
fileSystems."/mnt/f" =
{ device = "F:\134";
fsType = "9p";
{ device = "F:";
fsType = "drvfs";
};
swapDevices = [ ];

View File

@ -0,0 +1,8 @@
#!/usr/bin/env sh
# This is used when we need to refresh hardware-configuration.nix
# Basically what this does is to mount the drives, then ask nixos-generate-config
# to regenerate hardware-configuration.nix for us.
# Manual on nixos-generate-config [here](https://www.mankier.com/8/nixos-generate-config)
SCRIPT_DIR=$(realpath $(dirname $0))
${SCRIPT_DIR}/felia-mount.sh
sudo nixos-generate-config

View File

@ -0,0 +1,14 @@
#!/usr/bin/env sh
SCRIPT_DIR=$(realpath $(dirname $0))
function mntDrive() {
WSL_DRIVE=$(echo $1 | tr '[:upper:]' '[:lower:]')
${SCRIPT_DIR}/mount-windrive.sh $1 $WSL_DRIVE
echo "ls /mnt/${WSL_DRIVE}"
ls /mnt/${WSL_DRIVE}
}
mntDrive C
mntDrive D
mntDrive F

View File

@ -0,0 +1,11 @@
#!/usr/bin/env sh
# https://linuxnightly.com/mount-and-access-hard-drives-in-windows-subsystem-for-linux-wsl/
# Usage: scripts/mount-windrive.sh C # /mnt/c -> C:\
WIN_DRIVE_CHAR=${1:-"C"}
WSL_DRIVE_CHAR=${2:-$(echo $WIN_DRIVE_CHAR | tr '[:upper:]' '[:lower:]')}
sudo umount "/mnt/${WSL_DRIVE_CHAR}"
sudo mount -t drvfs "${WIN_DRIVE_CHAR}:" "/mnt/${WSL_DRIVE_CHAR}"