1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-15 17:51:01 +00:00
nix-darwin/.github/workflows/test.yml
2022-12-14 03:45:00 -07:00

116 lines
3.9 KiB
YAML

name: "Test"
on:
pull_request:
push:
jobs:
tests:
runs-on: macos-12
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v17
- run: nix-build ./release.nix -I nixpkgs=channel:nixpkgs-22.05-darwin -I darwin=. -A tests
- run: nix-build ./release.nix -I nixpkgs=channel:nixpkgs-22.05-darwin -I darwin=. -A manpages
- run: nix-build ./release.nix -I nixpkgs=channel:nixpkgs-22.05-darwin -I darwin=. -A examples.simple
install:
runs-on: macos-12
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v17
- run: |
nix-channel --add https://nixos.org/channels/nixpkgs-22.05-darwin nixpkgs
nix-channel --update
- run: |
export NIX_PATH=$HOME/.nix-defexpr/channels
nix-shell -A installer
nix-shell -A installer.check
- run: |
. /etc/static/bashrc
darwin-rebuild switch -I darwin=.
- run: |
export NIX_PATH=$HOME/.nix-defexpr/channels
nix-shell -A uninstaller
nix-shell -A uninstaller.check
- name: Debugging tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 15
with:
limit-access-to-actor: true
install-flake:
runs-on: macos-12
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: cachix/install-nix-action@v17
with:
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.10.0pre20220808_73fde9e/install
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- run: |
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
nix-channel --update
- run: |
export NIX_PATH=$HOME/.nix-defexpr/channels
nix-shell -A installer
- run: |
nix build ./modules/examples#darwinConfigurations.simple.system --override-input darwin .
- run: |
./result/sw/bin/darwin-rebuild switch --flake ./modules/examples#simple --override-input darwin .
- run: |
. /etc/static/bashrc
darwin-rebuild build --flake ./modules/examples#simple --override-input darwin .
- name: Test git submodules
run: |
. /etc/static/bashrc
mkdir -p /tmp/{test-nix-darwin-submodules,example-submodule}
pushd /tmp/example-submodule
echo '"hello"' > hello.nix
git init
git add .
git commit -m "add a submodule we will import"
popd
cp -a ./modules/examples/. /tmp/test-nix-darwin-submodules
pushd /tmp/test-nix-darwin-submodules
/usr/bin/sed -i.bak \
'\#modules = \[#s#darwin.darwinModules.simple#./simple.nix#' \
./flake.nix
/usr/bin/sed -i.bak \
's#pkgs.vim#pkgs."${import ./submodule-test/hello.nix}"#' \
./simple.nix
git init
git add flake.nix simple.nix
git \
-c protocol.file.allow=always \
submodule add /tmp/example-submodule submodule-test
popd
# Should fail
darwin-rebuild build \
--flake /tmp/test-nix-darwin-submodules#simple \
--override-input darwin . \
&& {
printf 'succeeded while expecting failure due to submodule\n' >/dev/stderr
exit 1
}
# Should also fail
darwin-rebuild build \
--flake /tmp/test-nix-darwin-submodules?submodules=0#simple \
--override-input darwin . \
&& {
printf 'succeeded while expecting failure due to submodule\n' >/dev/stderr
exit 1
}
# Should succeed
darwin-rebuild build \
--flake /tmp/test-nix-darwin-submodules?submodules=1#simple \
--override-input darwin .