diff --git a/.sops.yaml b/.sops.yaml index aaf3e03..e10bd39 100644 --- a/.sops.yaml +++ b/.sops.yaml @@ -3,6 +3,7 @@ keys: - &muho age1v4s4hg7u3vjjkarvrk7v6ev7w3wja2r5xm7f4t06culw3fuq7qns8sfju7 - &mups age1n7qz2w3hkf7fcdv92kxw9k6uef487na2tlc87486rcjwj8lyfuws5q46gn - &murk age1mgjhkqy9x27gv2t2xvq46dxcajkr9c8zes7rr3dj0ac7md2j6vas43dftp + - &musk age1m97a3eptxwpdd7h5kkqe9gkmhg6rquc64qjmlsfqfhfqv8q72crqrylhgc creation_rules: - path_regex: modules/nixos/sops/secrets.ya?ml$ @@ -12,6 +13,7 @@ creation_rules: - *muho - *mups - *murk + - *musk - path_regex: modules/home/sops/secrets.ya?ml$ key_groups: @@ -20,3 +22,4 @@ creation_rules: - *muho - *mups - *murk + - *musk diff --git a/flake.lock b/flake.lock index f958a84..3ed83fb 100644 --- a/flake.lock +++ b/flake.lock @@ -233,11 +233,11 @@ ] }, "locked": { - "lastModified": 1768598210, - "narHash": "sha256-kkgA32s/f4jaa4UG+2f8C225Qvclxnqs76mf8zvTVPg=", + "lastModified": 1768912518, + "narHash": "sha256-FJlof1jnbLIT5RbKxef/NV6RzcOj1GoMzXE4FcBFg5Y=", "owner": "nix-community", "repo": "home-manager", - "rev": "c47b2cc64a629f8e075de52e4742de688f930dc6", + "rev": "9c5f8aceb6ef620e881f50fe65cb4a2c6b1e8527", "type": "github" }, "original": { @@ -254,11 +254,11 @@ ] }, "locked": { - "lastModified": 1747978958, - "narHash": "sha256-pQQnbxWpY3IiZqgelXHIe/OAE/Yv4NSQq7fch7M6nXQ=", + "lastModified": 1768598210, + "narHash": "sha256-kkgA32s/f4jaa4UG+2f8C225Qvclxnqs76mf8zvTVPg=", "owner": "nix-community", "repo": "home-manager", - "rev": "7419250703fd5eb50e99bdfb07a86671939103ea", + "rev": "c47b2cc64a629f8e075de52e4742de688f930dc6", "type": "github" }, "original": { @@ -275,11 +275,11 @@ ] }, "locked": { - "lastModified": 1767104570, - "narHash": "sha256-GKgwu5//R+cLdKysZjGqvUEEOGXXLdt93sNXeb2M/Lk=", + "lastModified": 1768434960, + "narHash": "sha256-cJbFn17oyg6qAraLr+NVeNJrXsrzJdrudkzI4H2iTcg=", "owner": "nix-community", "repo": "home-manager", - "rev": "e4e78a2cbeaddd07ab7238971b16468cc1d14daf", + "rev": "b4d88c9ac42ae1a745283f6547701da43b6e9f9b", "type": "github" }, "original": { @@ -294,11 +294,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1767822991, - "narHash": "sha256-iyrn9AcPZCoyxX4OT8eMkBsjG7SRUQXXS/V1JzxS7rA=", + "lastModified": 1768835187, + "narHash": "sha256-6nY0ixjGjPQCL+/sUC1B1MRiO1LOI3AkRSIywm3i3bE=", "owner": "nix-community", "repo": "impermanence", - "rev": "82e5bc4508cab9e8d5a136626276eb5bbce5e9c5", + "rev": "0d633a69480bb3a3e2f18c080d34a8fa81da6395", "type": "github" }, "original": { @@ -350,11 +350,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1768475717, - "narHash": "sha256-185VOlWF4K9gzwr7M56ArjqDt6beN/5TxCYLEyVPOcs=", + "lastModified": 1768904356, + "narHash": "sha256-TIG8J+Or8nOydy8TztvtIshnprlf1q6XDIJnopLtMlA=", "owner": "thiagokokada", "repo": "nix-alien", - "rev": "a579610c67dc946f39c2a64656699eb29eb2ffb5", + "rev": "d95b25a4dd6da2a1dfeaaf66163d0a281a8270e9", "type": "github" }, "original": { @@ -422,11 +422,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1748026106, - "narHash": "sha256-6m1Y3/4pVw1RWTsrkAK2VMYSzG4MMIj7sqUy7o8th1o=", + "lastModified": 1768564909, + "narHash": "sha256-Kell/SpJYVkHWMvnhqJz/8DqQg2b6PguxVWOuadbHCc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "063f43f2dbdef86376cc29ad646c45c46e93234c", + "rev": "e4bae1bd10c9c57b2cf517953ab70060a828ee6f", "type": "github" }, "original": { @@ -573,11 +573,11 @@ ] }, "locked": { - "lastModified": 1768481291, - "narHash": "sha256-NjKtkJraCZEnLHAJxLTI+BfdU//9coAz9p5TqveZwPU=", + "lastModified": 1768863606, + "narHash": "sha256-1IHAeS8WtBiEo5XiyJBHOXMzECD6aaIOJmpQKzRRl64=", "owner": "Mic92", "repo": "sops-nix", - "rev": "e085e303dfcce21adcb5fec535d65aacb066f101", + "rev": "c7067be8db2c09ab1884de67ef6c4f693973f4a2", "type": "github" }, "original": { @@ -626,11 +626,11 @@ "tinted-zed": "tinted-zed" }, "locked": { - "lastModified": 1768603455, - "narHash": "sha256-ih6dYNhX1oSg0emfSAvf3iRcgsJtMmS6RUaoCX8kNoU=", + "lastModified": 1768744881, + "narHash": "sha256-3+h7OxqfrPIB/tRsiZXWE9sCbTm7NQN5Ie428p+S6BA=", "owner": "danth", "repo": "stylix", - "rev": "590e5c68c4d5e8c766420473c0185d75113f653b", + "rev": "06684f00cfbee14da96fd4307b966884de272d3a", "type": "github" }, "original": { @@ -794,11 +794,11 @@ ] }, "locked": { - "lastModified": 1768638486, - "narHash": "sha256-+LC0wOiliUXbIj6zT2hCoOQ0zn33BD2NxGoy0QqP3Eo=", + "lastModified": 1768857659, + "narHash": "sha256-93pj/A2s26CUZwvCpN0CL6a1NhLpYVzidzc/Vk2GKCI=", "owner": "0xc000022070", "repo": "zen-browser-flake", - "rev": "76bbc35c59419b8b0616fb779ce5600e85edab11", + "rev": "3a42efe341d068f13ffb961ed832474128b844f3", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index f478b06..ff6de6a 100644 --- a/flake.nix +++ b/flake.nix @@ -67,6 +67,9 @@ # work murk = utils.mkHost ./hosts/murk/configuration.nix; + # work desktop + musk = utils.mkHost ./hosts/musk/configuration.nix; + # lenovo muvo = utils.mkHost ./hosts/muvo/configuration.nix; diff --git a/hosts/murk/home.nix b/hosts/murk/home.nix index d92ed66..706f35d 100644 --- a/hosts/murk/home.nix +++ b/hosts/murk/home.nix @@ -19,10 +19,12 @@ in { mods.terminal.emulator.enable = true; mods.terminal.development.enable = true; mods.terminal.tools.enable = true; + mods.terminal.hr.enable = true; mods.desktop.development.enable = true; mods.desktop.productivity.enable = false; mods.zen.enable = true; mods.obsidian.enable = true; + mods.theme.slideshow = true; home.packages = with pkgs; [ diff --git a/hosts/musk/configuration.nix b/hosts/musk/configuration.nix new file mode 100644 index 0000000..b9868c3 --- /dev/null +++ b/hosts/musk/configuration.nix @@ -0,0 +1,117 @@ +{ + config, + lib, + pkgs, + inputs, + system, + sources, + modulesPath, + ... +}: let + cfg = config.mods; + keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKEio+Y5wBVD1wILaH2R3wV10FvVjiqy/4gGBWHOITTB muon@muon" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKevYmkH7xvYoquBjnYZ7PJiVqf+GOh9fxAJBN6wZGBB gin4@hi.is" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILmAOd9VbhyJeibt6Vrb101MNTk5W8+rh94Djv/C+pyu muon@muho" + ]; +in { + # Hardware + imports = [ + ./hardware-configuration.nix + "${ + builtins.fetchTarball { + url = "https://github.com/nix-community/disko/archive/refs/tags/v1.12.0.tar.gz"; + sha256 = "0wbx518d2x54yn4xh98cgm65wvj0gpy6nia6ra7ns4j63hx14fkq"; + } + }/module.nix" + ./disk-config.nix + # (inputs.nixpkgs + # + "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix") + ]; + + environment.systemPackages = with inputs.nix-alien.packages.${system}; [ + nix-alien + pkgs.libratbag + pkgs.piper + pkgs.libpq + pkgs.qmk + pkgs.jq + pkgs.wireguard-tools + pkgs.opencode + ]; + + boot.binfmt = { + emulatedSystems = ["aarch64-linux"]; + preferStaticEmulators = true; # Make it work with Docker + }; + + # System + mods.user.name = "muon"; + networking.hostName = "musk"; + networking.hostId = "a2309091"; + mods.home.file = ./home.nix; + nix.settings.trusted-users = ["root" "muon"]; + users.users.muon.extraGroups = ["docker"]; + + # Modules + mods.desktop.enable = true; + mods.boot.enable = true; + + mods.theme.enable = true; + mods.theme.scheme = "woodland"; + mods.theme.wallpaper = ./wallpaper.png; + + services.xserver.windowManager.i3.enable = true; + # mods.desktop.wayland.enable = true; + + mods.impermanence.enable = true; + + virtualisation.docker.enable = true; + + users.users.muon.openssh.authorizedKeys.keys = keys; + users.users.root.openssh.authorizedKeys.keys = keys; + + # Persist + environment.persistence."/persist" = { + directories = ["/etc/NetworkManager" "/var/lib/NetworkManager"]; + }; + + # Hardware preferences + environment.variables = { + WINIT_HIDPI_FACTOR = "1"; + WINIT_X11_SCALE_FACTOR = "1"; + }; + + ## Monitors + mods.monitors = { + primary = { + name = "DP-1"; + config = { + enable = true; + mode = "2560x1440"; + position = "0x0"; + rate = "60.00"; + dpi = 72; + }; + }; + right = { + name = "HDMI-1"; + config = { + enable = true; + mode = "2560x1440"; + position = "2560x0"; + rate = "60.00"; + dpi = 72; + }; + }; + }; + + ## Mouse + services.libinput.mouse.accelProfile = "flat"; + + ## Keyboard + hardware.keyboard.qmk.enable = true; + + # Version of first install + system.stateVersion = "23.05"; +} diff --git a/hosts/musk/disk-config.nix b/hosts/musk/disk-config.nix new file mode 100644 index 0000000..05a9f01 --- /dev/null +++ b/hosts/musk/disk-config.nix @@ -0,0 +1,72 @@ +{ + disko.devices = { + disk = { + main = { + type = "disk"; + device = "/dev/sda"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + luks = { + size = "100%"; + content = { + type = "luks"; + name = "crypted"; + # disable settings.keyFile if you want to use interactive password entry + #passwordFile = "/tmp/secret.key"; # Interactive + # settings = { + # allowDiscards = true; + # keyFile = "/tmp/secret.key"; + # }; + # additionalKeyFiles = [ "/tmp/additionalSecret.key" ]; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "/root" = { + mountpoint = "/"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/home" = { + mountpoint = "/home"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/persist" = { + mountpoint = "/persist"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/log" = { + mountpoint = "/var/log"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/swap" = { + mountpoint = "/swap"; + swap.swapfile.size = "4G"; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; + + fileSystems."/persist".neededForBoot = true; + fileSystems."/var/log".neededForBoot = true; +} diff --git a/hosts/musk/hardware-configuration.nix b/hosts/musk/hardware-configuration.nix new file mode 100644 index 0000000..332920b --- /dev/null +++ b/hosts/musk/hardware-configuration.nix @@ -0,0 +1,18 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/musk/home.nix b/hosts/musk/home.nix new file mode 100644 index 0000000..0bd1d49 --- /dev/null +++ b/hosts/musk/home.nix @@ -0,0 +1,83 @@ +{ + pkgs, + lib, + config, + osConfig, + inputs, + ... +}: let + cfg = osConfig.mods; +in { + # Modules + mods.xdg.enable = true; + mods.i3.enable = true; + # mods.hyprland.enable = true; + mods.terminal.zsh.enable = true; + mods.terminal.emulator.enable = true; + mods.terminal.development.enable = true; + mods.terminal.tools.enable = true; + mods.terminal.hr.enable = true; + mods.desktop.development.enable = true; + mods.desktop.productivity.enable = false; + mods.zen.enable = true; + + home.packages = with pkgs; + [ + thunderbird + pulseaudio + pavucontrol + alsa-utils + rustdesk-flutter + + # tools + docker + fish + devenv + dbeaver-bin + ruff + just + go + rainfrog + tealdeer + gh + (callPackage ./packages/mender-cli.nix {}) + ] + # Non-free " + echo "Commands:" + echo " switch Switch PROJECT_ID between mk2-test and mk2-prod" + echo " call Call a Cloud Run service route" + echo " cf Call a Cloud Function" + echo " init py Initialize a python devenv environment (git-ignored)" + echo " freeze Freeze dependencies to requirements.txt" +} + +_hr_init_devenv() { + if [ -f .gitignore ]; then + cp .gitignore .gitignore.bak + fi + + if command -v devenv >/dev/null; then + devenv init + echo "Direnv allowed" + else + echo "Error: devenv not found in path." + return 1 + fi + + if [ -f .gitignore.bak ]; then + mv .gitignore.bak .gitignore + elif [ -f .gitignore ]; then + rm .gitignore + fi +} + +_hr_add_ignores() { + if git rev-parse --git-dir >/dev/null 2>&1; then + EXCLUDE_FILE=$(git rev-parse --git-path info/exclude) + mkdir -p "$(dirname "$EXCLUDE_FILE")" + + for file in "$@"; do + if ! grep -Fxq "$file" "$EXCLUDE_FILE" 2>/dev/null; then + echo "$file" >>"$EXCLUDE_FILE" + echo "Added $file to local git exclude ($EXCLUDE_FILE)" + fi + done + else + echo "Warning: Not a git repository. Skipping git ignore setup." + fi +} + +_hr_py_files() { + cat <devenv.nix +{pkgs, ...}: { + packages = [ pkgs.google-cloud-sdk ]; + + languages.python = { + enable = true; + venv.enable = true; + uv = { + enable = true; + sync.enable = false; + }; + }; + + # We use the named index "google" defined in uv.toml + env.UV_INDEX_GOOGLE_USERNAME = "oauth2accesstoken"; + env.PROJECT_ID = "mk2-test"; + + enterShell = '' + if ! gcloud auth print-access-token >/dev/null 2>&1; then + echo "⚠️ gcloud not authenticated. Run 'gcloud auth login' to access Google Artifact Registry." + else + export UV_INDEX_GOOGLE_PASSWORD=\$(gcloud auth print-access-token) + fi + uv sync + ''; +} +EOF + + cat <uv.toml +[[index]] +name = "google" +url = "https://europe-west1-python.pkg.dev/mk2-prod/python-packages/simple/" +EOF +} + +_hr_rs_files() { + cat <devenv.nix +{pkgs, ...}: { + languages.rust = { + enable = true; + channel = "stable"; + }; +} +EOF + + cat <devenv.yaml +inputs: + rust-overlay: + url: github:oxalica/rust-overlay + inputs: + nixpkgs: + follows: nixpkgs +EOF +} + +_hr_cpp_files() { + cat <devenv.nix +{ pkgs, ... }: +let + # Use glibc-compatible static openssl to match system libs + staticOpenSSL = pkgs.openssl.override { static = true; }; + + # Shim to satisfy CMake looking for "ssl.a" + compatOpenSSL = pkgs.runCommand "openssl-compat" {} '' + mkdir -p \$out/lib + ln -s \${staticOpenSSL.out}/lib/libssl.a \$out/lib/ssl.a + ln -s \${staticOpenSSL.out}/lib/libcrypto.a \$out/lib/crypto.a + ''; +in { + packages = [ + pkgs.cmake + pkgs.clang-tools + pkgs.pkg-config + pkgs.mosquitto + + staticOpenSSL + compatOpenSSL + ]; + # Explicitly add lib paths so linker finds -lssl AND ssl.a + env.LIBRARY_PATH = "\${staticOpenSSL.out}/lib:\${compatOpenSSL}/lib"; + env.CPATH = "\${staticOpenSSL.dev}/include"; + + languages.cplusplus.enable = true; +} +EOF +} + +_hr_init_base() { + local name="$1" + local func="$2" + shift 2 + local ignores=("$@") + echo "Initializing $name devenv..." + + # 1. Init devenv + _hr_init_devenv + + # 2. Replace devenv.nix + "$func" + + # 3. Add to local git exclude + IGNORES=( + ".devenv*" + ".direnv" + "devenv.nix" + "devenv.yaml" + "devenv.lock" + ".envrc" + "${ignores[@]}" + ) + _hr_add_ignores "${IGNORES[@]}" + + direnv allow +} + +_hr_init_py() { + IGNORES=( + "uv.lock" + "uv.toml" + ) + _hr_init_base "Python" _hr_py_files "${IGNORES[@]}" +} + +_hr_init_rs() { + _hr_init_base "Rust" _hr_rs_files +} + +_hr_init_cpp() { + _hr_init_base "C++" _hr_cpp_files + mkdir -p build && + cd build && + cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release .. && + make -j$(nproc) && + cp compile_commands.json .. +} + +_hr_freeze() { + local extra_index_url="https://europe-west1-python.pkg.dev/mk2-prod/python-packages/simple/" + + # Install the auth plugin and keyring CLI + uv pip install keyrings.google-artifactregistry-auth==1.1.2 keyring + + # Install project dependencies using the subprocess keyring provider + uv pip install --no-cache -e ".[test]" --extra-index-url "${extra_index_url}" --keyring-provider subprocess + + # Generate requirements.txt + echo "--extra-index-url ${extra_index_url}" >requirements.txt + uv pip freeze --exclude-editable >>requirements.txt +} + +_hr_add_json_field() { + local json="$1" + local key="$2" + local value="$3" + local jq_opt="--arg" + + # Check if explicit boolean + if [[ "$value" == "true" || "$value" == "false" ]]; then + jq_opt="--argjson" + # Check if number (integer or float, no leading zeros unless just 0) + elif [[ "$value" =~ ^-?(0|[1-9][0-9]*)(\.[0-9]+)?$ ]]; then + jq_opt="--argjson" + # Check if object or array + elif [[ "$value" == "["* || "$value" == "{"* ]]; then + if echo "$value" | jq empty >/dev/null 2>&1; then + jq_opt="--argjson" + else + # Warn to stderr, but proceed as string + echo "Warning: Value for '$key' looks like JSON but is invalid. Treating as string." >&2 + fi + fi + + # Apply the value at the path defined by the key (dot-notation supported) + # paths like items.0.id are converted to ["items", 0, "id"] + echo "$json" | jq --arg k "$key" $jq_opt v "$value" \ + 'setpath($k | split(".") | map(if test("^[0-9]+$") then tonumber else . end); $v)' +} + +_hr_call() { + local route_arg="$1" + shift + + if [[ -z "$route_arg" ]]; then + echo "Usage: hr call [/path] " + return 1 + fi + + local service_name + local url_path + + if [[ "$route_arg" == */* ]]; then + service_name="${route_arg%%/*}" + url_path="/${route_arg#*/}" + else + service_name="$route_arg" + url_path="" + fi + + local project_number + if [[ "$PROJECT_ID" == "mk2-prod" ]]; then + project_number="1013087376822" + else + project_number="322048751601" + fi + + if ! command -v jq >/dev/null; then + echo "Error: jq is required but not installed." + return 1 + fi + + local json_payload="{}" + + while [[ $# -gt 0 ]]; do + if [[ "$1" == -* ]]; then + local key="${1#-}" + if [[ -z "$2" || "$2" == -* ]]; then + echo "Error: Missing value for option $key" + return 1 + fi + local value="$2" + + json_payload=$(_hr_add_json_field "$json_payload" "$key" "$value") + shift 2 + else + echo "Error: Unexpected argument '$1'" + return 1 + fi + done + + local url="https://${service_name}-${project_number}.europe-west1.run.app${url_path}" + + echo "Calling $url..." + echo "$json_payload" + + curl "$url" \ + -H "Authorization: bearer $(gcloud auth print-identity-token)" \ + -H "Content-Type: application/json" \ + -d "$json_payload" +} + +_hr_cf() { + local function_name="$1" + shift + + if [[ -z "$function_name" ]]; then + echo "Usage: hr cf " + return 1 + fi + + if ! command -v jq >/dev/null; then + echo "Error: jq is required but not installed." + return 1 + fi + + local json_payload="{}" + + while [[ $# -gt 0 ]]; do + if [[ "$1" == -* ]]; then + local key="${1#-}" + if [[ -z "$2" || "$2" == -* ]]; then + echo "Error: Missing value for option $key" + return 1 + fi + local value="$2" + + json_payload=$(_hr_add_json_field "$json_payload" "$key" "$value") + shift 2 + else + echo "Error: Unexpected argument '$1'" + return 1 + fi + done + + local url="https://europe-west1-${PROJECT_ID}.cloudfunctions.net/${function_name}" + + echo "Calling $url..." + echo "$json_payload" + + curl "$url" \ + -H "Authorization: bearer $(gcloud auth print-identity-token)" \ + -H "Content-Type: application/json" \ + -d "$json_payload" +} + +hr() { + if [[ $# -eq 0 ]]; then + _hr_usage + return 1 + fi + + local command="$1" + shift + + if [[ "$command" == "switch" ]]; then + if [[ -z "$1" ]]; then + # Toggle between test and prod + if [[ "$PROJECT_ID" == "mk2-test" ]]; then + export PROJECT_ID="mk2-prod" + echo "Switched PROJECT_ID to mk2-prod" + else + export PROJECT_ID="mk2-test" + echo "Switched PROJECT_ID to mk2-test" + fi + elif [[ "$1" == "test" ]]; then + export PROJECT_ID="mk2-test" + echo "Set PROJECT_ID to mk2-test" + elif [[ "$1" == "prod" ]]; then + export PROJECT_ID="mk2-prod" + echo "Set PROJECT_ID to mk2-prod" + else + echo "Usage: hr switch [test|prod]" + return 1 + fi + return 0 + fi + + # Run original logic in a subshell to preserve set -e behavior without affecting current shell + ( + set -e + # Restore arguments for processing + set -- "$command" "$@" + + if [ "$1" = "init" ] && [ "$2" = "py" ]; then + _hr_init_py + elif [ "$1" = "init" ] && [ "$2" = "rs" ]; then + _hr_init_rs + elif [ "$1" = "init" ] && [ "$2" = "cpp" ]; then + _hr_init_cpp + elif [ "$1" = "freeze" ]; then + _hr_freeze + elif [ "$1" = "call" ]; then + shift + _hr_call "$@" + elif [ "$1" = "cf" ]; then + shift + _hr_cf "$@" + else + _hr_usage + exit 1 + fi + ) +} diff --git a/modules/home/terminal/nvim/default.nix b/modules/home/terminal/nvim/default.nix index 6bdff05..9ea251e 100644 --- a/modules/home/terminal/nvim/default.nix +++ b/modules/home/terminal/nvim/default.nix @@ -1,9 +1,22 @@ { + pkgs, lib, config, inputs, ... -}: { +}: let + d2-vim = pkgs.vimUtils.buildVimPlugin { + pname = "d2-vim"; + version = "0.1.0"; + src = pkgs.fetchFromGitHub { + owner = "terrastruct"; + repo = "d2-vim"; + rev = "cb3eb7fcb1a2d45c4304bf2e91077d787b724a39"; + hash = "sha256-HmDQfOIoSV93wqRe7O4FPuHEmAxwoP1+Ut+sKhB62jA="; + fetchSubmodules = true; + }; + }; +in { options.mods.nvim.enable = lib.mkEnableOption "enables nvim"; @@ -13,6 +26,7 @@ ]; config = lib.mkIf config.mods.nvim.enable { + home.packages = [pkgs.d2]; programs.nvf = { enable = true; settings = { @@ -70,6 +84,8 @@ }; }; + startPlugins = [d2-vim]; + treesitter = { enable = true; context.enable = true;