[ubuntu] Onboard an ubuntu config.
This commit is contained in:
Generated
+41
-3
@@ -214,6 +214,26 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"home-manager-unstable": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs-unstable"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1794963576,
|
||||
"narHash": "sha256-+CPrP74GDJ63f7bgEFC9Av4hbxc7K9WUNv1ZVRifRe8=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "2b13c9cb3aa20653e6f8ee0b7f8331a53ea9b0a9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"home-manager_2": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
@@ -256,6 +276,22 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-flatpak": {
|
||||
"locked": {
|
||||
"lastModified": 1790428548,
|
||||
"narHash": "sha256-OsZ/I7v3ArCrk0XOUvkiU1dFtGtE1qZTHRGjvBXIKUU=",
|
||||
"owner": "gmodena",
|
||||
"repo": "nix-flatpak",
|
||||
"rev": "f1f045fc8b35ff59f88982c1752d3f3a42ca6a61",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "gmodena",
|
||||
"ref": "latest",
|
||||
"repo": "nix-flatpak",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixgl": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_3",
|
||||
@@ -343,11 +379,11 @@
|
||||
},
|
||||
"nixpkgs-unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1768564909,
|
||||
"narHash": "sha256-Kell/SpJYVkHWMvnhqJz/8DqQg2b6PguxVWOuadbHCc=",
|
||||
"lastModified": 1794890597,
|
||||
"narHash": "sha256-lME2lHoDHAaSHP3/okgiVoJ0icVEvsQH8LeU3We7tcc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e4bae1bd10c9c57b2cf517953ab70060a828ee6f",
|
||||
"rev": "04906337b6d53e8bb0eaf0470ae9f070a4d4eb55",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -446,7 +482,9 @@
|
||||
"ghostty": "ghostty",
|
||||
"godig": "godig",
|
||||
"home-manager": "home-manager_2",
|
||||
"home-manager-unstable": "home-manager-unstable",
|
||||
"nix-darwin": "nix-darwin",
|
||||
"nix-flatpak": "nix-flatpak",
|
||||
"nixgl": "nixgl",
|
||||
"nixos-hardware": "nixos-hardware",
|
||||
"nixpkgs": "nixpkgs_3",
|
||||
|
||||
@@ -27,6 +27,12 @@
|
||||
url = "github:nix-community/home-manager/release-25.11";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
home-manager-unstable = {
|
||||
url = "github:nix-community/home-manager";
|
||||
inputs.nixpkgs.follows = "nixpkgs-unstable";
|
||||
};
|
||||
# Declarative flatpaks.
|
||||
nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=latest";
|
||||
ghostty = {
|
||||
url = "github:ghostty-org/ghostty";
|
||||
};
|
||||
@@ -224,6 +230,33 @@
|
||||
./users/alarm/home.nix
|
||||
];
|
||||
};
|
||||
# Ubuntu desktop.
|
||||
# Apply with ./ubuntu/bootstrap.sh on first install (safe to rerun to sync).
|
||||
ubuntu = let
|
||||
pkgs = import nixpkgs-unstable {
|
||||
system = "x86_64-linux";
|
||||
config.allowUnfree = true;
|
||||
overlays = [
|
||||
# Use the host's flatpak. Ubuntu sets
|
||||
# kernel.apparmor_restrict_unprivileged_userns=1 so so nixpkgs'
|
||||
# flatpak can't sandbox extra-data installs (e.g. Slack's apply_extra).
|
||||
(final: prev: {
|
||||
flatpak = final.writeShellScriptBin "flatpak" ''exec /usr/bin/flatpak "$@"'';
|
||||
})
|
||||
];
|
||||
};
|
||||
in inputs.home-manager-unstable.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
extraSpecialArgs = {
|
||||
inherit inputs;
|
||||
homeConfigurationName = "ubuntu";
|
||||
# Shared modules take a pkgs-unstable arg, for this config pkgs-unstable and pkgs are the same.
|
||||
pkgs-unstable = pkgs;
|
||||
};
|
||||
modules = [
|
||||
./hosts/ubuntu/home.nix
|
||||
];
|
||||
};
|
||||
# For machines that don't run NixOS.
|
||||
devbox = home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = nixpkgs.legacyPackages."x86_64-linux";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{ lib, config, ... }: {
|
||||
{ lib, config, pkgs, ... }: {
|
||||
options.ghostty.font-size = lib.mkOption {
|
||||
# Using a string to support floats.
|
||||
type = lib.types.str;
|
||||
@@ -21,6 +21,11 @@
|
||||
# This is the default to open the configuration
|
||||
# I type this by accident way to frequently...
|
||||
keybind = ctrl+comma=unbind
|
||||
'' + lib.optionalString pkgs.stdenv.hostPlatform.isLinux ''
|
||||
|
||||
# Support configs where Meta+C/V is turned into Ctrl+Insert/Shift+Insert.
|
||||
keybind = ctrl+insert=copy_to_clipboard
|
||||
keybind = shift+insert=paste_from_clipboard
|
||||
'';
|
||||
};
|
||||
config.home.file.".config/ghostty/themes/PaleNight" = {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# Glue for running Home Manager on Ubuntu.
|
||||
{ config, ... }: {
|
||||
# Nix-installed apps/fonts/terminfo visible to the host system.
|
||||
targets.genericLinux.enable = true;
|
||||
# GUI apps come from apt/flatpak, so nix packages don't need host GPU drivers.
|
||||
targets.genericLinux.gpu.enable = false;
|
||||
|
||||
# Things the stock ~/.profile and ~/.bashrc provided that are still needed.
|
||||
# ~/.local/bin: native installers put binaries here.
|
||||
home.sessionPath = [ "$HOME/.local/bin" "$HOME/bin" ];
|
||||
|
||||
programs.zsh = {
|
||||
# Keep ~/.zshrc etc. in $HOME
|
||||
dotDir = config.home.homeDirectory;
|
||||
# Ubuntu's /etc/zsh/zshrc runs compinit; Home Manager runs it again.
|
||||
envExtra = ''
|
||||
skip_global_compinit=1
|
||||
'';
|
||||
# zsh doesn't read /etc/profile, so /etc/profile.d/* (nix-daemon, /snap/bin,
|
||||
# flatpak XDG_DATA_DIRS, vte) would be skipped for login shells.
|
||||
profileExtra = ''
|
||||
emulate sh -c '. /etc/profile'
|
||||
'';
|
||||
};
|
||||
|
||||
# GNOME's gcr-ssh-agent already owns SSH_AUTH_SOCK; don't start another agent.
|
||||
services.ssh-agent.enable = false;
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
# Ubuntu desktop. User config only.
|
||||
# OS packages and /etc files are handled by ../../ubuntu/bootstrap.sh.
|
||||
{
|
||||
inputs,
|
||||
pkgs,
|
||||
homeConfigurationName,
|
||||
...
|
||||
} :
|
||||
let
|
||||
homeDirectory = "/home/jmug";
|
||||
in {
|
||||
imports = [
|
||||
../../home-modules/default.nix
|
||||
../../home-modules/ubuntu.nix
|
||||
../../home-modules/direnv.nix
|
||||
../../home-modules/ghostty-config.nix
|
||||
../../home-modules/git.nix
|
||||
../../home-modules/herdr.nix
|
||||
../../home-modules/lazygit.nix
|
||||
../../home-modules/nvim.nix
|
||||
../../home-modules/opencode-config.nix
|
||||
../../home-modules/starship.nix
|
||||
../../home-modules/zsh.nix
|
||||
|
||||
inputs.nix-flatpak.homeManagerModules.nix-flatpak
|
||||
];
|
||||
|
||||
# TODO(yubikey): Port the yubikey setup (sops-managed key handles in ~/.ssh,
|
||||
# id_yubikey symlink via udev, ykman/pcscd from apt, yubikey public keys).
|
||||
# See modules/nixos/yubikey and home-modules/sops.nix.
|
||||
|
||||
nvim = {
|
||||
enable = true;
|
||||
package = pkgs.neovim; # pkgs is already nixpkgs-unstable.
|
||||
};
|
||||
|
||||
ghostty = {
|
||||
font-size = "14";
|
||||
# GNOME needs server-side decorations to move/resize windows.
|
||||
# TODO: Could turn off if moving to niri.
|
||||
window-decoration = true;
|
||||
};
|
||||
|
||||
fonts.fontconfig.enable = true;
|
||||
|
||||
home = {
|
||||
username = "jmug";
|
||||
inherit homeDirectory;
|
||||
|
||||
sessionVariables = {
|
||||
EDITOR = "nvim";
|
||||
};
|
||||
|
||||
packages = with pkgs; [
|
||||
# Fonts (ghostty uses BigBlueTermPlus).
|
||||
nerd-fonts.bigblue-terminal
|
||||
nerd-fonts.fira-code
|
||||
nerd-fonts.caskaydia-cove
|
||||
|
||||
# Languages / toolchains. The C toolchain (gcc, clang, cmake) comes from
|
||||
# apt so native builds link against the system's libraries.
|
||||
bun
|
||||
rustup
|
||||
nodejs_24
|
||||
# eas-cli
|
||||
|
||||
# Cloud / infra.
|
||||
awscli2
|
||||
google-cloud-sdk
|
||||
flyctl
|
||||
ngrok
|
||||
gh
|
||||
|
||||
# Secrets.
|
||||
sops
|
||||
age
|
||||
|
||||
# Serial consoles.
|
||||
minicom
|
||||
picocom
|
||||
tio
|
||||
|
||||
# Misc CLI.
|
||||
opencode
|
||||
glow
|
||||
pipx
|
||||
watchman
|
||||
exercism
|
||||
fastfetch
|
||||
btop
|
||||
tree
|
||||
bluetui
|
||||
];
|
||||
|
||||
stateVersion = "25.11";
|
||||
};
|
||||
|
||||
# Desktop apps. Installed per-user from flathub on activation.
|
||||
services.flatpak = {
|
||||
enable = true;
|
||||
packages = [
|
||||
"app.zen_browser.zen"
|
||||
"com.slack.Slack"
|
||||
"com.obsproject.Studio"
|
||||
"org.videolan.VLC"
|
||||
];
|
||||
};
|
||||
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
# Keys: ~/.ssh/id_* defaults, served by GNOME's agent.
|
||||
# TODO(yubikey): IdentityFile id_yubikey / id_jmug like hosts/nixbox.
|
||||
settings = {
|
||||
"*" = {
|
||||
AddKeysToAgent = "no";
|
||||
Compression = false;
|
||||
ServerAliveInterval = 0;
|
||||
ServerAliveCountMax = 3;
|
||||
HashKnownHosts = false;
|
||||
UserKnownHostsFile = "~/.ssh/known_hosts";
|
||||
ControlMaster = "no";
|
||||
ControlPath = "~/.ssh/master-%r@%n:%p";
|
||||
ControlPersist = "no";
|
||||
};
|
||||
"github.com" = { User = "git"; AddKeysToAgent = "yes"; };
|
||||
"code.jmug.me" = { User = "git"; AddKeysToAgent = "yes"; };
|
||||
homeserver = { User = "jmug"; HostName = "100.122.244.59"; ForwardAgent = true; };
|
||||
devbox = { User = "jmug"; HostName = "100.102.140.44"; ForwardAgent = true; };
|
||||
handmade = { User = "jmug"; HostName = "82.180.160.149"; ForwardAgent = true; };
|
||||
handmade-gitea = { User = "jmug"; HostName = "40.160.241.66"; ForwardAgent = true; };
|
||||
racknerd = { User = "jmug"; HostName = "155.94.155.137"; AddKeysToAgent = "yes"; ForwardAgent = false; };
|
||||
beefy = { User = "jmug"; HostName = "100.127.115.24"; AddKeysToAgent = "yes"; ForwardAgent = true; };
|
||||
mid = { User = "jmug"; HostName = "100.82.115.89"; AddKeysToAgent = "yes"; ForwardAgent = true; };
|
||||
};
|
||||
};
|
||||
|
||||
programs.zsh.shellAliases = {
|
||||
flakeconf = "nvim ${homeDirectory}/nixos/flake.nix";
|
||||
homeconf = "nvim ${homeDirectory}/nixos/hosts/ubuntu/home.nix";
|
||||
nvconf = "nvim ${homeDirectory}/nixos/home-modules/explicit-configs/nvim/init.lua";
|
||||
rshellconf = "source ${homeDirectory}/.zshrc";
|
||||
# Home Manager only.
|
||||
homesw = "home-manager switch -b hm-backup --flake ${homeDirectory}/nixos#${homeConfigurationName}";
|
||||
# apt packages, repos, /etc files, then Home Manager.
|
||||
syssw = "${homeDirectory}/nixos/ubuntu/bootstrap.sh";
|
||||
};
|
||||
|
||||
# mise is installed by `ubuntu/bootstrap.sh tools`.
|
||||
programs.zsh.initContent = ''
|
||||
if [ -x "$HOME/.local/bin/mise" ]; then
|
||||
eval "$("$HOME/.local/bin/mise" activate zsh)"
|
||||
fi
|
||||
'';
|
||||
|
||||
programs.home-manager.enable = true;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
# Ubuntu machines
|
||||
|
||||
Ubuntu machines are managed in layers:
|
||||
|
||||
| Layer | Where | Applied by |
|
||||
|---|---|---|
|
||||
| User env: CLI tools, dotfiles, fonts, ssh hosts | `hosts/ubuntu/home.nix` | Home Manager |
|
||||
| Desktop apps (flatpak) | `services.flatpak` in `hosts/ubuntu/home.nix` | nix-flatpak, on HM activation |
|
||||
| OS packages | `apt-packages.txt` | `bootstrap.sh` |
|
||||
| Third-party apt repos (tailscale/docker) | `bootstrap.sh` | `bootstrap.sh` |
|
||||
| System config files | `etc/**`, mirrored into `/etc` | `bootstrap.sh` |
|
||||
| Self-updating tools from upstream installers (mise, herdr, tuicr) into `~/.local/bin` | `bootstrap.sh` | `bootstrap.sh tools` (kept up to date with update commands) |
|
||||
|
||||
## Fresh machine
|
||||
|
||||
```sh
|
||||
sudo apt install -y git curl
|
||||
git clone <this repo> ~/nixos
|
||||
~/nixos/ubuntu/bootstrap.sh
|
||||
sudo tailscale up
|
||||
# log out and back in
|
||||
```
|
||||
|
||||
After that:
|
||||
|
||||
- `homesw`: Home Manager only.
|
||||
- `syssw`: everything (same as running `bootstrap.sh`).
|
||||
|
||||
## Keyboard (keyd)
|
||||
|
||||
`etc/keyd/default.conf` applies to every keyboard except YubiKeys:
|
||||
|
||||
- Caps Lock and Left Control are swapped.
|
||||
- Left Alt and Left Meta are swapped, so the key next to space is Meta.
|
||||
- Meta+C, Meta+V and Meta+X copy, paste and cut. keyd sends Ctrl+Insert,
|
||||
Shift+Insert and Ctrl+X, the same as omarchy's Hyprland binds. These work
|
||||
in GTK/Qt apps, browsers and Electron. Ghostty gets the matching bindings
|
||||
in `home-modules/ghostty-config.nix`.
|
||||
|
||||
To test keyd: `sudo keyd.rvaiya monitor`. To bypass a broken config: press Backspace+Escape+Enter together, which kills keyd.
|
||||
|
||||
## TODO
|
||||
|
||||
- [ ] **YubiKey**: port `modules/nixos/yubikey` and `home-modules/sops.nix`. ykman and pcscd from apt, the udev rule plus yubikey-up/down scripts in `etc/`, the sops age key from cold storage, and the `id_yubikey` identity files in the ssh config.
|
||||
- [ ] **system-manager**: explore [numtide/system-manager](https://github.com/numtide/system-manager) to move `etc/` and the systemd service setup into Nix.
|
||||
@@ -0,0 +1,24 @@
|
||||
# Installed by bootstrap.sh. One package per line, # for comments.
|
||||
|
||||
# Shell:
|
||||
zsh
|
||||
|
||||
# Desktop:
|
||||
flatpak
|
||||
ghostty
|
||||
wl-clipboard
|
||||
|
||||
# Input:
|
||||
keyd
|
||||
logiops
|
||||
|
||||
# Containers:
|
||||
docker.io
|
||||
docker-buildx
|
||||
docker-compose-v2
|
||||
|
||||
# C toolchain:
|
||||
build-essential
|
||||
clang
|
||||
cmake
|
||||
pkg-config
|
||||
Executable
+186
@@ -0,0 +1,186 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bootstrap / sync an Ubuntu machine from this repo. Idempotent: re-run it
|
||||
# whenever apt-packages.txt, ubuntu/etc/**, or the Home Manager config change.
|
||||
set -euo pipefail
|
||||
|
||||
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
HERE="$REPO/ubuntu"
|
||||
HM_TARGET="${HM_TARGET:-ubuntu}"
|
||||
ALL_STEPS=(nix repos apt etc services shell tools home)
|
||||
|
||||
# Tools installed with their upstream install script instead of Nix/apt.
|
||||
TOOLS=(
|
||||
"mise|https://mise.run"
|
||||
"herdr|https://herdr.dev/install.sh"
|
||||
"tuicr|https://tuicr.dev/install.sh"
|
||||
)
|
||||
|
||||
log() { printf '\n\033[1;34m==> %s\033[0m\n' "$*"; }
|
||||
info() { printf ' %s\n' "$*"; }
|
||||
|
||||
# Strip comments/blank lines from a list file.
|
||||
read_list() { sed -e 's/#.*//' -e 's/[[:space:]]*$//' -e '/^$/d' "$1"; }
|
||||
|
||||
step_nix() {
|
||||
log "nix"
|
||||
if command -v nix >/dev/null 2>&1; then
|
||||
info "already installed: $(nix --version)"
|
||||
return
|
||||
fi
|
||||
# Determinate's installer, but upstream Nix (makes it easier to uninstall if needed).
|
||||
curl -fsSL https://install.determinate.systems/nix \
|
||||
| sh -s -- install --no-confirm --prefer-upstream-nix
|
||||
# shellcheck disable=SC1091
|
||||
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
|
||||
}
|
||||
|
||||
step_repos() {
|
||||
log "third-party apt repos"
|
||||
local codename changed=0
|
||||
# shellcheck disable=SC1091
|
||||
codename="$(. /etc/os-release && echo "$VERSION_CODENAME")"
|
||||
|
||||
# Tailscale: https://tailscale.com/kb/1031/install-linux
|
||||
if [ ! -f /etc/apt/sources.list.d/tailscale.list ]; then
|
||||
curl -fsSL "https://pkgs.tailscale.com/stable/ubuntu/${codename}.noarmor.gpg" \
|
||||
| sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null
|
||||
curl -fsSL "https://pkgs.tailscale.com/stable/ubuntu/${codename}.tailscale-keyring.list" \
|
||||
| sudo tee /etc/apt/sources.list.d/tailscale.list >/dev/null
|
||||
changed=1
|
||||
fi
|
||||
info "tailscale repo present"
|
||||
|
||||
if [ "$changed" = 1 ]; then sudo apt-get update; fi
|
||||
}
|
||||
|
||||
step_apt() {
|
||||
log "apt packages"
|
||||
local pkgs=() missing=() p
|
||||
mapfile -t pkgs < <(read_list "$HERE/apt-packages.txt")
|
||||
pkgs+=(tailscale) # From step_repos.
|
||||
for p in "${pkgs[@]}"; do
|
||||
dpkg-query -W -f='${Status}' "$p" 2>/dev/null | grep -q 'install ok installed' \
|
||||
|| missing+=("$p")
|
||||
done
|
||||
if [ ${#missing[@]} -eq 0 ]; then
|
||||
info "all ${#pkgs[@]} packages installed"
|
||||
return
|
||||
fi
|
||||
info "installing: ${missing[*]}"
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y "${missing[@]}"
|
||||
}
|
||||
|
||||
# Copy ubuntu/etc/** to /etc. Only touches files that differ, and reloads the
|
||||
# daemons whose config changed. Removed files are orphaned.
|
||||
step_etc() {
|
||||
log "/etc files"
|
||||
local src rel dst changed=()
|
||||
while IFS= read -r -d '' src; do
|
||||
rel="${src#"$HERE/etc/"}"
|
||||
dst="/etc/$rel"
|
||||
if sudo cmp -s "$src" "$dst"; then
|
||||
info "unchanged $dst"
|
||||
continue
|
||||
fi
|
||||
if sudo test -e "$dst"; then
|
||||
sudo diff -u "$dst" "$src" || true
|
||||
fi
|
||||
sudo install -D -m 0644 -o root -g root "$src" "$dst"
|
||||
info "updated $dst"
|
||||
changed+=("$rel")
|
||||
done < <(find "$HERE/etc" -type f -print0 | sort -z)
|
||||
|
||||
local rel_changed
|
||||
for rel_changed in "${changed[@]}"; do
|
||||
case "$rel_changed" in
|
||||
keyd/*)
|
||||
# (Ubuntu ships the CLI as keyd.rvaiya)
|
||||
if systemctl is-active -q keyd.service; then sudo systemctl restart keyd.service && info "restarted keyd"; fi ;;
|
||||
logid.cfg)
|
||||
if systemctl is-active -q logid.service; then sudo systemctl restart logid.service && info "restarted logid"; fi ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
step_services() {
|
||||
log "system services"
|
||||
local unit
|
||||
for unit in keyd.service logid.service docker.service tailscaled.service; do
|
||||
if ! systemctl cat "$unit" >/dev/null 2>&1; then
|
||||
info "skip $unit (not installed)"
|
||||
continue
|
||||
fi
|
||||
if ! systemctl is-enabled -q "$unit" 2>/dev/null || ! systemctl is-active -q "$unit"; then
|
||||
sudo systemctl enable --now "$unit"
|
||||
fi
|
||||
info "running $unit"
|
||||
done
|
||||
|
||||
if getent group docker >/dev/null && ! id -nG "$USER" | grep -qw docker; then
|
||||
sudo usermod -aG docker "$USER"
|
||||
info "added $USER to docker group (log out/in to apply)"
|
||||
fi
|
||||
}
|
||||
|
||||
step_shell() {
|
||||
log "login shell"
|
||||
local want=/usr/bin/zsh current
|
||||
current="$(getent passwd "$USER" | cut -d: -f7)"
|
||||
if [ "$current" = "$want" ]; then
|
||||
info "already $want"
|
||||
return
|
||||
fi
|
||||
sudo chsh -s "$want" "$USER"
|
||||
info "changed $current -> $want (log out/in to apply)"
|
||||
}
|
||||
|
||||
step_tools() {
|
||||
log "self-installing tools (~/.local/bin)"
|
||||
local entry name url
|
||||
for entry in "${TOOLS[@]}"; do
|
||||
IFS='|' read -r name url <<<"$entry"
|
||||
# Also check ~/.local/bin directly: on a fresh machine this script may run from a shell that doesn't have it on PATH yet.
|
||||
if command -v "$name" >/dev/null 2>&1 || [ -x "$HOME/.local/bin/$name" ]; then
|
||||
info "already installed: $name"
|
||||
continue
|
||||
fi
|
||||
info "installing $name from $url"
|
||||
# TUICR_INSTALL_YES skips tuicr's confirmation prompt.
|
||||
curl -fsSL "$url" | TUICR_INSTALL_YES=1 sh
|
||||
done
|
||||
}
|
||||
|
||||
step_home() {
|
||||
log "home-manager ($HM_TARGET)"
|
||||
local out
|
||||
out="$(nix build --no-link --print-out-paths "$REPO#homeConfigurations.$HM_TARGET.activationPackage")"
|
||||
HOME_MANAGER_BACKUP_EXT=hm-backup "$out/activate"
|
||||
|
||||
if flatpak info --user app.zen_browser.zen >/dev/null 2>&1 \
|
||||
&& flatpak info --system app.zen_browser.zen >/dev/null 2>&1; then
|
||||
sudo flatpak uninstall --system -y --noninteractive app.zen_browser.zen
|
||||
info "removed system-wide Zen (user install takes over)"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
local steps=("$@") s
|
||||
[ ${#steps[@]} -eq 0 ] && steps=("${ALL_STEPS[@]}")
|
||||
for s in "${steps[@]}"; do
|
||||
if ! declare -F "step_$s" >/dev/null; then
|
||||
echo "unknown step: $s (valid: ${ALL_STEPS[*]})" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
for s in "${steps[@]}"; do "step_$s"; done
|
||||
|
||||
log "done"
|
||||
cat <<'EOF'
|
||||
First run only:
|
||||
- sudo tailscale up
|
||||
- log out and back in (zsh login shell, docker group, keyd is live already)
|
||||
EOF
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -0,0 +1,23 @@
|
||||
# Managed by ~/nixos/ubuntu (bootstrap.sh etc). Local edits get overwritten.
|
||||
[ids]
|
||||
*
|
||||
# YubiKey enumerates as a keyboard, ignore it.
|
||||
-1050:0407
|
||||
# logid's virtual keyboard.
|
||||
-0000:0000:48cf0dd2
|
||||
|
||||
[main]
|
||||
# Caps Lock <-> Left Control.
|
||||
capslock = layer(control)
|
||||
leftcontrol = capslock
|
||||
# Left Alt <-> Left Meta.
|
||||
leftalt = layer(meta)
|
||||
leftmeta = layer(alt)
|
||||
|
||||
# macOS-style clipboard, same mapping as omarchy's Hyprland binds
|
||||
# (default/hypr/bindings/clipboard.conf), done in keyd instead.
|
||||
# Ctrl/Shift+Insert copy/paste in GTK, Qt, browsers, Electron, and terminals.
|
||||
[meta]
|
||||
c = C-insert
|
||||
v = S-insert
|
||||
x = C-x
|
||||
@@ -0,0 +1,69 @@
|
||||
// Managed by ~/nixos/ubuntu (bootstrap.sh etc). Local edits get overwritten.
|
||||
// Ported from hosts/nixbox/configuration.nix.
|
||||
devices: (
|
||||
{
|
||||
name: "Wireless Mouse MX Master 3";
|
||||
|
||||
hiresscroll: {
|
||||
};
|
||||
|
||||
thumbwheel: {
|
||||
invert: true;
|
||||
};
|
||||
|
||||
buttons: (
|
||||
{
|
||||
cid: 0x53;
|
||||
action =
|
||||
{
|
||||
type : "Keypress";
|
||||
keys: ["KEY_LEFTMETA", "KEY_LEFT"];
|
||||
};
|
||||
},
|
||||
{
|
||||
cid: 0x56;
|
||||
action =
|
||||
{
|
||||
type : "Keypress";
|
||||
keys: ["KEY_LEFTMETA", "KEY_RIGHT"];
|
||||
};
|
||||
}
|
||||
);
|
||||
},
|
||||
{
|
||||
name: "MX Vertical Advanced Ergonomic Mouse";
|
||||
|
||||
hiresscroll: {
|
||||
hires: true;
|
||||
invert: false;
|
||||
target: false;
|
||||
};
|
||||
|
||||
buttons: (
|
||||
{
|
||||
cid: 0x53;
|
||||
action =
|
||||
{
|
||||
type : "Keypress";
|
||||
keys: ["KEY_LEFTMETA", "KEY_PAGEUP"];
|
||||
};
|
||||
},
|
||||
{
|
||||
cid: 0x56;
|
||||
action =
|
||||
{
|
||||
type : "Keypress";
|
||||
keys: ["KEY_LEFTMETA", "KEY_PAGEDOWN"];
|
||||
};
|
||||
},
|
||||
{
|
||||
cid: 0xfd;
|
||||
action =
|
||||
{
|
||||
type : "Keypress";
|
||||
keys: ["KEY_LEFTMETA"];
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user