mirror of
https://github.com/RGBCube/ncc
synced 2025-08-01 12:37:46 +00:00
shells: fix a lot of logic and use activation scripts
This commit is contained in:
parent
e759456954
commit
f673d73cd2
5 changed files with 165 additions and 132 deletions
70
rebuild.nu
70
rebuild.nu
|
@ -57,77 +57,7 @@ def main --wrapped [
|
|||
|
||||
if (uname | get kernel-name) == "Darwin" {
|
||||
NH_BYPASS_ROOT_CHECK=true NH_NO_CHECKS=true nh darwin switch . ...$nh_flags -- ...$nix_flags
|
||||
|
||||
if not (xcode-select --install e>| str contains "Command line tools are already installed") {
|
||||
darwin-shadow-xcode-popup
|
||||
}
|
||||
|
||||
darwin-set-zshrc
|
||||
} else {
|
||||
NH_BYPASS_ROOT_CHECK=true NH_NO_CHECKS=true nh os switch . ...$nh_flags -- ...$nix_flags
|
||||
}
|
||||
}
|
||||
|
||||
# Replace with the command that has been triggering
|
||||
# the "install developer tools" popup.
|
||||
#
|
||||
# Set by default to "SplitForks" because who even uses that?
|
||||
const original_trigger = "/usr/bin/SplitForks"
|
||||
|
||||
# Where the symbolic links to `/usr/bin/false` will
|
||||
# be created in to shadow all popup-triggering binaries.
|
||||
#
|
||||
# Place this in your $env.PATH right before /usr/bin
|
||||
# to never get the "install developer tools" popup ever again:
|
||||
#
|
||||
# ```nu
|
||||
# let usr_bin_index = $env.PATH
|
||||
# | enumerate
|
||||
# | where item == /usr/bin
|
||||
# | get 0.index
|
||||
#
|
||||
# $env.PATH = $env.PATH | insert $usr_bin_index $shadow_path
|
||||
# ```
|
||||
#
|
||||
# Do NOT set this to a path that you use for other things,
|
||||
# it will get deleted if it exists to only have the shadowers.
|
||||
const shadow_path = "~/.local/shadow" | path expand # Did you read the comment?
|
||||
|
||||
def darwin-shadow-xcode-popup [] {
|
||||
print "shadowing xcode popup binaries..."
|
||||
|
||||
let original_size = ls $original_trigger | get 0.size
|
||||
|
||||
let shadoweds = ls /usr/bin
|
||||
| flatten
|
||||
| where {
|
||||
# All xcode-select binaries are the same size, so we can narrow down and not run weird stuff.
|
||||
$in.size == $original_size
|
||||
}
|
||||
| where {
|
||||
^$in.name e>| str contains "xcode-select: note: No developer tools were found, requesting install."
|
||||
}
|
||||
| get name
|
||||
| each { path basename }
|
||||
|
||||
rm -rf $shadow_path
|
||||
mkdir $shadow_path
|
||||
|
||||
for shadowed in $shadoweds {
|
||||
let shadow_path = $shadow_path | path join $shadowed
|
||||
|
||||
ln --symbolic /usr/bin/false $shadow_path
|
||||
}
|
||||
}
|
||||
|
||||
def darwin-set-zshrc [] {
|
||||
print "setting zshrc..."
|
||||
|
||||
let nu_command = $"let usr_bin_index = $env.PATH | enumerate | where item == /usr/bin | get 0.index;
|
||||
$env.PATH = $env.PATH | insert $usr_bin_index ($shadow_path | path expand);
|
||||
$env.SHELL = which nu | get 0.path" | str replace --all "\n" ""
|
||||
|
||||
let zshrc = $"exec nu --execute '($nu_command)'"
|
||||
|
||||
$zshrc | save --force ~/.zshrc
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue