blob: ec29da6918f77ffdb3ce5f548d36c5dbb32d8223 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
{ config, pkgs, lib, ... }:
with lib;
let
nixos-enter' = config.system.build.nixos-enter.overrideAttrs (_: {
runtimeShell = "/bin/bash";
});
recovery = pkgs.writeScriptBin "nixos-wsl-recovery" ''
#! /bin/sh
if [ -f /etc/NIXOS ]; then
echo "nixos-wsl-recovery should only be run from the WSL system distribution."
echo "Example:"
echo " wsl --system --distribution NixOS --user root -- /nix/var/nix/profiles/system/bin/nixos-wsl-recovery"
exit 1
fi
mount -o remount,rw /mnt/wslg/distro
exec /mnt/wslg/distro/${nixos-enter'}/bin/nixos-enter --root /mnt/wslg/distro "$@"
'';
in
{
config = {
wsl.extraBin = [
# needs to be a copy, not a symlink, to be executable from outside
{ src = "${recovery}/bin/nixos-wsl-recovery"; copy = true; }
];
};
}
|