nixos: replace rcm with home-manager dotfile links
This commit is contained in:
65
nixos/dotfiles-links.nix
Normal file
65
nixos/dotfiles-links.nix
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
# Replicate the useful part of rcm/rcup:
|
||||||
|
# - dotfiles live in ~/dotfiles/dotfiles (no leading dots in the repo)
|
||||||
|
# - links in $HOME add a leading '.' to the first path component
|
||||||
|
# - link files individually so unmanaged state can coexist (e.g. ~/.cabal/store)
|
||||||
|
#
|
||||||
|
# Use out-of-store symlinks so editing the repo updates config immediately
|
||||||
|
# without a rebuild/switch (only link *placement* is managed by HM).
|
||||||
|
oos = config.lib.file.mkOutOfStoreSymlink;
|
||||||
|
|
||||||
|
# Where the checked-out repo lives at runtime (activation time).
|
||||||
|
worktreeDotfiles = "${config.home.homeDirectory}/dotfiles/dotfiles";
|
||||||
|
|
||||||
|
# Use the flake source for enumeration (pure), but point links at the worktree.
|
||||||
|
srcDotfiles = ../dotfiles;
|
||||||
|
|
||||||
|
excludedTop = [
|
||||||
|
# Managed by Nix directly (PATH/fpath), not meant to appear as ~/.lib.
|
||||||
|
"lib"
|
||||||
|
# Avoid colliding with HM-generated xdg.configFile entries for now.
|
||||||
|
"config"
|
||||||
|
# Handled as a single directory symlink below.
|
||||||
|
"emacs.d"
|
||||||
|
];
|
||||||
|
|
||||||
|
firstComponent = rel:
|
||||||
|
let parts = lib.splitString "/" rel;
|
||||||
|
in lib.elemAt parts 0;
|
||||||
|
|
||||||
|
isExcluded = rel: lib.elem (firstComponent rel) excludedTop;
|
||||||
|
|
||||||
|
listFilesRec = dir:
|
||||||
|
let
|
||||||
|
entries = builtins.readDir dir;
|
||||||
|
names = builtins.attrNames entries;
|
||||||
|
go = name:
|
||||||
|
let
|
||||||
|
ty = entries.${name};
|
||||||
|
path = dir + "/${name}";
|
||||||
|
in
|
||||||
|
if ty == "directory" then
|
||||||
|
map (p: "${name}/${p}") (listFilesRec path)
|
||||||
|
else
|
||||||
|
[ name ];
|
||||||
|
in
|
||||||
|
lib.concatLists (map go names);
|
||||||
|
|
||||||
|
managedRelFiles =
|
||||||
|
lib.filter (rel: !(isExcluded rel)) (listFilesRec srcDotfiles);
|
||||||
|
|
||||||
|
mkManaged = rel:
|
||||||
|
lib.nameValuePair ".${rel}" {
|
||||||
|
source = oos "${worktreeDotfiles}/${rel}";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
home.file =
|
||||||
|
(builtins.listToAttrs (map mkManaged managedRelFiles))
|
||||||
|
// {
|
||||||
|
# Keep ~/.emacs.d as a directory symlink (matches current setup).
|
||||||
|
".emacs.d".source = oos "${worktreeDotfiles}/emacs.d";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,6 @@
|
|||||||
pulseaudio
|
pulseaudio
|
||||||
python-with-my-packages
|
python-with-my-packages
|
||||||
rclone
|
rclone
|
||||||
rcm
|
|
||||||
ripgrep
|
ripgrep
|
||||||
runc
|
runc
|
||||||
silver-searcher
|
silver-searcher
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
home-manager.users.imalison = {
|
home-manager.users.imalison = {
|
||||||
imports = [
|
imports = [
|
||||||
./emacs.nix
|
./emacs.nix
|
||||||
|
./dotfiles-links.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
# Hyprland config starts this target on login (see `dotfiles/config/hypr/hyprland.conf`).
|
# Hyprland config starts this target on login (see `dotfiles/config/hypr/hyprland.conf`).
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
export THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
export DOTFILES_DIR="$(readlink -f $THIS_DIR/dotfiles)"
|
|
||||||
|
|
||||||
echo $DOTFILES_DIR
|
|
||||||
rcup -d $DOTFILES_DIR -S "emacs.d" -S "config/*" -S "lib"
|
|
||||||
Reference in New Issue
Block a user