Skip to content

Commit

Permalink
home/user: use writeShellScriptBin for ssh-perm aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman committed Jan 5, 2025
1 parent 0eac44d commit c77f34e
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions modules/home/user/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,30 @@ in
sha = "shasum -a 256"; # Test checksum
ssh-list-perm-user = # Bash
''find ~/.ssh -exec stat -c "%a %n" {} \;'';
ssh-perm-user = # bash
''
${getExe' pkgs.findutils "find"} ~/.ssh -type f -exec chmod 600 {} \;; ${getExe' pkgs.findutils "find"} ~/.ssh -type d -exec chmod 700 {} \;; ${getExe' pkgs.findutils "find"} ~/.ssh -type f -name "*.pub" -exec chmod 644 {} \;
'';
ssh-perm-user =
let
mainProgram = "ssh-perm-system";
in
lib.getExe' (pkgs.writeShellScriptBin mainProgram # bash
''
${getExe' pkgs.findutils "find"} ~/.ssh -type f -exec chmod 600 {}\;;
${getExe' pkgs.findutils "find"} ~/.ssh -type d -exec chmod 700 {}\;;
${getExe' pkgs.findutils "find"} ~/.ssh -type f -name "*.pub" -exec chmod 644 {}\;;
''
) mainProgram;
ssh-list-perm-system = # Bash
''sudo find /etc/ssh -exec stat -c "%a %n" {} \;'';
ssh-perm-system = # bash
''
sudo ${getExe' pkgs.findutils "find"} /etc/ssh -type f -exec chmod 600 {} \;; sudo ${getExe' pkgs.findutils "find"} /etc/ssh -type d -exec chmod 700 {} \;;sudo ${getExe' pkgs.findutils "find"} /etc/ssh -type f -name "*.pub" -exec chmod 644 {} \;
'';
ssh-perm-system =
let
mainProgram = "ssh-perm-system";
in
lib.getExe' (pkgs.writeShellScriptBin mainProgram # bash
''
sudo ${getExe' pkgs.findutils "find"} /etc/ssh -type f -exec chmod 600 {}\;;
sudo ${getExe' pkgs.findutils "find"} /etc/ssh -type d -exec chmod 700 {}\;;
sudo ${getExe' pkgs.findutils "find"} /etc/ssh -type f -name "*.pub" -exec chmod 644 {}\;;
''
) mainProgram;
};

username = mkDefault cfg.name;
Expand Down

0 comments on commit c77f34e

Please sign in to comment.