diff options
| author | nzbr <mail@nzbr.de> | 2023-09-12 12:19:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-12 12:19:14 +0200 |
| commit | ff57c8dc58f707299379fd538c6b6ec77980f7cf (patch) | |
| tree | 1e29af88c893020fdd1dcb694c9303c6bf43d78b /modules/recovery.nix | |
| parent | 212e2d6b0d820fc9f1e79f7b5feeea2824db51bb (diff) | |
Refactor (#291)
* move module imports to default.nix
* move docker modules to subdirectory
* add an otion for adding files to /bin. Fixes #279
* move recovery script to own module
* reorder options
* move systemd related code to separate modules
* move utils to repo root
* devShell -> devShells.default
* fix utils imports
* fix bashWrapper
Diffstat (limited to 'modules/recovery.nix')
| -rw-r--r-- | modules/recovery.nix | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/modules/recovery.nix b/modules/recovery.nix new file mode 100644 index 0000000..ec29da6 --- /dev/null +++ b/modules/recovery.nix @@ -0,0 +1,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; } + ]; + }; + +} |
