From deb460989e01d917f1fce1c7309ebe4a238fab19 Mon Sep 17 00:00:00 2001 From: Nikolaos Karaolidis Date: Tue, 26 Aug 2025 07:11:49 +0000 Subject: [PATCH] Update nixos-wsl Signed-off-by: Nikolaos Karaolidis --- flake.lock | 12 ++-- flake.nix | 2 +- hosts/elara/README.md | 6 +- hosts/elara/build-tarball.sh | 4 +- hosts/elara/hardware/build-tarball.nix | 92 -------------------------- hosts/elara/hardware/default.nix | 6 +- 6 files changed, 14 insertions(+), 108 deletions(-) delete mode 100644 hosts/elara/hardware/build-tarball.nix diff --git a/flake.lock b/flake.lock index 8e91c45..c6cd118 100644 --- a/flake.lock +++ b/flake.lock @@ -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" } diff --git a/flake.nix b/flake.nix index da5787d..189d8fb 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; diff --git a/hosts/elara/README.md b/hosts/elara/README.md index 0c6ae32..d2509ed 100644 --- a/hosts/elara/README.md +++ b/hosts/elara/README.md @@ -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 diff --git a/hosts/elara/build-tarball.sh b/hosts/elara/build-tarball.sh index 4c41a20..23339f0 100755 --- a/hosts/elara/build-tarball.sh +++ b/hosts/elara/build-tarball.sh @@ -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 diff --git a/hosts/elara/hardware/build-tarball.nix b/hosts/elara/hardware/build-tarball.nix deleted file mode 100644 index c666811..0000000 --- a/hosts/elara/hardware/build-tarball.nix +++ /dev/null @@ -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" - ''; - } - ); -} diff --git a/hosts/elara/hardware/default.nix b/hosts/elara/hardware/default.nix index 8795688..abbb2f2 100644 --- a/hosts/elara/hardware/default.nix +++ b/hosts/elara/hardware/default.nix @@ -1,12 +1,10 @@ { ... }: { - imports = [ - ./build-tarball.nix - ./display.nix - ]; + imports = [ ./display.nix ]; wsl = { enable = true; + tarball.configPath = ../../../.; startMenuLaunchers = true; }; }