Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
run: |
imagetag=$(cat artifacts/imagetag.txt)
tag="${imagetag#base-}"
gh release create "${tag}" --notes "Arch Linux WSL modern distribution based on the Docker image \`archlinux:${imagetag}\`" ./artifacts/archlinux.wsl.gz ./artifacts/DistributionInfo.json
gh release create "${tag}" \
--notes "Arch Linux WSL modern distribution based on the Docker image \`archlinux:${imagetag}\`" \
./artifacts/archlinux.wsl \
./artifacts/DistributionInfo.json
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 3 additions & 4 deletions .github/workflows/reusable-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ jobs:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
run: |
./build
gzip --best archlinux.wsl
sha256=$(sha256sum archlinux.wsl.gz)
sha256=$(sha256sum archlinux.wsl)
read -r sha256 _ <<<"${sha256}"
tag=$(cat imagetag.txt)
version="${tag#base-}"
Expand All @@ -32,7 +31,7 @@ jobs:
"Default": true,
"FriendlyName": "Arch Linux Unofficial version ${version} (latest)",
"Amd64Url": {
"Url": "https://github.com/DevelopersCommunity/archlinux-wsl/releases/download/${version}/archlinux.wsl.gz",
"Url": "https://github.com/DevelopersCommunity/archlinux-wsl/releases/download/${version}/archlinux.wsl",
"Sha256": "${sha256}"
}
}
Expand All @@ -45,7 +44,7 @@ jobs:
with:
name: artifacts
path: |
archlinux.wsl.gz
archlinux.wsl
imagetag.txt
DistributionInfo.json
if-no-files-found: error
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM archlinux:base

# Apply configuration files recommendations
# https://learn.microsoft.com/windows/wsl/build-custom-distro#configuration-file-recommendations
COPY --chown=root:root --chmod=0644 root/etc/wsl.conf root/etc/wsl-distribution.conf /etc/
COPY --chown=root:root --chmod=0755 root/etc/oobe.sh /etc/

Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ distribution](https://learn.microsoft.com/windows/wsl/build-custom-distro).

You can download a pre-built version from the [releases
page](https://github.com/DevelopersCommunity/archlinux-wsl/releases/latest).
Get the `archlinux.wsl.gz` file, decompress it, and double-click the
`archlinux.wsl` file to install it.
Get the `archlinux.wsl` file and double-click it in `File Explorer` to
install the distribution.

## Requirements

You need [WSL release 2.4.4 or higher](https://github.com/microsoft/WSL/releases)
to use this installation method. To install a pre-release version of WSL, run the
following command:
to use this installation method. To install a pre-release version of WSL, run
the following command:

```powershell
wsl --update --pre-release
Expand Down Expand Up @@ -68,6 +68,15 @@ $ systemctl
Failed to connect to system scope bus via local transport: No such file or directory
```

If you still have problems after installing another distribution, try to run the
following
[command](https://github.com/microsoft/WSL/issues/10205#issuecomment-1601620093)
in a `PowerShell` terminal:

```powershell
wsl -d Arch-Linux-Unofficial -u root -e systemctl restart user@1000.service
```

## Arch Linux trademark

The logo used in this distribution was taken from the [Arch Linux logos and
Expand Down
28 changes: 21 additions & 7 deletions build
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#!/bin/bash
#
# Build WSL tar image
# Build an Arch Linux WSL tar image

set -eu

[[ -f .env ]] && source .env

# Generate a Windows Terminal profile
# https://learn.microsoft.com/windows/wsl/build-custom-distro#generate-a-windows-terminal-profile
pushd terminal-profile || exit 1
npm install
node index.js >../root/usr/lib/wsl/terminal-profile.json
popd || exit 1

# Create an Arch Linux image based on its latest base Docker image
[[ -f .env ]] && source .env

token=$(curl \
-d "{ \"username\": \"${DOCKER_HUB_USERNAME}\", \"password\": \"${DOCKER_HUB_PAT}\" }" \
-H "Content-Type: application/json" \
Expand All @@ -34,9 +37,20 @@ echo "${tag}" >imagetag.txt

dockerfile=$(cat Dockerfile)
dockerfile="${dockerfile/FROM archlinux:base/FROM archlinux:${tag}}"
docker buildx build -t "archwsl:${tag}" -f - . <<<"${dockerfile}"

docker buildx build -t archwsl:latest -f - . <<<"${dockerfile}"

docker run -t --name wsl_export archwsl:latest ls /
docker export wsl_export >archlinux.wsl
# Export the tar from the container
# https://learn.microsoft.com/windows/wsl/use-custom-distro#export-the-tar-from-a-container
docker run -t --name wsl_export "archwsl:${tag}" ls /
docker export wsl_export >archlinux.tar
docker rm wsl_export
docker rmi "archwsl:${tag}"

# Apply configuration file recommendations
# https://learn.microsoft.com/windows/wsl/build-custom-distro#configuration-file-recommendations
tar --delete -f archlinux.tar etc/resolv.conf

# Create the tar file
# https://learn.microsoft.com/windows/wsl/build-custom-distro#create-the-tar-file
gzip --best --force archlinux.tar
mv archlinux.tar.gz archlinux.wsl
11 changes: 11 additions & 0 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

set -eu

# Apply systemd recommendations
# https://learn.microsoft.com/en-us/windows/wsl/build-custom-distro#systemd-recommendations
/bin/systemctl mask systemd-resolved.service
/bin/systemctl mask systemd-networkd.service
/bin/systemctl mask systemd-tmpfiles-setup.service
/bin/systemctl mask systemd-tmpfiles-clean.service
/bin/systemctl mask systemd-tmpfiles-clean.timer
/bin/systemctl mask systemd-tmpfiles-setup-dev-early.service
/bin/systemctl mask systemd-tmpfiles-setup-dev.service
/bin/systemctl mask tmp.mount

# Enable pacman progress bar and remove NoExtract options.
# https://gitlab.archlinux.org/archlinux/archlinux-docker/-/blob/master/scripts/make-rootfs.sh?ref_type=heads#L17
pacman=$(cat /etc/pacman.conf)
Expand Down
14 changes: 13 additions & 1 deletion root/etc/oobe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@

set -ue

/bin/dbus-uuidgen --ensure=/etc/machine-id
# https://man.archlinux.org/man/machine-id.5.en
/bin/systemd-machine-id-setup --commit
# https://wiki.archlinux.org/title/Reflector
/bin/systemctl enable reflector.timer
# https://learn.microsoft.com/azure/virtual-machines/linux/time-sync#chrony
/bin/systemctl enable chronyd.service

# Initialize and populate the pacman keyring
# https://wiki.archlinux.org/title/Pacman/Package_signing#Initializing_the_keyring
/bin/pacman-key --init
/bin/pacman-key --populate archlinux
/bin/pacman -S --noconfirm --needed archlinux-keyring
Expand Down Expand Up @@ -37,3 +42,10 @@ done
while ! /bin/passwd "${username}"; do
:
done

# Apply systemd recommendations
# http://learn.microsoft.com/windows/wsl/build-custom-distro#systemd-recommendations
su -c "mkdir -p \"\${HOME}/.config/systemd/user\"" - "${username}"
su -c "ln -s /dev/null \"\${HOME}/.config/systemd/user/systemd-tmpfiles-clean.service\"" - "${username}"
su -c "ln -s /dev/null \"\${HOME}/.config/systemd/user/systemd-tmpfiles-clean.timer\"" - "${username}"
su -c "ln -s /dev/null \"\${HOME}/.config/systemd/user/systemd-tmpfiles-setup.service\"" - "${username}"