Skip to content

Commit

Permalink
Include activation functions to setup password store
Browse files Browse the repository at this point in the history
  • Loading branch information
rounakdatta committed Feb 20, 2024
1 parent a12326a commit 237436c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 29 deletions.
14 changes: 7 additions & 7 deletions configs/bash/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ in
initExtra = ''
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export PASSWORD_STORE_DIR=/Users/${config.home.username}/.password-store
'' +
(if isDarwin then
''
export PATH="$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:$PATH"
export PATH="$PATH:/etc/profiles/per-user/${config.home.username}/bin"
export PATH="$PATH:/opt/homebrew/bin"
export PATH="$PATH:/opt/homebrew/opt/node@18/bin"
export JAVA_HOME=/usr/libexec/java_home
export PASSWORD_STORE_DIR="/Users/${config.home.username}/.password-store"
export PATH="$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:$PATH"
export PATH="$PATH:/etc/profiles/per-user/${config.home.username}/bin"
export PATH="$PATH:/opt/homebrew/bin"
export PATH="$PATH:/opt/homebrew/opt/node@18/bin"
export JAVA_HOME=/usr/libexec/java_home
# TODO: verify if this is at all needed at all needed
export PASSWORD_STORE_DIR="/Users/${config.home.username}/.password-store"
''
else
''
Expand Down
15 changes: 8 additions & 7 deletions configs/fish/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ in
'' +
(if isDarwin then
''
# this is needed, otherwise darwin-rebuild wouldn't be in PATH
fish_add_path --prepend --global "$HOME/.nix-profile/bin" /nix/var/nix/profiles/default/bin /run/current-system/sw/bin
set PATH $PATH /etc/profiles/per-user/${config.home.username}/bin
set PATH $PATH /opt/homebrew/bin
set PATH $PATH /opt/homebrew/opt/node@18/bin
set JAVA_HOME /usr/libexec/java_home
set PASSWORD_STORE_DIR /Users/${config.home.username}/.password-store
# this is needed, otherwise darwin-rebuild wouldn't be in PATH
fish_add_path --prepend --global "$HOME/.nix-profile/bin" /nix/var/nix/profiles/default/bin /run/current-system/sw/bin
set PATH $PATH /etc/profiles/per-user/${config.home.username}/bin
set PATH $PATH /opt/homebrew/bin
set PATH $PATH /opt/homebrew/opt/node@18/bin
set JAVA_HOME /usr/libexec/java_home
# TODO: verify if this is at all needed at all needed
set PASSWORD_STORE_DIR /Users/${config.home.username}/.password-store
''
else
''
Expand Down
19 changes: 5 additions & 14 deletions configs/gopass/default.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
{ config, pkgs, ... }:
let
isDarwin = pkgs.stdenv.isDarwin;
in
{
{ config, pkgs, ... }: {
home.file.".config/gopass/config".text =
if isDarwin then ''
[mounts]
path = ${config.home.homeDirectory}/.password-store
''
else
''
[mounts]
path = ${config.home.homeDirectory}/.local/share/.password-store
'';
''
[mounts]
path = ${config.home.homeDirectory}/.password-store
'';
}
4 changes: 3 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.rounak = {
imports = [ ./hosts/ninezeroes/home.nix ];
imports = [
./hosts/ninezeroes/home.nix
];
_module.args.self = self;
_module.args.host = "ninezeroes";
_module.args.inputs = inputs;
Expand Down
28 changes: 28 additions & 0 deletions hosts/commons/pass.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{ config, pkgs, ... }: {
home.activation = {
passwordStore = ''
PW_DIR=${config.home.homeDirectory}/.password-store
if [ ! -d "$PW_DIR" ]; then
mkdir -p "$PW_DIR"
fi
cd $PW_DIR
# the following PATH addition is to make sure that binaries like `git`, `emacs`, `ssh` are available for use
export PATH="${config.home.path}/bin:/run/current-system/sw/bin:/etc/profiles/per-user/${config.home.username}/bin:$PATH"
git init
if git remote | grep -q origin; then
git remote set-url origin [email protected]:rounakdatta/pass.git
else
git remote add origin [email protected]:rounakdatta/pass.git
fi
git fetch origin
git pull origin master
gopass-jsonapi configure --browser chrome --global=false --path=${config.home.homeDirectory}/.config/gopass
gopass-jsonapi configure --browser firefox --global=false --path=${config.home.homeDirectory}/.config/gopass
'';
};
}
1 change: 1 addition & 0 deletions hosts/ninezeroes/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

imports = [
../../configs
../commons/pass.nix
];

home = {
Expand Down

0 comments on commit 237436c

Please sign in to comment.