Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include activation functions to setup password store #16

Merged
merged 4 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions configs/bash/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ 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
export PASSWORD_STORE_DIR="/Users/${config.home.username}/.password-store"
''
else
''
Expand Down
14 changes: 7 additions & 7 deletions configs/fish/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ 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
set PASSWORD_STORE_DIR /Users/${config.home.username}/.password-store
''
else
''
Expand Down
15 changes: 3 additions & 12 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
'';
'';
}
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
2 changes: 1 addition & 1 deletion hosts/ckmac/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ inputs, config, pkgs, ... }:
{ inputs, config, pkgs, lib, ... }:

{
nix.settings = {
Expand Down
1 change: 1 addition & 0 deletions hosts/ckmac/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
30 changes: 30 additions & 0 deletions hosts/commons/pass.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{ 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"
# `ssh` is on the following path in darwin, so there we go
export PATH="/usr/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
Loading