mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
installer: remove
This commit is contained in:
parent
62f9402af0
commit
60ed03d0b1
4 changed files with 14 additions and 131 deletions
12
.github/workflows/test.yml
vendored
12
.github/workflows/test.yml
vendored
|
@ -46,7 +46,7 @@ jobs:
|
||||||
nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin
|
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 --add https://nixos.org/channels/${{ env.CURRENT_STABLE_CHANNEL }} nixpkgs
|
||||||
nix-channel --update
|
nix-channel --update
|
||||||
- name: Install nix-darwin and test
|
- name: Install nix-darwin
|
||||||
run: |
|
run: |
|
||||||
export NIX_PATH=$HOME/.nix-defexpr/channels
|
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\" ];/" \
|
"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
|
~/.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
|
- name: Build and activate default derivation
|
||||||
run: |
|
run: |
|
||||||
. /etc/static/bashrc
|
. /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://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin
|
||||||
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
|
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
|
||||||
nix-channel --update
|
nix-channel --update
|
||||||
- name: Install nix-darwin and test
|
- name: Install nix-darwin
|
||||||
run: |
|
run: |
|
||||||
export NIX_PATH=$HOME/.nix-defexpr/channels
|
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\" ];/" \
|
"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
|
~/.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
|
- name: Build and activate default derivation
|
||||||
run: |
|
run: |
|
||||||
. /etc/static/bashrc
|
. /etc/static/bashrc
|
||||||
|
|
|
@ -78,7 +78,7 @@ Make sure to set `nixpkgs.hostPlatform` in your `configuration.nix` to either `x
|
||||||
|
|
||||||
### Step 2. Installing `nix-darwin`
|
### 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
|
```bash
|
||||||
nix run nix-darwin -- switch --flake ~/.config/nix-darwin
|
nix run nix-darwin -- switch --flake ~/.config/nix-darwin
|
||||||
|
@ -128,9 +128,10 @@ nix-channel --update
|
||||||
|
|
||||||
### Step 3. Installing `nix-darwin`
|
### 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
|
```bash
|
||||||
nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
|
nix --extra-experimental-features "nix-command flakes" run nix-darwin -- switch -I darwin-config=$HOME/.config/nix-darwin/configuration.nix
|
||||||
./result/bin/darwin-installer
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 4. Using `nix-darwin`
|
### Step 4. Using `nix-darwin`
|
||||||
|
|
17
default.nix
17
default.nix
|
@ -1,8 +1,8 @@
|
||||||
{ nixpkgs ? <nixpkgs>
|
{ nixpkgs ? <nixpkgs>
|
||||||
, configuration ? <darwin-config>
|
, configuration ? <darwin-config>
|
||||||
, lib ? pkgs.lib
|
|
||||||
, pkgs ? import nixpkgs { inherit system; }
|
|
||||||
, system ? builtins.currentSystem
|
, system ? builtins.currentSystem
|
||||||
|
, pkgs ? import nixpkgs { inherit system; }
|
||||||
|
, lib ? pkgs.lib
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -15,20 +15,7 @@ let
|
||||||
nixpkgs.system = lib.mkDefault system;
|
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
|
in
|
||||||
|
|
||||||
eval // {
|
eval // {
|
||||||
installer = pkgs.callPackage ./pkgs/darwin-installer { inherit nix-darwin; };
|
|
||||||
uninstaller = pkgs.callPackage ./pkgs/darwin-uninstaller { };
|
uninstaller = pkgs.callPackage ./pkgs/darwin-uninstaller { };
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: [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
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Reference in a new issue