Update nixos-wsl
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
12
flake.lock
generated
12
flake.lock
generated
@@ -258,16 +258,16 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1755261305,
|
||||
"narHash": "sha256-EOqCupB5X5WoGVHVcfOZcqy0SbKWNuY3kq+lj1wHdu8=",
|
||||
"owner": "nix-community",
|
||||
"lastModified": 1755774185,
|
||||
"narHash": "sha256-XjKqiTA19mkoBkja0VOy90qp2gC1f2fGgsLb9m1lg5Q=",
|
||||
"owner": "karaolidis",
|
||||
"repo": "NixOS-WSL",
|
||||
"rev": "203a7b463f307c60026136dd1191d9001c43457f",
|
||||
"rev": "b1f426697f62006b99fac0cc25a106626c78f874",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"ref": "main",
|
||||
"owner": "karaolidis",
|
||||
"ref": "extra-files",
|
||||
"repo": "NixOS-WSL",
|
||||
"type": "github"
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@
|
||||
};
|
||||
|
||||
nixos-wsl = {
|
||||
url = "github:nix-community/NixOS-WSL/main";
|
||||
url = "github:karaolidis/NixOS-WSL/extra-files";
|
||||
inputs = {
|
||||
nixpkgs.follows = "nixpkgs";
|
||||
flake-compat.follows = "flake-compat";
|
||||
|
@@ -11,7 +11,5 @@ You must build the system once with `sas.build.private = false;`. Then, connect
|
||||
1. Using a separate Nix system, run `hosts/elara/build-tarball.sh`
|
||||
2. Copy the generated tarball to the Elara host
|
||||
3. On the Elara host, run `wsl --import NixOS $env:USERPROFILE\NixOS nixos.wsl --version 2` in PowerShell
|
||||
4. `chown` your home directory to your user
|
||||
5. Stop WSL with `wsl --shutdown`
|
||||
6. Enable `cgroup v2` support by setting `kernelCommandLine=cgroup_no_v1=all` in `.wslconfig` in your Windows home directory
|
||||
7. Optionally, run `wsl --set-default nixos` to make NixOS the default WSL distribution
|
||||
4. Enable `cgroup v2` support by setting `kernelCommandLine=cgroup_no_v1=all` in `.wslconfig` in your Windows home directory
|
||||
5. Optionally, run `wsl --set-default nixos` to make NixOS the default WSL distribution
|
||||
|
@@ -18,4 +18,6 @@ install -d -m 700 "$temp/home/nikara"
|
||||
install -d -m 755 "$temp/home/nikara/.config/sops-nix"
|
||||
cp ./submodules/secrets/domains/sas/key.txt "$temp/home/nikara/.config/sops-nix/key.txt"
|
||||
|
||||
sudo nix run .#nixosConfigurations.elara.config.system.build.tarballBuilder -- --extra-files "$temp"
|
||||
sudo nix run .#nixosConfigurations.elara.config.system.build.tarballBuilder -- \
|
||||
--extra-files "$temp" \
|
||||
--chown /home/nikara 1000:100
|
||||
|
@@ -1,92 +0,0 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
# FIXME: https://github.com/nix-community/NixOS-WSL/issues/343
|
||||
# FIXME: https://github.com/nix-community/NixOS-WSL/issues/612
|
||||
{
|
||||
system.build.tarballBuilder = lib.mkForce (
|
||||
pkgs.writeShellApplication {
|
||||
name = "nixos-wsl-tarball-builder";
|
||||
|
||||
runtimeInputs = [
|
||||
config.nix.package
|
||||
pkgs.coreutils
|
||||
pkgs.e2fsprogs
|
||||
pkgs.gnutar
|
||||
pkgs.nixos-install-tools
|
||||
pkgs.pigz
|
||||
];
|
||||
|
||||
text = ''
|
||||
if ! [ "$EUID" -eq 0 ]; then
|
||||
echo "This script must be run as root!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
out="nixos-wsl.tar.gz"
|
||||
extra_files=""
|
||||
|
||||
positional=()
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--extra-files=*)
|
||||
extra_files="''${1#*=}"
|
||||
;;
|
||||
--extra-files)
|
||||
shift
|
||||
extra_files="$1"
|
||||
;;
|
||||
-*)
|
||||
echo "Unknown option: $1"
|
||||
echo "Usage: $0 [--extra-files PATH] [output.tar.gz]"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
positional+=("$1")
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ ''${#positional[@]} -gt 0 ]; then
|
||||
out="''${positional[0]}"
|
||||
fi
|
||||
|
||||
root=$(mktemp -p "''${TMPDIR:-/tmp}" -d nixos-wsl-tarball.XXXXXXXXXX)
|
||||
# FIXME: fails in CI for some reason, but we don't really care because it's CI
|
||||
trap 'chattr -Rf -i "$root" || true && rm -rf "$root" || true' INT TERM EXIT
|
||||
|
||||
if [ -n "$extra_files" ]; then
|
||||
echo "[NixOS-WSL] Copying extra files to $root..."
|
||||
cp --verbose --archive --no-target-directory "$extra_files" "$root"
|
||||
fi
|
||||
|
||||
chmod o+rx "$root"
|
||||
|
||||
echo "[NixOS-WSL] Installing..."
|
||||
nixos-install \
|
||||
--root "$root" \
|
||||
--no-root-passwd \
|
||||
--system ${config.system.build.toplevel} \
|
||||
--substituters ""
|
||||
|
||||
echo "[NixOS-WSL] Adding channel..."
|
||||
nixos-enter --root "$root" --command 'HOME=/root nix-channel --add https://github.com/nix-community/NixOS-WSL/archive/refs/heads/main.tar.gz nixos-wsl'
|
||||
|
||||
echo "[NixOS-WSL] Compressing..."
|
||||
tar -C "$root" \
|
||||
-c \
|
||||
--sort=name \
|
||||
--mtime='@1' \
|
||||
--owner=0 \
|
||||
--group=0 \
|
||||
--numeric-owner \
|
||||
. \
|
||||
| pigz > "$out"
|
||||
'';
|
||||
}
|
||||
);
|
||||
}
|
@@ -1,12 +1,10 @@
|
||||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
./build-tarball.nix
|
||||
./display.nix
|
||||
];
|
||||
imports = [ ./display.nix ];
|
||||
|
||||
wsl = {
|
||||
enable = true;
|
||||
tarball.configPath = ../../../.;
|
||||
startMenuLaunchers = true;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user