From 35e92af40367ebc8cf41bbec9eb7c3144645204c Mon Sep 17 00:00:00 2001 From: Artem Sheremet Date: Thu, 14 May 2026 14:32:22 +0000 Subject: [PATCH] Create static build of mac-portable config --- README.md | 13 +++++-------- {migrated => assets}/.vimrc | 0 {migrated => assets}/.zshenv | 0 {migrated => assets}/.zshrc | 0 bin/export-home-config | 7 +++++++ flake.nix | 12 ++++++++++++ hosts/mars/home.nix | 3 +-- modules/home/common.nix | 13 +++++++------ 8 files changed, 32 insertions(+), 16 deletions(-) rename {migrated => assets}/.vimrc (100%) rename {migrated => assets}/.zshenv (100%) rename {migrated => assets}/.zshrc (100%) create mode 100755 bin/export-home-config diff --git a/README.md b/README.md index 1469223..8729c3e 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,11 @@ git clone git@github.com:dotdoom/dotfiles.git cd dotfiles ``` -Step 2 - stow. +Step 2 - if Nix is not an option. ``` -stow migrated stow legacy +stow exported/{machine} ``` Step 2 - Nix. @@ -30,15 +30,12 @@ nix run \ ## Layout -- `migrated`: files which are assets for home-manager, but can still be used to - stow +- `assets`: files which are assets for home-manager - `legacy`: files to be placed under `$HOME` which are still under stow - `hosts/*/{darwin,nixos,home}.nix`: personal machine nix configs - `modules/{darwin,nixos,home}/*.nix`: exported nix configs - -TODO: rename `migrated` to `assets` and create `exported` which would be the -exact mirror of nix-built configuration, but without nix (for machines where nix -can not be installed). That `exported` will then be used by stow. +- `exported`: for those poor souls who can not run nix, a pre-built collection + of files for `$HOME`, best effort ## Security diff --git a/migrated/.vimrc b/assets/.vimrc similarity index 100% rename from migrated/.vimrc rename to assets/.vimrc diff --git a/migrated/.zshenv b/assets/.zshenv similarity index 100% rename from migrated/.zshenv rename to assets/.zshenv diff --git a/migrated/.zshrc b/assets/.zshrc similarity index 100% rename from migrated/.zshrc rename to assets/.zshrc diff --git a/bin/export-home-config b/bin/export-home-config new file mode 100755 index 0000000..0c2aae9 --- /dev/null +++ b/bin/export-home-config @@ -0,0 +1,7 @@ +#!/bin/sh +set -e +CONFIG=$1 +OUT_DIR="exported/$CONFIG" +STORE_PATH=$(nix build .#homeConfigurations."$CONFIG".activationPackage --extra-experimental-features 'nix-command flakes' --no-link --print-out-paths) +mkdir -p "$OUT_DIR" +cp -rL "$STORE_PATH/home-files/." "$OUT_DIR/" diff --git a/flake.nix b/flake.nix index 70a5bf4..326336c 100644 --- a/flake.nix +++ b/flake.nix @@ -53,6 +53,12 @@ pre-commit-check = inputs.git-hooks.lib.${system}.run ( { src = ./.; + hooks.export-mac-portable = { + enable = nixpkgs.lib.hasInfix "darwin" system; + name = "Build static mac-portable home directory files"; + entry = "bin/export-home-config mac-portable && git add exported/mac-portable"; + pass_filenames = false; + }; } // inputs.fw_nix.lib.pre-commit ); @@ -92,6 +98,12 @@ ]; }; + homeConfigurations.mac-portable = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.x86_64-darwin; + extraSpecialArgs.primaryUser = "empty"; + modules = [ self.homeModules.mac-portable ]; + }; + darwinConfigurations.mars = darwin.lib.darwinSystem { system = "x86_64-darwin"; specialArgs.primaryUser = "artem"; diff --git a/hosts/mars/home.nix b/hosts/mars/home.nix index 16fe530..667d283 100644 --- a/hosts/mars/home.nix +++ b/hosts/mars/home.nix @@ -1,7 +1,6 @@ { pkgs, lib, - config, trustedSSHKeys, ... }: @@ -20,7 +19,7 @@ home.activation.setupAuthorizedKeys = lib.hm.dag.entryAfter [ "writeBoundary" ] '' run install -m 0600 -D \ ${pkgs.writeText "keys" (builtins.concatStringsSep "\n" trustedSSHKeys)} \ - ${config.home.homeDirectory}/.ssh/ephemeral_sshd/authorized_keys + ''${HOME?}/.ssh/ephemeral_sshd/authorized_keys ''; # TODO: consider diff --git a/modules/home/common.nix b/modules/home/common.nix index f25c892..1c1fa29 100644 --- a/modules/home/common.nix +++ b/modules/home/common.nix @@ -28,11 +28,11 @@ . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh fi - if [ -r ~/dotfiles/migrated/.zshrc ]; then + if [ -r ~/dotfiles/assets/.zshrc ]; then # Hack for faster iterations - . ~/dotfiles/migrated/.zshrc + . ~/dotfiles/assets/.zshrc else - . ${../../migrated/.zshrc} + . ${../../assets/.zshrc} fi ''; @@ -61,10 +61,11 @@ vim-startify ]; extraConfig = '' - if filereadable(expand("~/dotfiles/migrated/.vimrc")) - source ~/dotfiles/migrated/.vimrc + if filereadable(expand("~/dotfiles/assets/.vimrc")) + # Hack for faster iterations + source ~/dotfiles/assets/.vimrc else - source ${../../migrated/.vimrc} + source ${../../assets/.vimrc} endif ''; };