From 64a15676ac5b7cb8990d683f19ad78ac9a6bc4ef Mon Sep 17 00:00:00 2001 From: sbh69840 Date: Tue, 9 May 2023 15:57:49 +0530 Subject: support authorized_keys for users --- modules/system/etc.nix | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'modules/system') diff --git a/modules/system/etc.nix b/modules/system/etc.nix index cccb2b0..a27e49e 100644 --- a/modules/system/etc.nix +++ b/modules/system/etc.nix @@ -12,6 +12,7 @@ let hasDir = path: length (splitString "/" path) > 1; etc = filter (f: f.enable) (attrValues config.environment.etc); + etcCopy = filter (f: f.copy) (attrValues config.environment.etc); etcDirs = filter (attr: hasDir attr.target) (attrValues config.environment.etc); in @@ -38,6 +39,7 @@ in cd $out/etc ${concatMapStringsSep "\n" (attr: "mkdir -p $(dirname '${attr.target}')") etc} ${concatMapStringsSep "\n" (attr: "ln -s '${attr.source}' '${attr.target}'") etc} + ${concatMapStringsSep "\n" (attr: "touch '${attr.target}'.copy") etcCopy} ''; system.activationScripts.etc.text = '' @@ -63,7 +65,11 @@ in for h in ''${etcSha256Hashes["$l"]}; do if [ "$o" = "$h" ]; then mv "$l" "$l.orig" - ln -s "$f" "$l" + if [ -e "$f".copy ]; then + cp "$f" "$l" + else + ln -s "$f" "$l" + fi break else h= @@ -77,7 +83,11 @@ in fi fi else - ln -s "$f" "$l" + if [ -e "$f".copy ]; then + cp "$f" "$l" + else + ln -s "$f" "$l" + fi fi done -- cgit v1.2.3 From ccaa942888f53404b56d979cb3a0a5c9f18a1faa Mon Sep 17 00:00:00 2001 From: sbh69840 Date: Wed, 10 May 2023 20:03:21 +0530 Subject: don't check knownSha256 for authorized_keys files --- modules/system/etc.nix | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'modules/system') diff --git a/modules/system/etc.nix b/modules/system/etc.nix index a27e49e..4b45e3a 100644 --- a/modules/system/etc.nix +++ b/modules/system/etc.nix @@ -57,6 +57,10 @@ in if [ ! -e "$d" ]; then mkdir -p "$d" fi + if [ -e "$f".copy ]; then + cp "$f" "$l" + continue + fi if [ -e "$l" ]; then if [ "$(readlink "$l")" != "$f" ]; then if ! grep -q /etc/static "$l"; then @@ -65,11 +69,7 @@ in for h in ''${etcSha256Hashes["$l"]}; do if [ "$o" = "$h" ]; then mv "$l" "$l.orig" - if [ -e "$f".copy ]; then - cp "$f" "$l" - else - ln -s "$f" "$l" - fi + ln -s "$f" "$l" break else h= @@ -83,11 +83,7 @@ in fi fi else - if [ -e "$f".copy ]; then - cp "$f" "$l" - else - ln -s "$f" "$l" - fi + ln -s "$f" "$l" fi done -- cgit v1.2.3