about summary refs log tree commit diff
path: root/modules/common/profiles
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2023-04-07 19:35:15 +0300
committerAzat Bahawi <azat@bahawi.net>2023-04-07 19:35:15 +0300
commitdae3149a93cab4d1140526e15eb928d275f56128 (patch)
tree2b567413cd9f6882c616fee5aba7392281ac95fa /modules/common/profiles
parent2023-04-04 (diff)
2023-04-07
Diffstat (limited to '')
-rw-r--r--modules/common/profiles/email.nix22
1 files changed, 19 insertions, 3 deletions
diff --git a/modules/common/profiles/email.nix b/modules/common/profiles/email.nix
index e289c2e..9cc12d7 100644
--- a/modules/common/profiles/email.nix
+++ b/modules/common/profiles/email.nix
@@ -39,7 +39,18 @@ in {
               attrs
             ];
 
-          pass = path: "${config.hm.programs.password-store.package}/bin/pass show ${path}";
+          getPassword = {
+            path,
+            line ? 0,
+          }:
+            assert (builtins.isInt line);
+              concatStringsSep " " (
+                [
+                  "${config.hm.programs.password-store.package}/bin/pass show ${path}"
+                ]
+                ++ optional (line > 0)
+                "| ${pkgs.gnused}/bin/sed -e '${toString line}!d'"
+              );
         in rec {
           shire = mkAccount rec {
             address = my.email;
@@ -64,7 +75,9 @@ in {
               tls.enable = true;
             };
             userName = "azahi@shire.net";
-            passwordCommand = pass "email/shire.net/azahi";
+            passwordCommand = getPassword {
+              path = "email/shire.net/azahi";
+            };
           };
 
           yahoo = mkAccount rec {
@@ -74,7 +87,10 @@ in {
 
             flavor = "yahoo.com";
             userName = "admin@yahoo.com";
-            passwordCommand = pass "email/yahoo.com/admin";
+            passwordCommand = getPassword {
+              path = "email/yahoo.com/admin";
+              line = 2;
+            };
           };
         };
       };

Consider giving Nix/NixOS a try! <3