Skip to content

Commit

Permalink
feat: use nix across platforms
Browse files Browse the repository at this point in the history
Fixes #792, #778

topic:nixpkgs
  • Loading branch information
kaihowl committed Nov 9, 2024
1 parent 2f62c61 commit ab54d67
Show file tree
Hide file tree
Showing 56 changed files with 319 additions and 537 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ jobs:
run: |
env
export XDG_CONFIG_HOME=~/.config
# Don't care about outdated, broken linkages on CI.
# Otherwise, this might update node or php.
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
export HOMEBREW_NO_INSTALL_CLEANUP=1
# Make `infocmp` for nvim healthcheck succeed
export TERM=dumb
# Ignore potentially insecure directories on GitHub actions runner.
export ZSH_DISABLE_COMPFIX=true
# Do not rate limit with public / untrusted access bucket
export NIX_CONFIG="access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}"
cd .dotfiles/
./script/ci.sh
- name: Rename versions report
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.PHONY: update clean

update:
nix run home-manager/release-24.05 -- --impure switch --flake .#myprofile

clean:
nix-collect-garbage -d

closuresize-all:
nix path-info -S /Users/kaihowl/.nix-profile/ -r | sort -n -k2

closuresize-single:
nix path-info -S /Users/kaihowl/.nix-profile/

print-dependencies:
nix-store --query ~/.nix-profile --graph | dot -Tpdf -o out.pdf && open out.pdf
12 changes: 2 additions & 10 deletions alacritty/install.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
#!/bin/bash
set -e

SCRIPT_DIR=$(unset CDPATH; cd "$(dirname "$0")" > /dev/null; pwd -P)

if [ "$(uname)" == "Darwin" ]; then
source "${SCRIPT_DIR}/../common/brew.sh"
brew_install alacritty
elif [[ "$(lsb_release -i)" == *"Ubuntu"* ]]; then
sudo snap remove alacritty || true
source "${SCRIPT_DIR}/../common/apt.sh"
apt_add_repo alacritty https://ppa.launchpadcontent.net/aslatter/ppa/ubuntu ::codename:: 3a160895cc2ce253085d08a552b24df7d43b5377
apt_install alacritty
# Actual copy needed, otherwise Spotlight will not show the app
sudo cp -rf ~/.nix-profile/Applications/Alacritty.app /Applications/
fi

8 changes: 8 additions & 0 deletions alacritty/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@ set -e
echo "Check if alacritty is installed"
which alacritty

echo "Check if alacritty is nix controlled"
actual_path=$(realpath "$(which alacritty)")
if [[ "${actual_path}" != /nix/store/* ]]; then
echo "Actual Path: $actual_path"
echo Expected alacritty to be managed by nix
exit 1
fi

echo "Check if alacritty is runnable"
alacritty --version
15 changes: 0 additions & 15 deletions ccache/install.sh

This file was deleted.

8 changes: 8 additions & 0 deletions ccache/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ set -e
echo "Check if ccache is available"
which ccache

echo "Check if ccache is nix controlled"
actual_path=$(realpath "$(which ccache)")
if [[ "${actual_path}" != /nix/store/* ]]; then
echo "Actual Path: $actual_path"
echo Expected ccache to be managed by nix
exit 1
fi

echo "Check if ccache is runnable"
ccache --version

Expand Down
23 changes: 0 additions & 23 deletions clangd/install.sh

This file was deleted.

1 change: 0 additions & 1 deletion clangd/path.zsh

This file was deleted.

10 changes: 6 additions & 4 deletions clangd/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ clangd --version
echo "Check that clangd can be started"
clangd --help > /dev/null

echo "Check that clangd is installed from llvm apt repo (Ubuntu-only)"
if [[ "$(lsb_release -i)" == *"Ubuntu"* ]]; then
apt-cache policy clangd
apt-cache policy clangd | grep -F '**' -A1 | grep -F apt.llvm.org
echo "Check that clangd is nix managed"
actual_path=$(realpath "$(which clangd)")
if [[ "${actual_path}" != /nix/store/* ]]; then
echo "Actual Path: $actual_path"
echo Expected clangd to be managed by nix
exit 1
fi
28 changes: 0 additions & 28 deletions cmake/install.sh

This file was deleted.

10 changes: 6 additions & 4 deletions cmake/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ set -e
echo "Check if cmake is available"
which cmake

echo "Check that cmake is installed from llvm apt repo (Ubuntu-only)"
if [[ "$(lsb_release -i)" == *"Ubuntu"* ]]; then
apt-cache policy cmake
apt-cache policy cmake | grep -F '**' -A1 | grep -F apt.kitware.com
echo "Check if cmake is nix controlled"
actual_path=$(realpath "$(which cmake)")
if [[ "${actual_path}" != /nix/store/* ]]; then
echo "Actual Path: $actual_path"
echo Expected cmake to be managed by nix
exit 1
fi
5 changes: 0 additions & 5 deletions colors/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,4 @@ set -e

SCRIPT_DIR=$(unset CDPATH; cd "$(dirname "$0")" > /dev/null; pwd -P)

# Depends on an installed zsh for using zparseopts in change-color
if ! command -v zsh > /dev/null; then
"${SCRIPT_DIR}/../zsh/install.sh"
fi

"${SCRIPT_DIR}/../colors/bin/change-color"
5 changes: 0 additions & 5 deletions common/apt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ function apt_install() {
sudo apt-get -o DPkg::Lock::Timeout=-1 install --upgrade -y "$@"
}

function apt_remove() {
wait_for_apt
sudo apt-get remove -y "$@"
}

function apt_add_repo_with_keyfile() {
local name
name=$1
Expand Down
42 changes: 0 additions & 42 deletions common/brew.sh

This file was deleted.

36 changes: 0 additions & 36 deletions common/download.sh

This file was deleted.

27 changes: 8 additions & 19 deletions common/python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,27 @@

set -e

function ensure_python_installed() {
local script_dir
script_dir=$(unset CDPATH; cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null; pwd -P)
if [[ "$(uname)" == "Linux" && "$(lsb_release -i)" == *"Ubuntu"* ]]; then
source "${script_dir}/apt.sh"
# venv is needed as Ubuntu 22.04 otherwise has no ensurepip and venv fails.
# Install all of these packages as a sane baseline.
apt_install --no-install-recommends python3-pip python3-dev python3-venv
else
# The apple xcode python is broken. Use brew's python version instead.
source "${script_dir}/brew.sh"
brew_install python
fi
}

function install_in_named_virtualenv() {
local venvname
venvname=$1
shift

ensure_python_installed
# Using venv instead of virtualenv as homebrews virtualenv is completely
# separate from its python. I.e., it is not installed as a site package.
# Installing virtualenv globally defeats the purpose of having venvs in the
# first place. venv seems to have the most support throughout macOS / Ubuntu.
# Major difference, it does not seed wheel (needed by pynvim) into the
# virtualenv. This is done manually including an upgrade of pip and
# setuptools.
python3 -m venv "$HOME/.virtualenvs/$venvname"
python3Binary=$HOME/.virtualenvs/$venvname/bin/python3
if [[ -f $python3Binary ]] && ! [[ $(realpath "$python3Binary") == /nix/store/* ]]; then
echo "Delete pre-nix-era venv, start fresh"
rm -rf "$HOME/.virtualenvs/$venvname/"
fi
~/.nix-profile/bin/python3 -m venv "$HOME/.virtualenvs/$venvname"
# Must run independently as wheel is a non-declared dependency of some packages.
"$HOME/.virtualenvs/$venvname/bin/python3" -m pip install --upgrade pip setuptools wheel
"$HOME/.virtualenvs/$venvname/bin/python3" -m pip install --upgrade "$*"
"$python3Binary" -m pip install --upgrade pip setuptools wheel
"$python3Binary" -m pip install --upgrade "$*"
}

function install_in_nvim_virtualenv() {
Expand Down
12 changes: 0 additions & 12 deletions ctags/install.sh

This file was deleted.

8 changes: 8 additions & 0 deletions ctags/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,13 @@ set -e
echo "Check if (universal-)ctags is available"
which ctags

echo "Check if ctags is nix controlled"
actual_path=$(realpath "$(which ctags)")
if [[ "${actual_path}" != /nix/store/* ]]; then
echo "Actual Path: $actual_path"
echo Expected ctags to be managed by nix
exit 1
fi

echo "Check if ctags is runnable"
ctags --version
28 changes: 0 additions & 28 deletions efm/install.sh

This file was deleted.

2 changes: 0 additions & 2 deletions efm/path.zsh

This file was deleted.

Loading

0 comments on commit ab54d67

Please sign in to comment.