Support nix-shell by logging in as root
This commit is contained in:
parent
c9302471e8
commit
24d95eee5e
|
|
@ -1,7 +1,7 @@
|
|||
# A comprehensive test for NixOS.
|
||||
#
|
||||
# This test suite is designed to run on GitHub's larger runners,
|
||||
# leveraging their extended storage capacity.
|
||||
# leveraging their extended storage capacity.
|
||||
# Here, we can thoroughly test a wider range of NixOS commands and various applications.
|
||||
# As GitHub charges more for these premium runners,
|
||||
# these tests will only run when changes are detected in AsterNixOS-specific content.
|
||||
|
|
@ -33,7 +33,12 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
- name: Use nix-env to install and run the hello package
|
||||
run: |
|
||||
make run NIXOS=1 NIXOS_DISK_SIZE_IN_MB=4096 NIXOS_STAGE_2_INIT="nix-env -iA nixos.hello && hello && sync" || true
|
||||
make run NIXOS=1 NIXOS_DISK_SIZE_IN_MB=4096 NIXOS_STAGE_2_INIT='/bin/sh -l -c "nix-env -iA nixos.hello && hello && sync"' || true
|
||||
tail --lines 10 qemu.log | grep -q "^Hello, world!" || (echo "Test nix-env failed" && exit 1)
|
||||
echo "Test nix-env succeeds!"
|
||||
- name: Use nix-shell to install and run the hello package
|
||||
run: |
|
||||
make run NIXOS=1 NIXOS_DISK_SIZE_IN_MB=4096 NIXOS_STAGE_2_INIT='/bin/sh -l -c "nix-shell -p hello --command hello && sync"' || true
|
||||
tail --lines 10 qemu.log | grep -q "^Hello, world!" || (echo "Test nix-shell failed" && exit 1)
|
||||
echo "Test nix-shell succeeds!"
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ jobs:
|
|||
with:
|
||||
image: asterinas/asterinas:0.16.1-20251130
|
||||
options: --privileged -v /dev:/dev -v ${{ github.workspace }}:/root/asterinas
|
||||
run: make run NIXOS=1 NIXOS_DISK_SIZE_IN_MB=4096 NIXOS_STAGE_2_INIT="hello-asterinas" || true
|
||||
run: make run NIXOS=1 NIXOS_DISK_SIZE_IN_MB=4096 NIXOS_STAGE_2_INIT='/bin/sh -l -c "hello-asterinas"' || true
|
||||
- name: Check results
|
||||
run: |
|
||||
tail --lines 10 ${{ github.workspace }}/qemu.log | grep -q "^Hello Asterinas!" || (echo "Test NixOS failed" && exit 1)
|
||||
|
|
|
|||
3
Makefile
3
Makefile
|
|
@ -59,7 +59,8 @@ NIXOS ?= 0
|
|||
NIXOS_DISK_SIZE_IN_MB ?= 8196
|
||||
NIXOS_DISABLE_SYSTEMD ?= true
|
||||
# The following option is only effective when NIXOS_DISABLE_SYSTEMD is set to 'true'.
|
||||
NIXOS_STAGE_2_INIT ?= /bin/sh
|
||||
# Use a login shell to ensure that environment variables are initialized correctly.
|
||||
NIXOS_STAGE_2_INIT ?= /bin/sh -l
|
||||
# End of NixOS settings
|
||||
|
||||
# ========================= End of Makefile options. ==========================
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ in {
|
|||
echo "Executing postBootCommands..."
|
||||
rm -rf /etc/resolv.conf
|
||||
ln -s ${resolv-conf} /etc/resolv.conf
|
||||
PATH=$PATH:/nix/var/nix/profiles/system/sw/bin:~/.nix-profile/bin
|
||||
if [ "${builtins.getEnv "NIXOS_DISABLE_SYSTEMD"}" = "true" ]; then
|
||||
${builtins.getEnv "NIXOS_STAGE_2_INIT"}
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in New Issue