summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hoang <Enzime@users.noreply.github.com>2023-11-24 14:11:34 +1100
committerGitHub <noreply@github.com>2023-11-24 14:11:34 +1100
commit4b9b83d5a92e8c1fbfd8eb27eda375908c11ec4d (patch)
tree6138d59bce2e227602d0687d0d4ad34e2a5b1ad1
parent7e8d292728e480e9e602f1884dbc124fe010e803 (diff)
parent09284ab00b2bf86b0d33bae8cf8b1a999bb512d9 (diff)
Merge pull request #806 from DeterminateSystems/easier-uninstall
Install darwin-uninstall by default, which includes the 'empty' config it switches to
-rw-r--r--default.nix4
-rw-r--r--flake.nix2
-rw-r--r--modules/nix/nix-darwin.nix16
-rw-r--r--pkgs/darwin-uninstaller/configuration.nix2
-rw-r--r--pkgs/darwin-uninstaller/default.nix28
5 files changed, 28 insertions, 24 deletions
diff --git a/default.nix b/default.nix
index 7c7e06b..c93b478 100644
--- a/default.nix
+++ b/default.nix
@@ -16,7 +16,7 @@ let
};
};
- # The source code of this repo needed by the [un]installers.
+ # The source code of this repo needed by the installer.
nix-darwin = lib.cleanSource (
lib.cleanSourceWith {
# We explicitly specify a name here otherwise `cleanSource` will use the
@@ -30,5 +30,5 @@ in
eval // {
installer = pkgs.callPackage ./pkgs/darwin-installer { inherit nix-darwin; };
- uninstaller = pkgs.callPackage ./pkgs/darwin-uninstaller { inherit nix-darwin; };
+ uninstaller = pkgs.callPackage ./pkgs/darwin-uninstaller { };
}
diff --git a/flake.nix b/flake.nix
index d09f4d6..e25fe6a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -42,7 +42,7 @@
overlays.default = final: prev: {
inherit (prev.callPackage ./pkgs/nix-tools { }) darwin-rebuild darwin-option darwin-version;
- darwin-uninstaller = prev.callPackage ./pkgs/darwin-uninstaller { nix-darwin = self; };
+ darwin-uninstaller = prev.callPackage ./pkgs/darwin-uninstaller { };
};
darwinModules.hydra = ./modules/examples/hydra.nix;
diff --git a/modules/nix/nix-darwin.nix b/modules/nix/nix-darwin.nix
index 7f07b45..ad1ab8f 100644
--- a/modules/nix/nix-darwin.nix
+++ b/modules/nix/nix-darwin.nix
@@ -1,4 +1,4 @@
-{ config, pkgs, ... }:
+{ config, pkgs, lib, ... }:
let
nix-tools = pkgs.callPackage ../../pkgs/nix-tools {
@@ -7,22 +7,30 @@ let
nixPackage = config.nix.package;
};
+ darwin-uninstaller = pkgs.callPackage ../../pkgs/darwin-uninstaller { };
+
inherit (nix-tools) darwin-option darwin-rebuild darwin-version;
in
{
- config = {
+ options = {
+ system.includeUninstaller = lib.mkOption {
+ type = lib.types.bool;
+ internal = true;
+ default = true;
+ };
+ };
+ config = {
environment.systemPackages =
[ # Include nix-tools by default
darwin-option
darwin-rebuild
darwin-version
- ];
+ ] ++ lib.optional config.system.includeUninstaller darwin-uninstaller;
system.build = {
inherit darwin-option darwin-rebuild darwin-version;
};
-
};
}
diff --git a/pkgs/darwin-uninstaller/configuration.nix b/pkgs/darwin-uninstaller/configuration.nix
index 96a2165..6487774 100644
--- a/pkgs/darwin-uninstaller/configuration.nix
+++ b/pkgs/darwin-uninstaller/configuration.nix
@@ -1,4 +1,4 @@
-{ config, lib, pkgs, ... }:
+{ lib, ... }:
with lib;
diff --git a/pkgs/darwin-uninstaller/default.nix b/pkgs/darwin-uninstaller/default.nix
index ca7be48..94c0749 100644
--- a/pkgs/darwin-uninstaller/default.nix
+++ b/pkgs/darwin-uninstaller/default.nix
@@ -1,18 +1,17 @@
-{ stdenv, nix, pkgs, nix-darwin }:
+{ stdenv, lib, pkgs }:
let
- configuration = builtins.path {
- name = "nix-darwin-uninstaller-configuration";
- path = ./.;
- filter = name: _type: name != toString ./default.nix;
+ uninstallSystem = import ../../eval-config.nix {
+ inherit lib;
+ modules = [
+ ./configuration.nix
+ {
+ nixpkgs.source = pkgs.path;
+ nixpkgs.hostPlatform = pkgs.system;
+ system.includeUninstaller = false;
+ }
+ ];
};
-
- nixPath = pkgs.lib.concatStringsSep ":" [
- "darwin-config=${configuration}/configuration.nix"
- "darwin=${nix-darwin}"
- "nixpkgs=${pkgs.path}"
- "$NIX_PATH"
- ];
in
stdenv.mkDerivation {
@@ -62,10 +61,7 @@ stdenv.mkDerivation {
esac
fi
- export nix=${nix}
- export NIX_PATH=${nixPath}
- system=$($nix/bin/nix-build '<darwin>' -A system)
- $system/sw/bin/darwin-rebuild switch
+ ${uninstallSystem.system}/sw/bin/darwin-rebuild activate
if test -L /run/current-system; then
sudo rm /run/current-system