mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-16 05:18:17 +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
|
let
|
||||||
configuration = builtins.path {
|
|
||||||
name = "nix-darwin-installer-configuration";
|
|
||||||
path = ./.;
|
|
||||||
filter = name: _type: name != toString ./default.nix;
|
|
||||||
};
|
|
||||||
|
|
||||||
nixPath = pkgs.lib.concatStringsSep ":" [
|
nixPath = pkgs.lib.concatStringsSep ":" [
|
||||||
"darwin-config=${configuration}/configuration.nix"
|
|
||||||
"darwin=${nix-darwin}"
|
"darwin=${nix-darwin}"
|
||||||
"nixpkgs=${pkgs.path}"
|
"nixpkgs=${pkgs.path}"
|
||||||
"$HOME/.nix-defexpr/channels"
|
"$HOME/.nix-defexpr/channels"
|
||||||
|
@ -54,7 +47,7 @@ stdenv.mkDerivation {
|
||||||
echo >&2 "Installing nix-darwin..."
|
echo >&2 "Installing nix-darwin..."
|
||||||
echo >&2
|
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
|
if ! test -f "$config"; then
|
||||||
echo "copying example configuration.nix" >&2
|
echo "copying example configuration.nix" >&2
|
||||||
mkdir -p "$HOME/.nixpkgs"
|
mkdir -p "$HOME/.nixpkgs"
|
||||||
|
@ -93,10 +86,10 @@ stdenv.mkDerivation {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export NIX_PATH=${nixPath}
|
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
|
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
|
||||||
echo >&2 " Open '$config' to get started."
|
echo >&2 " Open '$config' to get started."
|
||||||
|
@ -123,12 +116,6 @@ stdenv.mkDerivation {
|
||||||
echo >&2 "checking /etc"
|
echo >&2 "checking /etc"
|
||||||
readlink /etc/static
|
readlink /etc/static
|
||||||
test -e /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"
|
echo >&2 "checking profile"
|
||||||
cat /etc/profile
|
cat /etc/profile
|
||||||
grep -v nix-daemon.sh /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…
Add table
Reference in a new issue