summaryrefslogtreecommitdiffstatshomepage
path: root/nix
diff options
context:
space:
mode:
authorsommerfeld <sommerfeld@sommerfeld.dev>2026-09-17 15:05:36 +0100
committersommerfeld <sommerfeld@sommerfeld.dev>2026-09-17 15:05:36 +0100
commitaff435a0fb3a56b1d7b738c7dede363440884b3a (patch)
tree07acb41d37760aa169ee42dbeb69da3621cc7489 /nix
parenta7f74c1fa4b89c5829f5896842eb7248c820704c (diff)
downloaddotfiles-aff435a0fb3a56b1d7b738c7dede363440884b3a.tar.gz
dotfiles-aff435a0fb3a56b1d7b738c7dede363440884b3a.tar.bz2
dotfiles-aff435a0fb3a56b1d7b738c7dede363440884b3a.zip
Add the Canonical laptop profile and setup workflows
Diffstat (limited to 'nix')
-rw-r--r--nix/canonical.nix24
-rw-r--r--nix/flake.nix5
-rw-r--r--nix/host.nix21
-rw-r--r--nix/justfile9
-rw-r--r--nix/switch.sh33
-rw-r--r--nix/whisper-model.nix21
6 files changed, 90 insertions, 23 deletions
diff --git a/nix/canonical.nix b/nix/canonical.nix
new file mode 100644
index 0000000..0f37427
--- /dev/null
+++ b/nix/canonical.nix
@@ -0,0 +1,24 @@
+{ pkgs, lib, ... }:
+{
+ imports = [ ./common.nix ];
+ home.username = builtins.getEnv "USER";
+ home.homeDirectory = builtins.getEnv "HOME";
+ home.sessionVariables.NVIM_TREESITTER_CC = "${pkgs.stdenv.cc}/bin/cc";
+ home.packages = with pkgs; [
+ external-editor-revived
+ gnome-extensions-cli
+ wl-clipboard
+ qrencode
+ libnotify
+ playerctl
+ pulseaudio
+ (tesseract.override {
+ enableLanguages = [
+ "eng"
+ "por"
+ ];
+ })
+ whisper-cpp
+ (import ./whisper-model.nix { inherit pkgs lib; })
+ ];
+}
diff --git a/nix/flake.nix b/nix/flake.nix
index d871ce7..b140bf0 100644
--- a/nix/flake.nix
+++ b/nix/flake.nix
@@ -260,6 +260,10 @@
devShells.${system}.default = pkgs.mkShellNoCC {
packages = with pkgs; [
basedpyright
+ chezmoi
+ git
+ jq
+ python3
just
nixfmt
prettier
@@ -275,6 +279,7 @@
homeConfigurations = {
vm = mkProfile ./vm.nix;
host = mkProfile ./host.nix;
+ canonical = mkProfile ./canonical.nix;
};
};
}
diff --git a/nix/host.nix b/nix/host.nix
index 588d635..b3d9d60 100644
--- a/nix/host.nix
+++ b/nix/host.nix
@@ -9,26 +9,7 @@
# Arch host Home-Manager package profile.
let
- whisper-cpp-model-base = pkgs.stdenvNoCC.mkDerivation rec {
- pname = "whisper-cpp-model-base";
- version = "1.0";
- src = pkgs.fetchurl {
- url = "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.bin";
- hash = "sha256-YO1bw90U7qhWST0zQ0m0BXgt3K8AKNS130CINF+6Lv4=";
- };
- dontUnpack = true;
- installPhase = ''
- runHook preInstall
- install -Dm644 $src $out/share/whisper-cpp-models/ggml-base.bin
- runHook postInstall
- '';
- meta = with lib; {
- description = "Whisper.cpp ggml-base.bin model (142 MB, multilingual)";
- homepage = "https://huggingface.co/ggerganov/whisper.cpp";
- license = licenses.mit;
- platforms = platforms.all;
- };
- };
+ whisper-cpp-model-base = import ./whisper-model.nix { inherit pkgs lib; };
pass-secret-service-rust = pkgs.rustPlatform.buildRustPackage rec {
pname = "pass-secret-service";
version = "0.7.0";
diff --git a/nix/justfile b/nix/justfile
index 4ecd75b..7ea7b30 100644
--- a/nix/justfile
+++ b/nix/justfile
@@ -13,7 +13,7 @@ pull:
# Rebuild Home-Manager profile from the current checkout (no pull)
switch:
- home-manager switch --impure --flake '{{ justfile_directory() }}#vm' -b backup
+ bash '{{ justfile_directory() }}/switch.sh' vm
# Apply VM dotfiles with chezmoi
apply: _ensure-vm-chezmoi-config
@@ -37,6 +37,9 @@ _ensure-vm-chezmoi-config:
fix-gpg-agent:
#!/usr/bin/env sh
set -eu
+ . "{{ justfile_directory() }}/../just-lib.sh"
+ DOTFILES_SOURCE="{{ justfile_directory() }}/.."
+ [ "$(_machine_role)" = vm ]
gpgconf_bin="$HOME/.nix-profile/bin/gpgconf"
gpg_connect_agent_bin="$HOME/.nix-profile/bin/gpg-connect-agent"
[ -x "$gpgconf_bin" ] || gpgconf_bin=$(command -v gpgconf)
@@ -59,7 +62,7 @@ fix-gpg-agent:
"$gpg_connect_agent_bin" 'getinfo version' /bye
# One-time migration from the old VM Home-Manager symlink deployment to chezmoi
-migrate-chezmoi: pull switch fix-gpg-agent _cleanup-home-manager-dotfiles apply
+migrate-chezmoi: pull _ensure-vm-chezmoi-config switch fix-gpg-agent _cleanup-home-manager-dotfiles apply
_cleanup-home-manager-dotfiles: _ensure-vm-chezmoi-config
#!/usr/bin/env bash
@@ -90,7 +93,7 @@ _cleanup-home-manager-dotfiles: _ensure-vm-chezmoi-config
# remove the old file when it still exactly matches the repo source.
ssh_config="$HOME/.ssh/config"
if [ -f "$ssh_config" ] && [ ! -L "$ssh_config" ]; then
- if cmp -s "$ssh_config" "$src/private_dot_ssh/config"; then
+ if cmp -s "$ssh_config" <(chezmoi execute-template -S "$src" --file "$src/private_dot_ssh/config.tmpl"); then
rm -f "$ssh_config"
else
printf 'refusing to overwrite modified %s; merge it before migrating\n' "$ssh_config" >&2
diff --git a/nix/switch.sh b/nix/switch.sh
new file mode 100644
index 0000000..ce63855
--- /dev/null
+++ b/nix/switch.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+set -euo pipefail
+root=$(cd "$(dirname "$0")/.." && pwd)
+cd "$root"
+source "$root/just-lib.sh"
+profile=$(_machine_role)
+if ! command -v nix >/dev/null 2>&1; then
+ [[ $profile != canonical ]] || {
+ echo 'Install upstream Nix first.' >&2
+ exit 1
+ }
+ echo 'Nix is not installed; skipping Home-Manager.' >&2
+ exit 0
+fi
+if [[ -n ${1:-} && $profile != "$1" ]]; then
+ echo "error: expected role $1, got $profile" >&2
+ exit 1
+fi
+export USER="${USER:-$(id -un)}"
+export HOME="${HOME:?HOME must be set}"
+generation=$(sh "$root/nix/with-github-auth.sh" \
+ nix --extra-experimental-features 'nix-command flakes' build --impure \
+ --no-link --print-out-paths "$root/nix#homeConfigurations.$profile.activationPackage")
+HOME_MANAGER_BACKUP_EXT=backup "$generation/activate"
+if [[ $profile != canonical ]]; then
+ shell="$HOME/.nix-profile/bin/zsh"
+ if ! grep -qxF "$shell" /etc/shells; then
+ printf '%s\n' "$shell" | sudo tee -a /etc/shells >/dev/null
+ fi
+ if [[ $(getent passwd "$USER" | cut -d: -f7) != "$shell" ]]; then
+ sudo chsh -s "$shell" "$USER"
+ fi
+fi
diff --git a/nix/whisper-model.nix b/nix/whisper-model.nix
new file mode 100644
index 0000000..3582bd3
--- /dev/null
+++ b/nix/whisper-model.nix
@@ -0,0 +1,21 @@
+{ pkgs, lib }:
+pkgs.stdenvNoCC.mkDerivation rec {
+ pname = "whisper-cpp-model-base";
+ version = "1.0";
+ src = pkgs.fetchurl {
+ url = "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.bin";
+ hash = "sha256-YO1bw90U7qhWST0zQ0m0BXgt3K8AKNS130CINF+6Lv4=";
+ };
+ dontUnpack = true;
+ installPhase = ''
+ runHook preInstall
+ install -Dm644 $src $out/share/whisper-cpp-models/ggml-base.bin
+ runHook postInstall
+ '';
+ meta = with lib; {
+ description = "Whisper.cpp ggml-base.bin model (142 MB, multilingual)";
+ homepage = "https://huggingface.co/ggerganov/whisper.cpp";
+ license = licenses.mit;
+ platforms = platforms.all;
+ };
+}