2020-03-28 15:24:17 +01:00
|
|
|
|
name: "Test"
|
|
|
|
|
on:
|
|
|
|
|
pull_request:
|
|
|
|
|
push:
|
2024-10-22 14:07:25 +11:00
|
|
|
|
branches:
|
|
|
|
|
- master
|
2023-04-28 13:26:11 +02:00
|
|
|
|
|
2023-05-19 13:33:38 +02:00
|
|
|
|
env:
|
2025-01-08 19:10:22 +00:00
|
|
|
|
NIXPKGS_BRANCH: nixpkgs-unstable
|
|
|
|
|
NIX_VERSION: 2.24.11
|
2023-05-19 13:33:38 +02:00
|
|
|
|
|
2020-03-28 15:24:17 +01:00
|
|
|
|
jobs:
|
2025-01-08 19:10:22 +00:00
|
|
|
|
# The `test-stable` and `install-against-stable` job names are
|
|
|
|
|
# load‐bearing, despite their inaccuracy on the unstable branch, as
|
|
|
|
|
# they are set as required checks in the repository configuration,
|
|
|
|
|
# which only repository admins can change.
|
|
|
|
|
#
|
|
|
|
|
# TODO: Change them once the repository configuration is updated.
|
2023-05-19 13:33:38 +02:00
|
|
|
|
|
2025-01-08 19:10:22 +00:00
|
|
|
|
test-stable:
|
2024-11-05 03:21:37 +11:00
|
|
|
|
runs-on: macos-13
|
2020-03-28 15:24:17 +01:00
|
|
|
|
steps:
|
2024-11-04 14:37:59 +11:00
|
|
|
|
- uses: actions/checkout@v4
|
2025-01-08 19:10:22 +00:00
|
|
|
|
- name: Install Nix
|
2024-10-22 14:48:39 +11:00
|
|
|
|
uses: cachix/install-nix-action@v30
|
2024-09-10 21:14:05 +01:00
|
|
|
|
with:
|
2025-01-08 19:10:22 +00:00
|
|
|
|
install_url: https://releases.nixos.org/nix/nix-${{ env.NIX_VERSION }}/install
|
|
|
|
|
- run: nix flake check --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
|
2023-04-28 13:26:11 +02:00
|
|
|
|
|
2023-05-19 13:33:38 +02:00
|
|
|
|
install-against-stable:
|
2024-11-05 03:21:37 +11:00
|
|
|
|
runs-on: macos-13
|
2025-01-08 19:10:22 +00:00
|
|
|
|
timeout-minutes: 30
|
2020-03-28 15:24:17 +01:00
|
|
|
|
steps:
|
2024-11-04 14:37:59 +11:00
|
|
|
|
- uses: actions/checkout@v4
|
2025-01-08 19:10:22 +00:00
|
|
|
|
- name: Install Nix
|
2024-10-22 14:48:39 +11:00
|
|
|
|
uses: cachix/install-nix-action@v30
|
2023-04-28 13:26:11 +02:00
|
|
|
|
with:
|
2025-01-08 19:10:22 +00:00
|
|
|
|
install_url: https://releases.nixos.org/nix/nix-${{ env.NIX_VERSION }}/install
|
|
|
|
|
nix_path: nixpkgs=channel:${{ env.NIXPKGS_BRANCH }}
|
2024-11-17 02:51:42 +11:00
|
|
|
|
- name: Install channels
|
2023-05-19 13:33:38 +02:00
|
|
|
|
run: |
|
2025-01-08 19:10:22 +00:00
|
|
|
|
nix-channel --add https://nixos.org/channels/${{ env.NIXPKGS_BRANCH }} nixpkgs
|
2020-03-28 15:24:17 +01:00
|
|
|
|
nix-channel --update
|
2024-11-17 02:14:06 +11:00
|
|
|
|
- name: Install nix-darwin
|
2023-05-19 13:33:38 +02:00
|
|
|
|
run: |
|
2025-01-13 23:21:04 +00:00
|
|
|
|
sudo mkdir -p /etc/nix-darwin
|
|
|
|
|
sudo cp modules/examples/simple.nix /etc/nix-darwin/configuration.nix
|
2023-06-24 13:58:56 +10:00
|
|
|
|
|
|
|
|
|
nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
|
2025-01-13 23:21:04 +00:00
|
|
|
|
sudo /usr/bin/sed -i.bak \
|
2025-01-26 21:38:12 +00:00
|
|
|
|
"s/# programs.fish.enable = true;/ \
|
|
|
|
|
imports = [ \
|
|
|
|
|
({ options, ... }: { \
|
|
|
|
|
nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; \
|
|
|
|
|
environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ]; \
|
|
|
|
|
nix.nixPath = \
|
|
|
|
|
[ { darwin = \"${PWD////\/}\"; } ] \
|
|
|
|
|
++ options.nix.nixPath.default; \
|
|
|
|
|
}) \
|
|
|
|
|
]; \
|
|
|
|
|
/" \
|
2025-01-13 23:21:04 +00:00
|
|
|
|
/etc/nix-darwin/configuration.nix
|
2023-06-24 13:58:56 +10:00
|
|
|
|
|
2025-01-13 23:21:04 +00:00
|
|
|
|
nix run .#darwin-rebuild -- switch \
|
2025-01-26 21:38:12 +00:00
|
|
|
|
-I darwin=. \
|
2025-01-13 23:21:04 +00:00
|
|
|
|
-I darwin-config=/etc/nix-darwin/configuration.nix
|
2024-11-17 16:16:32 +11:00
|
|
|
|
- name: Switch to new configuration
|
2023-05-19 13:33:38 +02:00
|
|
|
|
run: |
|
2024-11-19 12:50:32 +11:00
|
|
|
|
. /etc/bashrc
|
2024-11-17 16:16:32 +11:00
|
|
|
|
|
2025-01-13 23:21:04 +00:00
|
|
|
|
sudo /usr/bin/sed -i.bak \
|
2024-11-17 16:16:32 +11:00
|
|
|
|
"s/pkgs.vim/pkgs.hello/" \
|
2025-01-13 23:21:04 +00:00
|
|
|
|
/etc/nix-darwin/configuration.nix
|
2024-11-17 16:16:32 +11:00
|
|
|
|
|
2025-01-26 21:38:12 +00:00
|
|
|
|
darwin-rebuild switch
|
2024-11-17 16:16:32 +11:00
|
|
|
|
|
|
|
|
|
hello
|
2023-05-19 13:33:38 +02:00
|
|
|
|
- name: Test uninstallation of nix-darwin
|
|
|
|
|
run: |
|
2024-11-19 12:54:51 +11:00
|
|
|
|
# We need to specify `--extra-experimental-features` because `experimental-features` is set by
|
|
|
|
|
# `cachix/install-nix-action` but not by our default config above
|
2024-11-05 02:48:25 +11:00
|
|
|
|
nix run .#darwin-uninstaller \
|
2024-11-19 12:54:51 +11:00
|
|
|
|
--extra-experimental-features "nix-command flakes" \
|
2025-01-08 19:10:22 +00:00
|
|
|
|
--override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
|
2024-11-05 02:48:25 +11:00
|
|
|
|
nix run .#darwin-uninstaller.tests.uninstaller \
|
2024-11-19 12:54:51 +11:00
|
|
|
|
--extra-experimental-features "nix-command flakes" \
|
2025-01-08 19:10:22 +00:00
|
|
|
|
--override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
|
2023-05-19 13:33:38 +02:00
|
|
|
|
|
2025-01-08 19:10:22 +00:00
|
|
|
|
install-flake:
|
2024-11-05 03:21:37 +11:00
|
|
|
|
runs-on: macos-13
|
2023-05-19 13:33:38 +02:00
|
|
|
|
timeout-minutes: 30
|
|
|
|
|
steps:
|
2024-11-04 14:37:59 +11:00
|
|
|
|
- uses: actions/checkout@v4
|
2025-01-08 19:10:22 +00:00
|
|
|
|
- name: Install Nix
|
2024-10-22 14:48:39 +11:00
|
|
|
|
uses: cachix/install-nix-action@v30
|
2024-09-10 21:14:05 +01:00
|
|
|
|
with:
|
2025-01-08 19:10:22 +00:00
|
|
|
|
install_url: https://releases.nixos.org/nix/nix-${{ env.NIX_VERSION }}/install
|
2023-06-20 22:54:31 +10:00
|
|
|
|
- name: Install nix-darwin
|
2023-04-28 13:26:11 +02:00
|
|
|
|
run: |
|
2025-01-13 23:21:04 +00:00
|
|
|
|
sudo mkdir -p /etc/nix-darwin
|
2023-06-24 13:58:56 +10:00
|
|
|
|
darwin=$(pwd)
|
2025-01-13 23:21:04 +00:00
|
|
|
|
pushd /etc/nix-darwin
|
|
|
|
|
sudo nix flake init -t $darwin
|
2023-06-24 13:58:56 +10:00
|
|
|
|
nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
|
2025-01-13 23:21:04 +00:00
|
|
|
|
sudo /usr/bin/sed -i.bak \
|
2024-11-11 22:30:42 +11:00
|
|
|
|
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
|
2023-06-24 13:58:56 +10:00
|
|
|
|
flake.nix
|
2025-01-13 23:21:04 +00:00
|
|
|
|
sudo /usr/bin/sed -i.bak \
|
|
|
|
|
's/darwinConfigurations."simple"/darwinConfigurations."'$(scutil --get LocalHostName)'"/g' \
|
|
|
|
|
flake.nix
|
|
|
|
|
sudo /usr/bin/sed -i.bak \
|
2024-11-17 13:11:30 +11:00
|
|
|
|
's/nixpkgs.hostPlatform = "aarch64-darwin";/nixpkgs.hostPlatform = "'$(nix eval --expr builtins.currentSystem --impure --raw)'";/' \
|
|
|
|
|
flake.nix
|
2023-06-24 13:58:56 +10:00
|
|
|
|
popd
|
2025-01-13 23:21:04 +00:00
|
|
|
|
nix run .#darwin-rebuild -- switch \
|
2023-07-13 22:35:54 +10:00
|
|
|
|
--override-input nix-darwin . \
|
2025-01-08 19:10:22 +00:00
|
|
|
|
--override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
|
2024-11-17 16:16:32 +11:00
|
|
|
|
- name: Switch to new configuration
|
2023-04-28 13:26:11 +02:00
|
|
|
|
run: |
|
2024-11-19 12:50:32 +11:00
|
|
|
|
. /etc/bashrc
|
2024-11-17 16:16:32 +11:00
|
|
|
|
|
2025-01-13 23:21:04 +00:00
|
|
|
|
sudo /usr/bin/sed -i.bak \
|
2024-11-17 16:16:32 +11:00
|
|
|
|
"s/pkgs.vim/pkgs.hello/" \
|
2025-01-13 23:21:04 +00:00
|
|
|
|
/etc/nix-darwin/flake.nix
|
2024-11-17 16:16:32 +11:00
|
|
|
|
|
2025-01-13 23:21:04 +00:00
|
|
|
|
darwin-rebuild switch \
|
2024-11-17 13:11:30 +11:00
|
|
|
|
--override-input nix-darwin . \
|
2025-01-08 19:10:22 +00:00
|
|
|
|
--override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
|
2024-11-17 16:16:32 +11:00
|
|
|
|
|
|
|
|
|
hello
|
2024-11-04 11:55:15 +11:00
|
|
|
|
- name: Test uninstallation of nix-darwin
|
|
|
|
|
run: |
|
2025-01-08 19:10:22 +00:00
|
|
|
|
nix run .#darwin-uninstaller --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
|
|
|
|
|
nix run .#darwin-uninstaller.tests.uninstaller --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
|