summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/test.yml12
-rw-r--r--README.md7
-rw-r--r--default.nix17
-rw-r--r--pkgs/darwin-installer/default.nix109
4 files changed, 14 insertions, 131 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 73a3fb7..43aed10 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -46,7 +46,7 @@ jobs:
nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin
nix-channel --add https://nixos.org/channels/${{ env.CURRENT_STABLE_CHANNEL }} nixpkgs
nix-channel --update
- - name: Install nix-darwin and test
+ - name: Install nix-darwin
run: |
export NIX_PATH=$HOME/.nix-defexpr/channels
@@ -58,7 +58,9 @@ jobs:
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
~/.config/nix-darwin/configuration.nix
- nix-shell -A installer -I darwin-config=$HOME/.config/nix-darwin/configuration.nix
+ nix run .#darwin-rebuild \
+ -- switch \
+ -I darwin-config=$HOME/.config/nix-darwin/configuration.nix
- name: Build and activate default derivation
run: |
. /etc/static/bashrc
@@ -93,7 +95,7 @@ jobs:
nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
nix-channel --update
- - name: Install nix-darwin and test
+ - name: Install nix-darwin
run: |
export NIX_PATH=$HOME/.nix-defexpr/channels
@@ -105,7 +107,9 @@ jobs:
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
~/.config/nix-darwin/configuration.nix
- nix-shell -A installer -I darwin-config=$HOME/.config/nix-darwin/configuration.nix
+ nix run .#darwin-rebuild \
+ -- switch \
+ -I darwin-config=$HOME/.config/nix-darwin/configuration.nix
- name: Build and activate default derivation
run: |
. /etc/static/bashrc
diff --git a/README.md b/README.md
index a4ce598..c7fb408 100644
--- a/README.md
+++ b/README.md
@@ -78,7 +78,7 @@ Make sure to set `nixpkgs.hostPlatform` in your `configuration.nix` to either `x
### Step 2. Installing `nix-darwin`
-Instead of using `darwin-installer`, you can just run `darwin-rebuild switch` to install nix-darwin. As `darwin-rebuild` won't be installed in your `PATH` yet, you can use the following command:
+Unlike NixOS, `nix-darwin` does not have an installer, you can just run `darwin-rebuild switch` to install nix-darwin. As `darwin-rebuild` won't be installed in your `PATH` yet, you can use the following command:
```bash
nix run nix-darwin -- switch --flake ~/.config/nix-darwin
@@ -128,9 +128,10 @@ nix-channel --update
### Step 3. Installing `nix-darwin`
+To install `nix-darwin`, you can just run `darwin-rebuild switch` to install nix-darwin. As `darwin-rebuild` won't be installed in your `PATH` yet, you can use the following command:
+
```bash
-nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
-./result/bin/darwin-installer
+nix --extra-experimental-features "nix-command flakes" run nix-darwin -- switch -I darwin-config=$HOME/.config/nix-darwin/configuration.nix
```
### Step 4. Using `nix-darwin`
diff --git a/default.nix b/default.nix
index c93b478..075ae6d 100644
--- a/default.nix
+++ b/default.nix
@@ -1,8 +1,8 @@
{ nixpkgs ? <nixpkgs>
, configuration ? <darwin-config>
-, lib ? pkgs.lib
-, pkgs ? import nixpkgs { inherit system; }
, system ? builtins.currentSystem
+, pkgs ? import nixpkgs { inherit system; }
+, lib ? pkgs.lib
}:
let
@@ -15,20 +15,7 @@ let
nixpkgs.system = lib.mkDefault system;
};
};
-
- # 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
- # basename of ./. which might be different for different clones of this
- # repo leading to non-reproducible outputs.
- name = "nix-darwin";
- src = ./.;
- }
- );
in
-
eval // {
- installer = pkgs.callPackage ./pkgs/darwin-installer { inherit nix-darwin; };
uninstaller = pkgs.callPackage ./pkgs/darwin-uninstaller { };
}
diff --git a/pkgs/darwin-installer/default.nix b/pkgs/darwin-installer/default.nix
deleted file mode 100644
index 630c5bf..0000000
--- a/pkgs/darwin-installer/default.nix
+++ /dev/null
@@ -1,109 +0,0 @@
-{ stdenv, nix, pkgs, nix-darwin }:
-
-let
- nixPath = pkgs.lib.concatStringsSep ":" [
- "darwin=${nix-darwin}"
- "nixpkgs=${pkgs.path}"
- "$HOME/.nix-defexpr/channels"
- "/nix/var/nix/profiles/per-user/root/channels"
- "$NIX_PATH"
- ];
-in
-
-stdenv.mkDerivation {
- name = "darwin-installer";
- preferLocalBuild = true;
-
- unpackPhase = ":";
-
- installPhase = ''
- mkdir -p $out/bin
- echo "$shellHook" > $out/bin/darwin-installer
- chmod +x $out/bin/darwin-installer
- '';
-
- shellHook = ''
- #!${stdenv.shell}
- set -e
-
- _PATH=$PATH
- export PATH=/nix/var/nix/profiles/default/bin:${nix}/bin:${pkgs.gnused}/bin:${pkgs.openssh}/bin:/usr/bin:/bin:/usr/sbin:/sbin
-
- action=switch
- while [ "$#" -gt 0 ]; do
- i="$1"; shift 1
- case "$i" in
- --help)
- echo "darwin-installer: [--help] [--check]"
- exit
- ;;
- --check)
- action=check
- ;;
- esac
- done
-
- echo >&2
- echo >&2 "Installing nix-darwin..."
- echo >&2
-
- export NIX_PATH=${nixPath}
- system=$(nix-build '<darwin>' -A system --no-out-link --show-trace)
-
- export PATH=$system/sw/bin:$PATH
- darwin-rebuild "$action"
-
- echo >&2
- echo >&2 " Installation complete."
- echo >&2 " See the README for more information: https://github.com/LnL7/nix-darwin/blob/master/README.md"
- echo >&2
- echo >&2 " Please log out and log in again to make sure nix-darwin is properly loaded."
- echo >&2
- exit
- '';
-
- passthru.check = stdenv.mkDerivation {
- name = "run-darwin-test";
- shellHook = ''
- set -e
- echo >&2 "running installer tests..."
- echo >&2
-
- echo >&2 "checking configuration.nix"
- test -f ~/.nixpkgs/darwin-configuration.nix
- test -w ~/.nixpkgs/darwin-configuration.nix
- echo >&2 "checking darwin channel"
- readlink ~/.nix-defexpr/channels/darwin
- test -e ~/.nix-defexpr/channels/darwin
- echo >&2 "checking /etc"
- readlink /etc/static
- test -e /etc/static
- echo >&2 "checking profile"
- cat /etc/profile
- (! grep nix-daemon.sh /etc/profile)
- echo >&2 "checking /run/current-system"
- readlink /run
- test -e /run
- readlink /run/current-system
- test -e /run/current-system
- echo >&2 "checking system profile"
- readlink /nix/var/nix/profiles/system
- test -e /nix/var/nix/profiles/system
-
- echo >&2 "checking bash environment"
- env -i USER=john HOME=/Users/john bash -li -c 'echo $PATH'
- env -i USER=john HOME=/Users/john bash -li -c 'echo $PATH' | grep /Users/john/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
- env -i USER=john HOME=/Users/john bash -li -c 'echo $NIX_PATH'
- env -i USER=john HOME=/Users/john bash -li -c 'echo $NIX_PATH' | grep darwin-config=/Users/john/.nixpkgs/darwin-configuration.nix:/nix/var/nix/profiles/per-user/root/channels
-
- echo >&2 "checking zsh environment"
- env -i USER=john HOME=/Users/john zsh -l -c 'echo $PATH'
- env -i USER=john HOME=/Users/john zsh -l -c 'echo $PATH' | grep /Users/john/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
- env -i USER=john HOME=/Users/john zsh -l -c 'echo $NIX_PATH'
- env -i USER=john HOME=/Users/john zsh -l -c 'echo $NIX_PATH' | grep darwin-config=/Users/john/.nixpkgs/darwin-configuration.nix:/nix/var/nix/profiles/per-user/root/channels
-
- echo >&2 ok
- exit
- '';
- };
-}