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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
tag="${imagetag#base-}"
gh release create "${tag}" \
--notes "Arch Linux WSL modern distribution based on the Docker image \`archlinux:${imagetag}\`" \
./artifacts/archlinux.wsl \
./artifacts/archlinux-${imagetag}.wsl \
./artifacts/DistributionInfo.json
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32 changes: 16 additions & 16 deletions .github/workflows/reusable-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,33 @@ jobs:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
run: |
./build
sha256=$(sha256sum archlinux.wsl)
read -r sha256 _ <<<"${sha256}"
tag=$(cat imagetag.txt)
sha256=$(sha256sum archlinux-${tag}.wsl)
read -r sha256 _ <<<"${sha256}"
version="${tag#base-}"
cat <<EOF >DistributionInfo.json
{
"ModernDistributions": {
"Arch-Linux-Unofficial": [
{
"Name": "Arch-Linux-Unofficial-${tag}",
"Default": true,
"FriendlyName": "Arch Linux Unofficial version ${version} (latest)",
"Amd64Url": {
"Url": "https://github.com/DevelopersCommunity/archlinux-wsl/releases/download/${version}/archlinux.wsl",
"Sha256": "${sha256}"
}
}
]
}
"ModernDistributions": {
"Arch-Linux-Unofficial": [
{
"Name": "Arch-Linux-Unofficial",
"Default": true,
"FriendlyName": "Arch Linux Unofficial Rolling Release",
"Amd64Url": {
"Url": "https://github.com/DevelopersCommunity/archlinux-wsl/releases/download/${version}/archlinux-${tag}.wsl",
"Sha256": "${sha256}"
}
}
]
}
}
EOF
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
archlinux.wsl
archlinux-*.wsl
imagetag.txt
DistributionInfo.json
if-no-files-found: error
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/.env
/archlinux.wsl
/archlinux-*.wsl
/DistributionInfo.json
/imagetag.txt
/root/usr/lib/wsl/terminal-profile.json
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ 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/

COPY root/usr/lib/wsl/* /usr/lib/wsl/
COPY --chown=root:root --chmod=0755 root/usr/lib/wsl/oobe.sh /usr/lib/wsl/
COPY root/usr/lib/wsl/archlinux.ico root/usr/lib/wsl/terminal-profile.json /usr/lib/wsl/

COPY --chmod=0755 configure.sh ./configure.sh
RUN ./configure.sh && rm ./configure.sh
30 changes: 3 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ This is an automated script to create an [Arch Linux](https://archlinux.org)
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` file and double-click it in `File Explorer` to
install the distribution.
page](https://github.com/DevelopersCommunity/archlinux-wsl/releases/latest). Get
the `.wsl` file and double-click it in `File Explorer` to install the
distribution.

## Requirements

Expand Down Expand Up @@ -54,30 +54,6 @@ the [Arch Linux logo](https://archlinux.org/art/) blue color. The script to
generate the profile is available in the [`terminal-profile`
directory](./terminal-profile/).

## Known issues

### systemd services won't start

If you get the following error when running the `systemctl` command, try to
[install another WSL distribution with `systemd`
support](https://aka.ms/wslsystemd/) and check if it works. In my case,
`systemd` started working on Arch Linux after that, and kept working even after
uninstalling the other distro.

```terminal
$ 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
14 changes: 13 additions & 1 deletion build
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ docker rmi "archwsl:${tag}"
[[ -d rootfs ]] && rm -rf rootfs
mkdir rootfs
pushd rootfs || exit 1
fakeroot bash -c "tar -xf ../archlinux.tar && rm -f etc/resolv.conf && tar --numeric-owner --absolute-names -c -- * | gzip --best >../archlinux.wsl"
trim=$(
cat <<EOF
tar -xf ../archlinux.tar &&
rm -f etc/resolv.conf &&
rm -f .dockerenv &&
rm -rf boot &&
rm -rf dev &&
rm -rf run &&
tar --numeric-owner --absolute-names -c -- * |
gzip --best >../archlinux-${tag}.wsl
EOF
)
fakeroot bash -c "${trim}"
popd || exit 1
rm archlinux.tar
20 changes: 12 additions & 8 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ 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
systemctl mask systemd-resolved.service
systemctl mask systemd-networkd.service
systemctl mask systemd-tmpfiles-setup.service
systemctl mask systemd-tmpfiles-clean.service
systemctl mask systemd-tmpfiles-clean.timer
systemctl mask systemd-tmpfiles-setup-dev-early.service
systemctl mask systemd-tmpfiles-setup-dev.service
systemctl mask tmp.mount

systemctl mask --global systemd-tmpfiles-setup.service
systemctl mask --global systemd-tmpfiles-clean.service
systemctl mask --global systemd-tmpfiles-clean.timer

# 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
Expand Down
51 changes: 0 additions & 51 deletions root/etc/oobe.sh

This file was deleted.

2 changes: 1 addition & 1 deletion root/etc/wsl-distribution.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# /etc/wsl-distribution.conf

[oobe]
command = /etc/oobe.sh
command = /usr/lib/wsl/oobe.sh
defaultUid = 1000
defaultName = Arch-Linux-Unofficial

Expand Down
56 changes: 56 additions & 0 deletions root/usr/lib/wsl/oobe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
#
# Out of box experience script

set -ue

DEFAULT_UID='1000'

echo 'Please create a default UNIX user account. The username does not need to match your Windows username.'
echo 'For more information visit: https://aka.ms/wslusers'

if getent passwd "${DEFAULT_UID}" >/dev/null; then
echo 'User account already exists, skipping creation'
exit 0
fi

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

# Initialize and populate the pacman keyring
# https://wiki.archlinux.org/title/Pacman/Package_signing#Initializing_the_keyring
pacman-key --init
pacman-key --populate archlinux
pacman -S --noconfirm --needed archlinux-keyring

while true; do
# Prompt for the username
read -rp 'Enter new UNIX username: ' username

# Create the user
if useradd --uid "${DEFAULT_UID}" --create-home --user-group --groups wheel "${username}"; then
while ! passwd "${username}"; do
while true; do
read -rp 'Try again? [y/N] ' try_again
case "${try_again}" in
[yY])
continue 2
;;
"" | [nN])
break 2
;;
*)
continue
;;
esac
done
done
break
else
userdel "${username}"
fi
done
Loading