mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
uninstaller: switch to writeShellApplication
By not defining a `shellHook`, `nix-shell -A uninstaller` and `nix-shell -A uninstaller.check` no longer work.
This commit is contained in:
parent
c3b406bd1c
commit
ebca0c23c9
2 changed files with 50 additions and 63 deletions
18
.github/workflows/test.yml
vendored
18
.github/workflows/test.yml
vendored
|
@ -66,9 +66,12 @@ jobs:
|
|||
darwin-rebuild switch -I darwin=.
|
||||
- name: Test uninstallation of nix-darwin
|
||||
run: |
|
||||
export NIX_PATH=$HOME/.nix-defexpr/channels
|
||||
nix-shell -A uninstaller
|
||||
nix-shell -A uninstaller.check
|
||||
nix run .#darwin-uninstaller \
|
||||
--override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }} \
|
||||
--extra-experimental-features "nix-command flakes"
|
||||
nix run .#darwin-uninstaller.tests.uninstaller \
|
||||
--override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }} \
|
||||
--extra-experimental-features "nix-command flakes"
|
||||
- name: Debugging tmate session
|
||||
if: ${{ failure() }}
|
||||
uses: mxschmitt/action-tmate@v3
|
||||
|
@ -111,9 +114,12 @@ jobs:
|
|||
darwin-rebuild switch -I darwin=.
|
||||
- name: Test uninstallation of nix-darwin
|
||||
run: |
|
||||
export NIX_PATH=$HOME/.nix-defexpr/channels
|
||||
nix-shell -A uninstaller
|
||||
nix-shell -A uninstaller.check
|
||||
nix run .#darwin-uninstaller \
|
||||
--override-input nixpkgs nixpkgs/nixpkgs-unstable \
|
||||
--extra-experimental-features "nix-command flakes"
|
||||
nix run .#darwin-uninstaller.tests.uninstaller \
|
||||
--override-input nixpkgs nixpkgs/nixpkgs-unstable \
|
||||
--extra-experimental-features "nix-command flakes"
|
||||
- name: Debugging tmate session
|
||||
if: ${{ failure() }}
|
||||
uses: mxschmitt/action-tmate@v3
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ stdenv, lib, pkgs }:
|
||||
{ lib, path, stdenv, writeShellApplication }:
|
||||
|
||||
let
|
||||
uninstallSystem = import ../../eval-config.nix {
|
||||
|
@ -6,39 +6,23 @@ let
|
|||
modules = [
|
||||
./configuration.nix
|
||||
{
|
||||
nixpkgs.source = pkgs.path;
|
||||
nixpkgs.hostPlatform = pkgs.stdenv.hostPlatform.system;
|
||||
nixpkgs.source = path;
|
||||
nixpkgs.hostPlatform = stdenv.hostPlatform.system;
|
||||
system.includeUninstaller = false;
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
in writeShellApplication {
|
||||
name = "darwin-uninstaller";
|
||||
preferLocalBuild = true;
|
||||
|
||||
unpackPhase = ":";
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
echo "$shellHook" > $out/bin/darwin-uninstaller
|
||||
chmod +x $out/bin/darwin-uninstaller
|
||||
'';
|
||||
|
||||
shellHook = ''
|
||||
#!${stdenv.shell}
|
||||
set -e
|
||||
|
||||
action=switch
|
||||
text = ''
|
||||
while [ "$#" -gt 0 ]; do
|
||||
i="$1"; shift 1
|
||||
case "$i" in
|
||||
--help)
|
||||
echo "darwin-uninstaller: [--help]"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
i="$1"; shift 1
|
||||
case "$i" in
|
||||
--help)
|
||||
echo "darwin-uninstaller: [--help]"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo >&2
|
||||
|
@ -50,15 +34,15 @@ stdenv.mkDerivation {
|
|||
echo >&2 " - restore daemon service from nix installer (only when this is a multi-user install)"
|
||||
echo >&2
|
||||
|
||||
if test -t 0; then
|
||||
read -p "Proceed? [y/n] " i
|
||||
case "$i" in
|
||||
y|Y)
|
||||
;;
|
||||
*)
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
if [[ -t 0 ]]; then
|
||||
read -r -p "Proceed? [y/n] " i
|
||||
case "$i" in
|
||||
y|Y)
|
||||
;;
|
||||
*)
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
${uninstallSystem.system}/sw/bin/darwin-rebuild activate
|
||||
|
@ -83,29 +67,26 @@ stdenv.mkDerivation {
|
|||
echo >&2
|
||||
echo >&2 "Done!"
|
||||
echo >&2
|
||||
exit
|
||||
'';
|
||||
|
||||
passthru.check = stdenv.mkDerivation {
|
||||
name = "run-darwin-test";
|
||||
shellHook = ''
|
||||
set -e
|
||||
echo >&2 "running uninstaller tests..."
|
||||
echo >&2
|
||||
derivationArgs.passthru.tests.uninstaller = writeShellApplication {
|
||||
name = "post-uninstall-test";
|
||||
text = ''
|
||||
echo >&2 "running uninstaller tests..."
|
||||
echo >&2
|
||||
|
||||
echo >&2 "checking darwin channel"
|
||||
! test -e ~/.nix-defexpr/channels/darwin
|
||||
echo >&2 "checking /etc"
|
||||
! test -e /etc/static
|
||||
echo >&2 "checking /run/current-system"
|
||||
! test -e /run/current-system
|
||||
echo >&2 "checking nix-daemon service (assuming a multi-user install)"
|
||||
sudo launchctl list | grep org.nixos.nix-daemon || echo "FIXME? sudo launchctl list | grep org.nixos.nix-daemon"
|
||||
pgrep -l nix-daemon || echo "FIXME? pgrep -l nix-daemon"
|
||||
readlink /Library/LaunchDaemons/org.nixos.nix-daemon.plist || echo "FIXME? readlink /Library/LaunchDaemons/org.nixos.nix-daemon.plist"
|
||||
grep /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt /Library/LaunchDaemons/org.nixos.nix-daemon.plist || echo "FIXME? grep /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt /Library/LaunchDaemons/org.nixos.nix-daemon.plist"
|
||||
echo >&2 ok
|
||||
exit
|
||||
echo >&2 "checking darwin channel"
|
||||
test -e ~/.nix-defexpr/channels/darwin && exit 1
|
||||
echo >&2 "checking /etc"
|
||||
test -e /etc/static && exit 1
|
||||
echo >&2 "checking /run/current-system"
|
||||
test -e /run/current-system && exit 1
|
||||
echo >&2 "checking nix-daemon service (assuming a multi-user install)"
|
||||
sudo launchctl list | grep org.nixos.nix-daemon || echo "FIXME? sudo launchctl list | grep org.nixos.nix-daemon"
|
||||
pgrep -l nix-daemon || echo "FIXME? pgrep -l nix-daemon"
|
||||
readlink /Library/LaunchDaemons/org.nixos.nix-daemon.plist || echo "FIXME? readlink /Library/LaunchDaemons/org.nixos.nix-daemon.plist"
|
||||
grep /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt /Library/LaunchDaemons/org.nixos.nix-daemon.plist || echo "FIXME? grep /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt /Library/LaunchDaemons/org.nixos.nix-daemon.plist"
|
||||
echo >&2 ok
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue