Merge branch 'master' of ssh://git.joshuabell.xyz:3032/ringofstorms/dotfiles
This commit is contained in:
commit
3ab3466f57
6 changed files with 212 additions and 6 deletions
|
|
@ -7,9 +7,64 @@
|
|||
let
|
||||
cfg = config.impermanence.tools;
|
||||
|
||||
bcacheImpermanenceBin = pkgs.writeShellScriptBin "bcache-impermanence" (
|
||||
persistence = config.environment.persistence or { };
|
||||
|
||||
normalizePath = v:
|
||||
if builtins.isString v then
|
||||
v
|
||||
else if v ? dirPath then
|
||||
v.dirPath
|
||||
else if v ? filePath then
|
||||
v.filePath
|
||||
else
|
||||
null;
|
||||
|
||||
pathsFromList = f: xs: lib.filter (p: p != null) (map f xs);
|
||||
|
||||
userPersistencePaths = users:
|
||||
lib.flatten (
|
||||
lib.mapAttrsToList (
|
||||
userName: userCfg:
|
||||
let
|
||||
home = (config.users.users.${userName} or { }).home or "/home/${userName}";
|
||||
normalizeUserPath = v:
|
||||
if builtins.isString v then
|
||||
if lib.hasPrefix "/" v then v else "${home}/${v}"
|
||||
else
|
||||
normalizePath v;
|
||||
in
|
||||
(pathsFromList normalizeUserPath (userCfg.directories or [ ]))
|
||||
++ (pathsFromList normalizeUserPath (userCfg.files or [ ]))
|
||||
) users
|
||||
);
|
||||
|
||||
ignorePaths =
|
||||
lib.unique (
|
||||
lib.filter (p: p != null && p != "" && p != "/") (
|
||||
lib.flatten (
|
||||
lib.mapAttrsToList (
|
||||
persistRoot: persistCfg:
|
||||
[ persistRoot ]
|
||||
++ (pathsFromList normalizePath (persistCfg.directories or [ ]))
|
||||
++ (pathsFromList normalizePath (persistCfg.files or [ ]))
|
||||
++ (userPersistencePaths (persistCfg.users or { }))
|
||||
) persistence
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
ignoreFile = pkgs.writeText "bcache-impermanence-ignore-paths" (
|
||||
lib.concatStringsSep "\n" ignorePaths + "\n"
|
||||
);
|
||||
|
||||
scriptFile = pkgs.writeText "bcache-impermanence.sh" (
|
||||
builtins.readFile ./impermanence-tools.sh
|
||||
);
|
||||
|
||||
bcacheImpermanenceBin = pkgs.writeShellScriptBin "bcache-impermanence" ''
|
||||
export BCACHE_IMPERMANENCE_IGNORE_FILE="${ignoreFile}"
|
||||
exec ${pkgs.bash}/bin/bash "${scriptFile}" "$@"
|
||||
'';
|
||||
in
|
||||
{
|
||||
options.impermanence.tools = {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ KEEP_RECENT_WEEKS=4
|
|||
KEEP_RECENT_COUNT=5
|
||||
DRY_RUN=0
|
||||
DIFF_MAX_DEPTH=0
|
||||
IGNORE_FILE="${BCACHE_IMPERMANENCE_IGNORE_FILE-}"
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
|
|
@ -466,6 +467,13 @@ cmd_diff() {
|
|||
local persist_mounts
|
||||
persist_mounts=$(awk '$2 ~ "^/persist(/|$)" { print $2 }' /proc/self/mounts || true)
|
||||
|
||||
# Optional ignore list file generated from `environment.persistence`.
|
||||
local ignore_list
|
||||
ignore_list=""
|
||||
if [ -n "$IGNORE_FILE" ] && [ -f "$IGNORE_FILE" ]; then
|
||||
ignore_list=$(grep -vE '^[[:space:]]*($|#)' "$IGNORE_FILE" | sed 's/[[:space:]]*$//' || true)
|
||||
fi
|
||||
|
||||
is_persist_backed() {
|
||||
local p
|
||||
p="$1"
|
||||
|
|
@ -484,6 +492,34 @@ cmd_diff() {
|
|||
return 1
|
||||
}
|
||||
|
||||
is_ignored_path() {
|
||||
local p
|
||||
p="$1"
|
||||
|
||||
if [ -z "$p" ] || [ "$p" = "/" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "$ignore_list" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local ign
|
||||
while read -r ign; do
|
||||
[ -n "$ign" ] || continue
|
||||
case "$ign" in
|
||||
/*) : ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
|
||||
case "$p" in
|
||||
"$ign"|"$ign"/*) return 0 ;;
|
||||
esac
|
||||
done <<<"$ignore_list"
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
local prefixes
|
||||
prefixes=("$@")
|
||||
|
||||
|
|
@ -504,6 +540,11 @@ cmd_diff() {
|
|||
continue
|
||||
fi
|
||||
|
||||
# Skip prefixes explicitly persisted via `environment.persistence`.
|
||||
if is_ignored_path "$prefix"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
local rel
|
||||
rel="${prefix#/}"
|
||||
[ -z "$rel" ] && rel="."
|
||||
|
|
@ -550,6 +591,11 @@ cmd_diff() {
|
|||
continue
|
||||
fi
|
||||
|
||||
# Skip paths explicitly persisted via `environment.persistence`.
|
||||
if is_ignored_path "$b_path"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
local status
|
||||
if [ ! -e "$a_path" ] && [ -e "$b_path" ]; then
|
||||
status="added"
|
||||
|
|
|
|||
8
hosts/juni/flake.lock
generated
8
hosts/juni/flake.lock
generated
|
|
@ -39,11 +39,11 @@
|
|||
"common": {
|
||||
"locked": {
|
||||
"dir": "flakes/common",
|
||||
"lastModified": 1767575724,
|
||||
"narHash": "sha256-L+3hoO4t3RCXkp9RXyXpJlCkzj6AdTOsstUv7RphEBM=",
|
||||
"lastModified": 1767678258,
|
||||
"narHash": "sha256-UIbi/8BEJnasj3yVK+I4Y2Gqxq7Li86rb8iuzWrNfco=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "f86b8085c2ad39986c194b28d51260f8f402572a",
|
||||
"revCount": 1041,
|
||||
"rev": "d04f85587471ab83afeb18bc94e7e01dcfc3135b",
|
||||
"revCount": 1062,
|
||||
"type": "git",
|
||||
"url": "https://git.joshuabell.xyz/ringofstorms/dotfiles"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -7,9 +7,64 @@
|
|||
let
|
||||
cfg = config.impermanence.tools;
|
||||
|
||||
bcacheImpermanenceBin = pkgs.writeShellScriptBin "bcache-impermanence" (
|
||||
persistence = config.environment.persistence or { };
|
||||
|
||||
normalizePath = v:
|
||||
if builtins.isString v then
|
||||
v
|
||||
else if v ? dirPath then
|
||||
v.dirPath
|
||||
else if v ? filePath then
|
||||
v.filePath
|
||||
else
|
||||
null;
|
||||
|
||||
pathsFromList = f: xs: lib.filter (p: p != null) (map f xs);
|
||||
|
||||
userPersistencePaths = users:
|
||||
lib.flatten (
|
||||
lib.mapAttrsToList (
|
||||
userName: userCfg:
|
||||
let
|
||||
home = (config.users.users.${userName} or { }).home or "/home/${userName}";
|
||||
normalizeUserPath = v:
|
||||
if builtins.isString v then
|
||||
if lib.hasPrefix "/" v then v else "${home}/${v}"
|
||||
else
|
||||
normalizePath v;
|
||||
in
|
||||
(pathsFromList normalizeUserPath (userCfg.directories or [ ]))
|
||||
++ (pathsFromList normalizeUserPath (userCfg.files or [ ]))
|
||||
) users
|
||||
);
|
||||
|
||||
ignorePaths =
|
||||
lib.unique (
|
||||
lib.filter (p: p != null && p != "" && p != "/") (
|
||||
lib.flatten (
|
||||
lib.mapAttrsToList (
|
||||
persistRoot: persistCfg:
|
||||
[ persistRoot ]
|
||||
++ (pathsFromList normalizePath (persistCfg.directories or [ ]))
|
||||
++ (pathsFromList normalizePath (persistCfg.files or [ ]))
|
||||
++ (userPersistencePaths (persistCfg.users or { }))
|
||||
) persistence
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
ignoreFile = pkgs.writeText "bcache-impermanence-ignore-paths" (
|
||||
lib.concatStringsSep "\n" ignorePaths + "\n"
|
||||
);
|
||||
|
||||
scriptFile = pkgs.writeText "bcache-impermanence.sh" (
|
||||
builtins.readFile ./impermanence-tools.sh
|
||||
);
|
||||
|
||||
bcacheImpermanenceBin = pkgs.writeShellScriptBin "bcache-impermanence" ''
|
||||
export BCACHE_IMPERMANENCE_IGNORE_FILE="${ignoreFile}"
|
||||
exec ${pkgs.bash}/bin/bash "${scriptFile}" "$@"
|
||||
'';
|
||||
in
|
||||
{
|
||||
options.impermanence.tools = {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ KEEP_RECENT_WEEKS=4
|
|||
KEEP_RECENT_COUNT=5
|
||||
DRY_RUN=0
|
||||
DIFF_MAX_DEPTH=0
|
||||
IGNORE_FILE="${BCACHE_IMPERMANENCE_IGNORE_FILE-}"
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
|
|
@ -466,6 +467,13 @@ cmd_diff() {
|
|||
local persist_mounts
|
||||
persist_mounts=$(awk '$2 ~ "^/persist(/|$)" { print $2 }' /proc/self/mounts || true)
|
||||
|
||||
# Optional ignore list file generated from `environment.persistence`.
|
||||
local ignore_list
|
||||
ignore_list=""
|
||||
if [ -n "$IGNORE_FILE" ] && [ -f "$IGNORE_FILE" ]; then
|
||||
ignore_list=$(grep -vE '^[[:space:]]*($|#)' "$IGNORE_FILE" | sed 's/[[:space:]]*$//' || true)
|
||||
fi
|
||||
|
||||
is_persist_backed() {
|
||||
local p
|
||||
p="$1"
|
||||
|
|
@ -484,6 +492,34 @@ cmd_diff() {
|
|||
return 1
|
||||
}
|
||||
|
||||
is_ignored_path() {
|
||||
local p
|
||||
p="$1"
|
||||
|
||||
if [ -z "$p" ] || [ "$p" = "/" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "$ignore_list" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local ign
|
||||
while read -r ign; do
|
||||
[ -n "$ign" ] || continue
|
||||
case "$ign" in
|
||||
/*) : ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
|
||||
case "$p" in
|
||||
"$ign"|"$ign"/*) return 0 ;;
|
||||
esac
|
||||
done <<<"$ignore_list"
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
local prefixes
|
||||
prefixes=("$@")
|
||||
|
||||
|
|
@ -504,6 +540,11 @@ cmd_diff() {
|
|||
continue
|
||||
fi
|
||||
|
||||
# Skip prefixes explicitly persisted via `environment.persistence`.
|
||||
if is_ignored_path "$prefix"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
local rel
|
||||
rel="${prefix#/}"
|
||||
[ -z "$rel" ] && rel="."
|
||||
|
|
@ -550,6 +591,11 @@ cmd_diff() {
|
|||
continue
|
||||
fi
|
||||
|
||||
# Skip paths explicitly persisted via `environment.persistence`.
|
||||
if is_ignored_path "$b_path"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
local status
|
||||
if [ ! -e "$a_path" ] && [ -e "$b_path" ]; then
|
||||
status="added"
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@
|
|||
"/var/lib/NetworkManager"
|
||||
"/var/lib/iwd"
|
||||
"/var/lib/fail2ban"
|
||||
|
||||
"/var/lib/tailscale"
|
||||
|
||||
"/var/lib/upower"
|
||||
];
|
||||
files = [
|
||||
"/machine-key.json"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue