diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 92d06d4d..c531aa5f 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -41,37 +41,47 @@ jobs:
with:
install_url: https://releases.nixos.org/nix/nix-2.18.8/install
nix_path: nixpkgs=channel:${{ env.CURRENT_STABLE_CHANNEL }}
- - name: Install ${{ env.CURRENT_STABLE_CHANNEL }} channel
+ - name: Install channels
run: |
+ 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
- # We run nix-darwin twice to test that it can create darwin-configuration correctly for us
- # but we expect it to fail setting up /etc/nix/nix.conf
- nix-shell -A installer || true
+ mkdir -p ~/.config/nix-darwin
+ cp modules/examples/simple.nix ~/.config/nix-darwin/configuration.nix
nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
/usr/bin/sed -i.bak \
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
- ~/.nixpkgs/darwin-configuration.nix
+ ~/.config/nix-darwin/configuration.nix
- nix-shell -A installer
- nix-shell -A installer.check
- - name: Build and activate default derivation
+ nix run .#darwin-rebuild \
+ -- switch \
+ -I darwin-config=$HOME/.config/nix-darwin/configuration.nix
+ - name: Switch to new configuration
run: |
- . /etc/static/bashrc
+ . /etc/bashrc
+
+ /usr/bin/sed -i.bak \
+ "s/pkgs.vim/pkgs.hello/" \
+ ~/.config/nix-darwin/configuration.nix
+
darwin-rebuild switch -I darwin=.
+
+ hello
- name: Test uninstallation of nix-darwin
run: |
+ # We need to specify `--extra-experimental-features` because `experimental-features` is set by
+ # `cachix/install-nix-action` but not by our default config above
nix run .#darwin-uninstaller \
- --override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }} \
- --extra-experimental-features "nix-command flakes"
+ --extra-experimental-features "nix-command flakes" \
+ --override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }}
nix run .#darwin-uninstaller.tests.uninstaller \
- --override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }} \
- --extra-experimental-features "nix-command flakes"
+ --extra-experimental-features "nix-command flakes" \
+ --override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }}
- name: Debugging tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
@@ -89,32 +99,41 @@ jobs:
with:
install_url: https://releases.nixos.org/nix/nix-2.24.9/install
nix_path: nixpkgs=channel:nixpkgs-unstable
- - name: Install nixpkgs-unstable channel
+ - name: Install channels
run: |
+ 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
- # We run nix-darwin twice to test that it can create darwin-configuration correctly for us
- # but we expect it to fail setting up /etc/nix/nix.conf
- nix-shell -A installer || true
+ mkdir -p ~/.config/nix-darwin
+ cp modules/examples/simple.nix ~/.config/nix-darwin/configuration.nix
nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
/usr/bin/sed -i.bak \
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
- ~/.nixpkgs/darwin-configuration.nix
+ ~/.config/nix-darwin/configuration.nix
- nix-shell -A installer
- nix-shell -A installer.check
- - name: Build and activate default derivation
+ nix run .#darwin-rebuild \
+ -- switch \
+ -I darwin-config=$HOME/.config/nix-darwin/configuration.nix
+ - name: Switch to new configuration
run: |
- . /etc/static/bashrc
+ . /etc/bashrc
+
+ /usr/bin/sed -i.bak \
+ "s/pkgs.vim/pkgs.hello/" \
+ ~/.config/nix-darwin/configuration.nix
+
darwin-rebuild switch -I darwin=.
+
+ hello
- name: Test uninstallation of nix-darwin
run: |
- # A regression in Nix 2.19 means we need to put `--extra-experimental-features` before `--override-input`
+ # We need to specify `--extra-experimental-features` because `experimental-features` is set by
+ # `cachix/install-nix-action` but not by our default config above
nix run .#darwin-uninstaller \
--extra-experimental-features "nix-command flakes" \
--override-input nixpkgs nixpkgs/nixpkgs-unstable
@@ -147,15 +166,27 @@ jobs:
/usr/bin/sed -i.bak \
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
flake.nix
+ /usr/bin/sed -i.bak \
+ 's/nixpkgs.hostPlatform = "aarch64-darwin";/nixpkgs.hostPlatform = "'$(nix eval --expr builtins.currentSystem --impure --raw)'";/' \
+ flake.nix
popd
nix run .#darwin-rebuild -- \
switch --flake ~/.config/nix-darwin#simple \
--override-input nix-darwin . \
--override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }}
- - name: Rebuild and activate simple flake, but this time using nix-darwin's flake interface
+ - name: Switch to new configuration
run: |
- . /etc/static/bashrc
- darwin-rebuild build --flake ./modules/examples/flake#simple --override-input nix-darwin . --override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }}
+ . /etc/bashrc
+
+ /usr/bin/sed -i.bak \
+ "s/pkgs.vim/pkgs.hello/" \
+ ~/.config/nix-darwin/flake.nix
+
+ darwin-rebuild switch --flake ~/.config/nix-darwin#simple \
+ --override-input nix-darwin . \
+ --override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }}
+
+ hello
- name: Test uninstallation of nix-darwin
run: |
nix run .#darwin-uninstaller --override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }}
@@ -180,15 +211,27 @@ jobs:
/usr/bin/sed -i.bak \
"s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
flake.nix
+ /usr/bin/sed -i.bak \
+ 's/nixpkgs.hostPlatform = "aarch64-darwin";/nixpkgs.hostPlatform = "'$(nix eval --expr builtins.currentSystem --impure --raw)'";/' \
+ flake.nix
popd
nix run .#darwin-rebuild -- \
switch --flake ~/.config/nix-darwin#simple \
--override-input nix-darwin . \
--override-input nixpkgs nixpkgs/nixpkgs-unstable
- - name: Rebuild and activate simple flake, but this time using nix-darwin's flake interface
+ - name: Switch to new configuration
run: |
- . /etc/static/bashrc
- darwin-rebuild build --flake ./modules/examples/flake#simple --override-input nix-darwin . --override-input nixpkgs nixpkgs/nixpkgs-unstable
+ . /etc/bashrc
+
+ /usr/bin/sed -i.bak \
+ "s/pkgs.vim/pkgs.hello/" \
+ ~/.config/nix-darwin/flake.nix
+
+ darwin-rebuild switch --flake ~/.config/nix-darwin#simple \
+ --override-input nix-darwin . \
+ --override-input nixpkgs nixpkgs/nixpkgs-unstable
+
+ hello
- name: Test uninstallation of nix-darwin
run: |
nix run .#darwin-uninstaller --override-input nixpkgs nixpkgs/nixpkgs-unstable
diff --git a/README.md b/README.md
index 58bde794..d5373273 100644
--- a/README.md
+++ b/README.md
@@ -18,60 +18,14 @@ As the official Nix installer does not include an automated uninstaller, and man
- The [Nix installer from Determinate Systems](https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#determinate-nix-installer) is only recommended for use with flake-based setups. **Make sure you use it without the `--determinate` flag**. The `--determinate` flag installs the Determinate Nix distribution which does not work out of the box with nix-darwin.
* The [Lix installer](https://lix.systems/install/#on-any-other-linuxmacos-system) supports both flake-based and channel-based setups.
-## Installing
-If you wish to use nix-darwin with flakes, please refer to the [flakes](#flakes) section.
-```bash
-nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
-./result/bin/darwin-installer
-```
+## Getting started
-## Updating
+Despite being an experimental feature in Nix currently, nix-darwin recommends that beginners use flakes to manage their nix-darwin configurations.
-The installer will configure a channel for this repository.
-
-```bash
-nix-channel --update darwin
-darwin-rebuild changelog
-```
-
-> NOTE: If you are using Nix as a daemon service the channel for that will be owned by root.
-> Use `sudo -i nix-channel --update darwin` instead.
-
-## Uninstalling
-
-To run the latest version of the uninstaller, you can run the following command:
-
-```
-nix --extra-experimental-features "nix-command flakes" run nix-darwin#darwin-uninstaller
-```
-
-If that command doesn't work for you, you can try the locally installed uninstaller:
-
-```
-darwin-uninstaller
-```
-
-## Example configuration
-
-Configuration lives in `~/.nixpkgs/darwin-configuration.nix`. Check out
-[modules/examples](https://github.com/LnL7/nix-darwin/tree/master/modules/examples) for some example configurations.
-
-```nix
-{ pkgs, ... }:
-{
- # List packages installed in system profile. To search by name, run:
- # $ nix-env -qaP | grep wget
- environment.systemPackages =
- [ pkgs.vim
- ];
-}
-```
-
-## Flakes
-
-nix-darwin aims for both non-flake and flake configurations to be well supported despite flakes being an experimental feature in Nix.
+
+Flakes (Recommended for beginners)
### Step 1. Creating `flake.nix`
@@ -124,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
@@ -156,34 +110,67 @@ nix-darwin.lib.darwinSystem {
{ pkgs, lib, inputs }:
# inputs.self, inputs.nix-darwin, and inputs.nixpkgs can be accessed here
```
+
+
+
+Channels
+
+### Step 1. Creating `configuration.nix`
+
+Copy the [simple](./modules/examples/simple.nix) example to `~/.config/nix-darwin/configuration.nix`.
+
+### Step 2. Adding `nix-darwin` channel
+
+```bash
+nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin
+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 darwin-rebuild
+./result/bin/darwin-rebuild switch -I darwin-config=$HOME/.config/nix-darwin/configuration.nix
+```
+
+### Step 4. Using `nix-darwin`
+
+After installing, you can run `darwin-rebuild` to apply changes to your system:
+
+```bash
+darwin-rebuild switch
+```
+
+### Step 5. Updating `nix-darwin`
+
+You can update `nix-darwin` using the following command:
+
+```bash
+nix-channel --update darwin
+```
+
## Documentation
-Reference documentation of all the options is available [here](https://daiderd.com/nix-darwin/manual/index.html).
-This can also be accessed locally using `man 5 configuration.nix`.
+`darwin-help` will open up a local copy of the reference documentation, it can also be found online [here](https://daiderd.com/nix-darwin/manual/index.html).
-`darwin-help` will open a HTML version of the manpage in the default browser.
+The documentation is also available as manpages by running `man 5 configuration.nix`.
-Furthermore there's `darwin-option` to introspect the settings of a system and its available options.
-> NOTE: `darwin-option` is only available to non-flake installations.
+## Uninstalling
+
+To run the latest version of the uninstaller, you can run the following command:
```
-$ darwin-option nix.linux-builder.enable
-Value:
-true
-
-Default:
-false
-
-Example:
-true
-
-Description:
-Whether to enable Linux builder.
+nix --extra-experimental-features "nix-command flakes" run nix-darwin#darwin-uninstaller
```
-There's also a small wiki https://github.com/LnL7/nix-darwin/wiki about
-specific topics, like macOS upgrades.
+If that command doesn't work for you, you can try the locally installed uninstaller:
+
+```
+darwin-uninstaller
+```
## Tests
diff --git a/default.nix b/default.nix
index c93b4783..8bae7e1e 100644
--- a/default.nix
+++ b/default.nix
@@ -1,8 +1,8 @@
{ nixpkgs ?
, configuration ?
-, lib ? pkgs.lib
-, pkgs ? import nixpkgs { inherit system; }
, system ? builtins.currentSystem
+, pkgs ? import nixpkgs { inherit system; }
+, lib ? pkgs.lib
}:
let
@@ -15,20 +15,9 @@ 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 { };
+ darwin-uninstaller = pkgs.callPackage ./pkgs/darwin-uninstaller { };
+
+ inherit (pkgs.callPackage ./pkgs/nix-tools { }) darwin-option darwin-rebuild darwin-version;
}
diff --git a/modules/examples/flake/flake.nix b/modules/examples/flake/flake.nix
index dbcc420a..4520b8ff 100644
--- a/modules/examples/flake/flake.nix
+++ b/modules/examples/flake/flake.nix
@@ -30,7 +30,7 @@
system.stateVersion = 5;
# The platform the configuration will be used on.
- nixpkgs.hostPlatform = "x86_64-darwin";
+ nixpkgs.hostPlatform = "aarch64-darwin";
};
in
{
@@ -39,8 +39,5 @@
darwinConfigurations."simple" = nix-darwin.lib.darwinSystem {
modules = [ configuration ];
};
-
- # Expose the package set, including overlays, for convenience.
- darwinPackages = self.darwinConfigurations."simple".pkgs;
};
}
diff --git a/modules/examples/simple.nix b/modules/examples/simple.nix
index 8d769a2c..5771ec60 100644
--- a/modules/examples/simple.nix
+++ b/modules/examples/simple.nix
@@ -7,9 +7,8 @@
[ pkgs.vim
];
- # Use a custom configuration.nix location.
- # $ darwin-rebuild switch -I darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix
- # environment.darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix";
+ # Use custom location for configuration.nix.
+ environment.darwinConfig = "$HOME/.config/nix-darwin/configuration.nix";
# Enable alternative shell support in nix-darwin.
# programs.fish.enable = true;
diff --git a/modules/system/base.nix b/modules/system/base.nix
index 43c9d7ff..f20e2b64 100644
--- a/modules/system/base.nix
+++ b/modules/system/base.nix
@@ -2,46 +2,49 @@
{
system.activationScripts.createRun.text = ''
- if [[ ! -L /run ]]; then
- # This file doesn't exist by default on macOS and is only supported after 10.15
- # however every system with Nix installed should have this file otherwise `/nix`
- # wouldn't exist.
- if [[ -e /etc/synthetic.conf ]]; then
- if ! grep -q '^run\b' /etc/synthetic.conf 2>/dev/null; then
- echo "setting up /run via /etc/synthetic.conf..."
- printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf >/dev/null
- fi
+ IFS="." read -r -a macOSVersion <<< "$(sw_vers -productVersion)"
- # for Catalina (10.15)
- sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B &>/dev/null || true
- # for Big Sur (11.0)
- sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t &>/dev/null || true
+ if [[ ''${macOSVersion[0]} -gt 10 || ( ''${macOSVersion[0]} -eq 10 && ''${macOSVersion[1]} -ge 15 ) ]]; then
+ if ! grep -q '^run\b' /etc/synthetic.conf 2>/dev/null; then
+ echo "setting up /run via /etc/synthetic.conf..."
+ printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf >/dev/null
+ fi
- if [[ ! -L /run ]]; then
- printf >&2 '[1;31merror: apfs.util failed to symlink /run, aborting activation[0m\n'
- printf >&2 'To create a symlink from /run to /var/run, please run:\n'
- printf >&2 '\n'
- printf >&2 "$ printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf"
- printf >&2 '$ sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B # For Catalina\n'
- printf >&2 '$ sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t # For Big Sur and later\n' >&2
- printf >&2 '\n'
- printf >&2 'The current contents of /etc/synthetic.conf is:\n'
- printf >&2 '\n'
- sudo sed 's/^/ /' /etc/synthetic.conf >&2
- printf >&2 '\n'
- exit 1
- fi
+ if [[ ''${macOSVersion[0]} -gt 10 ]]; then
+ sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t || true
else
- echo "setting up /run..."
- sudo ln -sfn private/var/run /run
+ sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B || true
+ fi
- if [[ ! -L /run ]]; then
- printf >&2 '[1;31merror: failed to symlink /run, aborting activation[0m\n'
- printf >&2 'To create a symlink from /run to /var/run, please run:\n'
- printf >&2 '\n'
- printf >&2 '$ sudo ln -sfn private/var/link /run\n'
- exit 1
+ if [[ ! -L /run ]]; then
+ printf >&2 '[1;31merror: apfs.util failed to symlink /run, aborting activation[0m\n'
+ printf >&2 'To create a symlink from /run to /var/run, please run:\n'
+ printf >&2 '\n'
+ printf >&2 "$ printf 'run\tprivate/var/run\n' | sudo tee -a /etc/synthetic.conf"
+
+ if [[ ''${macOSVersion[0]} -gt 10 ]]; then
+ printf >&2 '$ sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t\n'
+ else
+ printf >&2 '$ sudo /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B\n'
fi
+
+ printf >&2 '\n'
+ printf >&2 'The current contents of /etc/synthetic.conf is:\n'
+ printf >&2 '\n'
+ sudo sed 's/^/ /' /etc/synthetic.conf >&2
+ printf >&2 '\n'
+ exit 1
+ fi
+ else
+ echo "setting up /run..."
+ sudo ln -sfn private/var/run /run
+
+ if [[ ! -L /run ]]; then
+ printf >&2 '[1;31merror: failed to symlink /run, aborting activation[0m\n'
+ printf >&2 'To create a symlink from /run to /var/run, please run:\n'
+ printf >&2 '\n'
+ printf >&2 '$ sudo ln -sfn private/var/link /run\n'
+ exit 1
fi
fi
'';
diff --git a/pkgs/darwin-installer/default.nix b/pkgs/darwin-installer/default.nix
deleted file mode 100644
index 78ca3c88..00000000
--- a/pkgs/darwin-installer/default.nix
+++ /dev/null
@@ -1,142 +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
-
- config="$HOME/.nixpkgs/darwin-configuration.nix"
- if ! test -f "$config"; then
- echo "copying example configuration.nix" >&2
- mkdir -p "$HOME/.nixpkgs"
- cp "${../../modules/examples/simple.nix}" "$config"
- chmod u+w "$config"
- fi
-
- # Skip when stdin is not a tty, eg.
- # $ yes | darwin-installer
- if test -t 0; then
- read -p "Would you like to edit the default configuration.nix before starting? [y/N] " i
- case "$i" in
- y|Y)
- PATH=$_PATH ''${EDITOR:-nano} "$config"
- ;;
- esac
- fi
-
- i=y
- darwinPath=$(NIX_PATH=$HOME/.nix-defexpr/channels nix-instantiate --eval -E '' 2> /dev/null) || true
- if ! test -e "$darwinPath"; then
- if test -t 0; then
- read -p "Would you like to manage with nix-channel? [y/N] " i
- fi
- case "$i" in
- y|Y)
- nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin
- nix-channel --update
- ;;
- esac
- fi
-
- export NIX_PATH=${nixPath}
- system=$(nix-build '' -I "darwin-config=$config" -A system --no-out-link --show-trace)
-
- export PATH=$system/sw/bin:$PATH
- darwin-rebuild "$action" -I "darwin-config=$config"
-
- echo >&2
- echo >&2 " Open '$config' to get started."
- echo >&2 " See the README for more information: [0;34mhttps://github.com/LnL7/nix-darwin/blob/master/README.md[0m"
- 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
- '';
- };
-}