mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
installer: match flaky installation logic
This commit is contained in:
parent
22620845fe
commit
7881727017
3 changed files with 4 additions and 60 deletions
|
@ -1,9 +0,0 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
imports = [ <user-darwin-config> ./installer.nix ];
|
||||
|
||||
nix.configureBuildUsers = true;
|
||||
}
|
|
@ -1,14 +1,7 @@
|
|||
{ stdenv, writeScript, nix, pkgs, nix-darwin }:
|
||||
{ stdenv, nix, pkgs, nix-darwin }:
|
||||
|
||||
let
|
||||
configuration = builtins.path {
|
||||
name = "nix-darwin-installer-configuration";
|
||||
path = ./.;
|
||||
filter = name: _type: name != toString ./default.nix;
|
||||
};
|
||||
|
||||
nixPath = pkgs.lib.concatStringsSep ":" [
|
||||
"darwin-config=${configuration}/configuration.nix"
|
||||
"darwin=${nix-darwin}"
|
||||
"nixpkgs=${pkgs.path}"
|
||||
"$HOME/.nix-defexpr/channels"
|
||||
|
@ -54,7 +47,7 @@ stdenv.mkDerivation {
|
|||
echo >&2 "Installing nix-darwin..."
|
||||
echo >&2
|
||||
|
||||
config=$(nix-instantiate --eval -E '<darwin-config>' 2> /dev/null || echo "$HOME/.nixpkgs/darwin-configuration.nix")
|
||||
config="$HOME/.nixpkgs/darwin-configuration.nix"
|
||||
if ! test -f "$config"; then
|
||||
echo "copying example configuration.nix" >&2
|
||||
mkdir -p "$HOME/.nixpkgs"
|
||||
|
@ -93,10 +86,10 @@ stdenv.mkDerivation {
|
|||
fi
|
||||
|
||||
export NIX_PATH=${nixPath}
|
||||
system=$(nix-build '<darwin>' -I "user-darwin-config=$config" -A system --no-out-link --show-trace)
|
||||
system=$(nix-build '<darwin>' -I "darwin-config=$config" -A system --no-out-link --show-trace)
|
||||
|
||||
export PATH=$system/sw/bin:$PATH
|
||||
darwin-rebuild "$action" -I "user-darwin-config=$config"
|
||||
darwin-rebuild "$action" -I "darwin-config=$config"
|
||||
|
||||
echo >&2
|
||||
echo >&2 " Open '$config' to get started."
|
||||
|
@ -123,12 +116,6 @@ stdenv.mkDerivation {
|
|||
echo >&2 "checking /etc"
|
||||
readlink /etc/static
|
||||
test -e /etc/static
|
||||
echo >&2 "checking /etc/static in bashrc"
|
||||
cat /etc/bashrc
|
||||
grep /etc/static/bashrc /etc/bashrc
|
||||
echo >&2 "checking /etc/static in zshrc"
|
||||
cat /etc/zshrc
|
||||
grep /etc/static/zshrc /etc/zshrc
|
||||
echo >&2 "checking profile"
|
||||
cat /etc/profile
|
||||
grep -v nix-daemon.sh /etc/profile
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
system.activationScripts.preUserActivation.text = mkBefore ''
|
||||
PATH=/nix/var/nix/profiles/default/bin:$PATH
|
||||
|
||||
i=y
|
||||
if ! test -L /etc/bashrc && ! tail -n1 /etc/bashrc | grep -q /etc/static/bashrc; then
|
||||
if test -t 1; then
|
||||
read -p "Would you like to load darwin configuration in /etc/bashrc? [y/n] " i
|
||||
fi
|
||||
case "$i" in
|
||||
y|Y)
|
||||
sudo ${pkgs.gnused}/bin/sed -i '\,/etc/static/bashrc,d' /etc/bashrc
|
||||
echo 'if test -e /etc/static/bashrc; then . /etc/static/bashrc; fi' | sudo tee -a /etc/bashrc
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if ! test -L /etc/zshrc && ! tail -n1 /etc/zshrc | grep -q /etc/static/zshrc; then
|
||||
if test -t 1; then
|
||||
read -p "Would you like to load darwin configuration in /etc/zshrc? [y/n] " i
|
||||
fi
|
||||
case "$i" in
|
||||
y|Y)
|
||||
sudo ${pkgs.gnused}/bin/sed -i '\,/etc/static/zshrc,d' /etc/zshrc
|
||||
echo 'if test -e /etc/static/zshrc; then . /etc/static/zshrc; fi' | sudo tee -a /etc/zshrc
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue