mirror of
https://github.com/nmasur/dotfiles
synced 2025-07-05 12:40:13 +00:00
move all files to new nixfmt rfc
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
{ config, lib, ... }: {
|
||||
{ config, lib, ... }:
|
||||
{
|
||||
|
||||
# Shell history sync
|
||||
|
||||
@ -10,7 +11,10 @@
|
||||
|
||||
programs.atuin = {
|
||||
enable = true;
|
||||
flags = [ "--disable-up-arrow" "--disable-ctrl-r" ];
|
||||
flags = [
|
||||
"--disable-up-arrow"
|
||||
"--disable-ctrl-r"
|
||||
];
|
||||
settings = {
|
||||
auto_sync = true;
|
||||
update_check = false;
|
||||
@ -27,13 +31,9 @@
|
||||
keymap_mode = "vim-normal";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
# Give root user the same setup
|
||||
home-manager.users.root.programs.atuin =
|
||||
config.home-manager.users.${config.user}.programs.atuin;
|
||||
|
||||
home-manager.users.root.programs.atuin = config.home-manager.users.${config.user}.programs.atuin;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,17 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
|
||||
config = {
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
programs.bash = {
|
||||
enable = true;
|
||||
shellAliases =
|
||||
config.home-manager.users.${config.user}.programs.fish.shellAliases;
|
||||
shellAliases = config.home-manager.users.${config.user}.programs.fish.shellAliases;
|
||||
initExtra = "";
|
||||
profileExtra = "";
|
||||
};
|
||||
@ -14,7 +19,6 @@
|
||||
programs.starship.enableBashIntegration = false;
|
||||
programs.zoxide.enableBashIntegration = true;
|
||||
programs.fzf.enableBashIntegration = true;
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -1,4 +1,10 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
|
||||
# Convenience utilities from charm.sh
|
||||
|
||||
@ -12,7 +18,5 @@
|
||||
charm # Manage account and filesystem
|
||||
pop # Send emails from a TUI
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
{ ... }: {
|
||||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
./atuin.nix
|
||||
./bash
|
||||
|
@ -1,10 +1,15 @@
|
||||
{ config, ... }: {
|
||||
{ config, ... }:
|
||||
{
|
||||
|
||||
# Enables quickly entering Nix shells when changing directories
|
||||
home-manager.users.${config.user}.programs.direnv = {
|
||||
enable = true;
|
||||
nix-direnv.enable = true;
|
||||
config = { whitelist = { prefix = [ config.dotfilesPath ]; }; };
|
||||
config = {
|
||||
whitelist = {
|
||||
prefix = [ config.dotfilesPath ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# programs.direnv.direnvrcExtra = ''
|
||||
@ -28,5 +33,4 @@
|
||||
keep-outputs = true
|
||||
keep-derivations = true
|
||||
'';
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,10 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
|
||||
users.users.${config.user}.shell = pkgs.fish;
|
||||
programs.fish.enable = true; # Needed for LightDM to remember username
|
||||
@ -46,7 +52,9 @@
|
||||
fish_user_key_bindings = {
|
||||
body = builtins.readFile ./functions/fish_user_key_bindings.fish;
|
||||
};
|
||||
ip = { body = builtins.readFile ./functions/ip.fish; };
|
||||
ip = {
|
||||
body = builtins.readFile ./functions/ip.fish;
|
||||
};
|
||||
json = {
|
||||
description = "Tidy up JSON using jq";
|
||||
body = "pbpaste | jq '.' | pbcopy"; # Need to fix for non-macOS
|
||||
@ -112,8 +120,7 @@
|
||||
moon = "curl wttr.in/Moon";
|
||||
|
||||
# Cheat Sheets
|
||||
ssl =
|
||||
"openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr";
|
||||
ssl = "openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr";
|
||||
fingerprint = "ssh-keyscan myhost.com | ssh-keygen -lf -";
|
||||
publickey = "ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub";
|
||||
forloop = "for i in (seq 1 100)";
|
||||
@ -122,7 +129,6 @@
|
||||
dc = "$DOTS/bin/docker_cleanup";
|
||||
dr = "docker run --rm -it";
|
||||
db = "docker build . -t";
|
||||
|
||||
};
|
||||
shellInit = "";
|
||||
};
|
||||
@ -132,6 +138,5 @@
|
||||
programs.starship.enableFishIntegration = true;
|
||||
programs.zoxide.enableFishIntegration = true;
|
||||
programs.fzf.enableFishIntegration = true;
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
{ config, pkgs, ... }: {
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
|
||||
# FZF is a fuzzy-finder for the terminal
|
||||
|
||||
@ -25,17 +26,20 @@
|
||||
'';
|
||||
};
|
||||
};
|
||||
shellAbbrs = { lsf = "ls -lh | fzf"; };
|
||||
shellAbbrs = {
|
||||
lsf = "ls -lh | fzf";
|
||||
};
|
||||
};
|
||||
|
||||
# Global fzf configuration
|
||||
home.sessionVariables = let fzfCommand = "fd --type file";
|
||||
in {
|
||||
FZF_DEFAULT_COMMAND = fzfCommand;
|
||||
FZF_CTRL_T_COMMAND = fzfCommand;
|
||||
FZF_DEFAULT_OPTS = "-m --height 50% --border";
|
||||
};
|
||||
|
||||
home.sessionVariables =
|
||||
let
|
||||
fzfCommand = "fd --type file";
|
||||
in
|
||||
{
|
||||
FZF_DEFAULT_COMMAND = fzfCommand;
|
||||
FZF_CTRL_T_COMMAND = fzfCommand;
|
||||
FZF_DEFAULT_OPTS = "-m --height 50% --border";
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,14 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let home-packages = config.home-manager.users.${config.user}.home.packages;
|
||||
|
||||
in {
|
||||
let
|
||||
home-packages = config.home-manager.users.${config.user}.home.packages;
|
||||
in
|
||||
{
|
||||
|
||||
options = {
|
||||
gitName = lib.mkOption {
|
||||
@ -28,16 +34,26 @@ in {
|
||||
userName = config.gitName;
|
||||
userEmail = config.gitEmail;
|
||||
extraConfig = {
|
||||
core.pager =
|
||||
"${pkgs.git}/share/git/contrib/diff-highlight/diff-highlight | less -F";
|
||||
interactive.difffilter =
|
||||
"${pkgs.git}/share/git/contrib/diff-highlight/diff-highlight";
|
||||
pager = { branch = "false"; };
|
||||
safe = { directory = config.dotfilesPath; };
|
||||
pull = { ff = "only"; };
|
||||
push = { autoSetupRemote = "true"; };
|
||||
init = { defaultBranch = "master"; };
|
||||
rebase = { autosquash = "true"; };
|
||||
core.pager = "${pkgs.git}/share/git/contrib/diff-highlight/diff-highlight | less -F";
|
||||
interactive.difffilter = "${pkgs.git}/share/git/contrib/diff-highlight/diff-highlight";
|
||||
pager = {
|
||||
branch = "false";
|
||||
};
|
||||
safe = {
|
||||
directory = config.dotfilesPath;
|
||||
};
|
||||
pull = {
|
||||
ff = "only";
|
||||
};
|
||||
push = {
|
||||
autoSetupRemote = "true";
|
||||
};
|
||||
init = {
|
||||
defaultBranch = "master";
|
||||
};
|
||||
rebase = {
|
||||
autosquash = "true";
|
||||
};
|
||||
gpg = {
|
||||
format = "ssh";
|
||||
ssh.allowedSignersFile = "~/.config/git/allowed-signers";
|
||||
@ -45,11 +61,16 @@ in {
|
||||
# commit.gpgsign = true;
|
||||
# tag.gpgsign = true;
|
||||
};
|
||||
ignores = [ ".direnv/**" "result" ];
|
||||
includes = [{
|
||||
path = "~/.config/git/personal";
|
||||
condition = "gitdir:~/dev/personal/";
|
||||
}];
|
||||
ignores = [
|
||||
".direnv/**"
|
||||
"result"
|
||||
];
|
||||
includes = [
|
||||
{
|
||||
path = "~/.config/git/personal";
|
||||
condition = "gitdir:~/dev/personal/";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
# Personal git config
|
||||
@ -86,8 +107,7 @@ in {
|
||||
gl = "git log --graph --decorate --oneline -20";
|
||||
gll = "git log --graph --decorate --oneline";
|
||||
gco = "git checkout";
|
||||
gcom = ''
|
||||
git switch (git symbolic-ref refs/remotes/origin/HEAD | cut -d"/" -f4)'';
|
||||
gcom = ''git switch (git symbolic-ref refs/remotes/origin/HEAD | cut -d"/" -f4)'';
|
||||
gcob = "git switch -c";
|
||||
gb = "git branch";
|
||||
gpd = "git push origin -d";
|
||||
@ -101,58 +121,63 @@ in {
|
||||
};
|
||||
|
||||
# Required for fish commands
|
||||
home.packages = with pkgs; [ fish fzf bat ];
|
||||
home.packages = with pkgs; [
|
||||
fish
|
||||
fzf
|
||||
bat
|
||||
];
|
||||
|
||||
programs.fish.functions = lib.mkIf (builtins.elem pkgs.fzf home-packages
|
||||
&& builtins.elem pkgs.bat home-packages) {
|
||||
git = { body = builtins.readFile ./fish/functions/git.fish; };
|
||||
git-add-fuzzy = {
|
||||
body = builtins.readFile ./fish/functions/git-add-fuzzy.fish;
|
||||
programs.fish.functions =
|
||||
lib.mkIf (builtins.elem pkgs.fzf home-packages && builtins.elem pkgs.bat home-packages)
|
||||
{
|
||||
git = {
|
||||
body = builtins.readFile ./fish/functions/git.fish;
|
||||
};
|
||||
git-add-fuzzy = {
|
||||
body = builtins.readFile ./fish/functions/git-add-fuzzy.fish;
|
||||
};
|
||||
git-fuzzy-branch = {
|
||||
argumentNames = "header";
|
||||
body = builtins.readFile ./fish/functions/git-fuzzy-branch.fish;
|
||||
};
|
||||
git-checkout-fuzzy = {
|
||||
body = ''
|
||||
set branch (git-fuzzy-branch "checkout branch...")
|
||||
and git checkout $branch
|
||||
'';
|
||||
};
|
||||
git-delete-fuzzy = {
|
||||
body = ''
|
||||
set branch (git-fuzzy-branch "delete branch...")
|
||||
and git branch -d $branch
|
||||
'';
|
||||
};
|
||||
git-force-delete-fuzzy = {
|
||||
body = ''
|
||||
set branch (git-fuzzy-branch "force delete branch...")
|
||||
and git branch -D $branch
|
||||
'';
|
||||
};
|
||||
git-merge-fuzzy = {
|
||||
body = ''
|
||||
set branch (git-fuzzy-branch "merge from...")
|
||||
and git merge $branch
|
||||
'';
|
||||
};
|
||||
git-show-fuzzy = {
|
||||
body = builtins.readFile ./fish/functions/git-show-fuzzy.fish;
|
||||
};
|
||||
git-commits = {
|
||||
body = builtins.readFile ./fish/functions/git-commits.fish;
|
||||
};
|
||||
git-history = {
|
||||
body = builtins.readFile ./fish/functions/git-history.fish;
|
||||
};
|
||||
uncommitted = {
|
||||
description = "Find uncommitted git repos";
|
||||
body = builtins.readFile ./fish/functions/uncommitted.fish;
|
||||
};
|
||||
};
|
||||
git-fuzzy-branch = {
|
||||
argumentNames = "header";
|
||||
body = builtins.readFile ./fish/functions/git-fuzzy-branch.fish;
|
||||
};
|
||||
git-checkout-fuzzy = {
|
||||
body = ''
|
||||
set branch (git-fuzzy-branch "checkout branch...")
|
||||
and git checkout $branch
|
||||
'';
|
||||
};
|
||||
git-delete-fuzzy = {
|
||||
body = ''
|
||||
set branch (git-fuzzy-branch "delete branch...")
|
||||
and git branch -d $branch
|
||||
'';
|
||||
};
|
||||
git-force-delete-fuzzy = {
|
||||
body = ''
|
||||
set branch (git-fuzzy-branch "force delete branch...")
|
||||
and git branch -D $branch
|
||||
'';
|
||||
};
|
||||
git-merge-fuzzy = {
|
||||
body = ''
|
||||
set branch (git-fuzzy-branch "merge from...")
|
||||
and git merge $branch
|
||||
'';
|
||||
};
|
||||
git-show-fuzzy = {
|
||||
body = builtins.readFile ./fish/functions/git-show-fuzzy.fish;
|
||||
};
|
||||
git-commits = {
|
||||
body = builtins.readFile ./fish/functions/git-commits.fish;
|
||||
};
|
||||
git-history = {
|
||||
body = builtins.readFile ./fish/functions/git-history.fish;
|
||||
};
|
||||
uncommitted = {
|
||||
description = "Find uncommitted git repos";
|
||||
body = builtins.readFile ./fish/functions/uncommitted.fish;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,40 +1,43 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
programs.gh =
|
||||
lib.mkIf config.home-manager.users.${config.user}.programs.git.enable {
|
||||
enable = true;
|
||||
gitCredentialHelper.enable = true;
|
||||
settings.git_protocol = "https";
|
||||
extensions = [ pkgs.gh-collaborators ];
|
||||
programs.gh = lib.mkIf config.home-manager.users.${config.user}.programs.git.enable {
|
||||
enable = true;
|
||||
gitCredentialHelper.enable = true;
|
||||
settings.git_protocol = "https";
|
||||
extensions = [ pkgs.gh-collaborators ];
|
||||
};
|
||||
|
||||
programs.fish = lib.mkIf config.home-manager.users.${config.user}.programs.gh.enable {
|
||||
shellAbbrs = {
|
||||
ghr = "gh repo view -w";
|
||||
gha = "gh run list | head -1 | awk '{ print \\$\\(NF-2\\) }' | xargs gh run view";
|
||||
grw = "gh run watch";
|
||||
grf = "gh run view --log-failed";
|
||||
grl = "gh run view --log";
|
||||
ghpr = "gh pr create && sleep 3 && gh run watch";
|
||||
|
||||
# https://github.com/cli/cli/discussions/4067
|
||||
prs = "gh search prs --state=open --review-requested=@me";
|
||||
};
|
||||
|
||||
programs.fish =
|
||||
lib.mkIf config.home-manager.users.${config.user}.programs.gh.enable {
|
||||
shellAbbrs = {
|
||||
ghr = "gh repo view -w";
|
||||
gha =
|
||||
"gh run list | head -1 | awk '{ print \\$\\(NF-2\\) }' | xargs gh run view";
|
||||
grw = "gh run watch";
|
||||
grf = "gh run view --log-failed";
|
||||
grl = "gh run view --log";
|
||||
ghpr = "gh pr create && sleep 3 && gh run watch";
|
||||
|
||||
# https://github.com/cli/cli/discussions/4067
|
||||
prs = "gh search prs --state=open --review-requested=@me";
|
||||
};
|
||||
functions = {
|
||||
repos = {
|
||||
description = "Clone GitHub repositories";
|
||||
argumentNames = "organization";
|
||||
body = ''
|
||||
set directory (gh-repos $organization)
|
||||
and cd $directory
|
||||
'';
|
||||
};
|
||||
functions = {
|
||||
repos = {
|
||||
description = "Clone GitHub repositories";
|
||||
argumentNames = "organization";
|
||||
body = ''
|
||||
set directory (gh-repos $organization)
|
||||
and cd $directory
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
home.packages = [
|
||||
(pkgs.writeShellScriptBin "gh-repos" ''
|
||||
@ -76,7 +79,5 @@
|
||||
}
|
||||
'')
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
{ config, ... }: {
|
||||
{ config, ... }:
|
||||
{
|
||||
|
||||
config = {
|
||||
|
||||
@ -9,12 +10,9 @@
|
||||
settings = {
|
||||
user = {
|
||||
name = config.home-manager.users.${config.user}.programs.git.userName;
|
||||
email =
|
||||
config.home-manager.users.${config.user}.programs.git.userEmail;
|
||||
email = config.home-manager.users.${config.user}.programs.git.userEmail;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,10 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
programs.fish = {
|
||||
@ -62,22 +68,22 @@
|
||||
|
||||
# Create nix-index if doesn't exist
|
||||
home.activation.createNixIndex =
|
||||
let cacheDir = "${config.homePath}/.cache/nix-index";
|
||||
in lib.mkIf
|
||||
config.home-manager.users.${config.user}.programs.nix-index.enable
|
||||
(config.home-manager.users.${config.user}.lib.dag.entryAfter
|
||||
[ "writeBoundary" ] ''
|
||||
let
|
||||
cacheDir = "${config.homePath}/.cache/nix-index";
|
||||
in
|
||||
lib.mkIf config.home-manager.users.${config.user}.programs.nix-index.enable (
|
||||
config.home-manager.users.${config.user}.lib.dag.entryAfter [ "writeBoundary" ] ''
|
||||
if [ ! -d ${cacheDir} ]; then
|
||||
$DRY_RUN_CMD ${pkgs.nix-index}/bin/nix-index -f ${pkgs.path}
|
||||
fi
|
||||
'');
|
||||
''
|
||||
);
|
||||
|
||||
# Set automatic generation cleanup for home-manager
|
||||
nix.gc = {
|
||||
automatic = config.nix.gc.automatic;
|
||||
options = config.nix.gc.options;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
nix = {
|
||||
@ -92,7 +98,10 @@
|
||||
};
|
||||
|
||||
# For security, only allow specific users
|
||||
settings.allowed-users = [ "@wheel" config.user ];
|
||||
settings.allowed-users = [
|
||||
"@wheel"
|
||||
config.user
|
||||
];
|
||||
|
||||
# Enable features in Nix commands
|
||||
extraOptions = ''
|
||||
@ -110,8 +119,7 @@
|
||||
# Add community Cachix to binary cache
|
||||
# Don't use with macOS because blocked by corporate firewall
|
||||
builders-use-substitutes = true;
|
||||
substituters =
|
||||
lib.mkIf (!pkgs.stdenv.isDarwin) [ "https://nix-community.cachix.org" ];
|
||||
substituters = lib.mkIf (!pkgs.stdenv.isDarwin) [ "https://nix-community.cachix.org" ];
|
||||
trusted-public-keys = lib.mkIf (!pkgs.stdenv.isDarwin) [
|
||||
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
||||
];
|
||||
@ -119,9 +127,6 @@
|
||||
# Scans and hard links identical files in the store
|
||||
# Not working with macOS: https://github.com/NixOS/nix/issues/7273
|
||||
auto-optimise-store = lib.mkIf (!pkgs.stdenv.isDarwin) true;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,10 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
|
||||
home-manager.users.${config.user}.programs.starship = {
|
||||
enable = true;
|
||||
@ -29,7 +35,9 @@
|
||||
truncate_to_repo = true;
|
||||
truncation_length = 100;
|
||||
};
|
||||
git_branch = { format = "[$symbol$branch]($style)"; };
|
||||
git_branch = {
|
||||
format = "[$symbol$branch]($style)";
|
||||
};
|
||||
git_commit = {
|
||||
format = "( @ [$hash]($style) )";
|
||||
only_detached = false;
|
||||
@ -56,8 +64,9 @@
|
||||
format = "[$symbol $name]($style)";
|
||||
symbol = "❄️";
|
||||
};
|
||||
python = { format = "[\${version}\\(\${virtualenv}\\)]($style)"; };
|
||||
python = {
|
||||
format = "[\${version}\\(\${virtualenv}\\)]($style)";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ let
|
||||
.terraform/
|
||||
.target/
|
||||
/Library/'';
|
||||
|
||||
in {
|
||||
in
|
||||
{
|
||||
|
||||
config = {
|
||||
|
||||
@ -70,9 +70,6 @@ in {
|
||||
body = "${pkgs.prettyping}/bin/prettyping --nolegend $target";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,46 +1,52 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
|
||||
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin {
|
||||
|
||||
home.packages = let
|
||||
ldap_scheme = "ldaps";
|
||||
magic_number = "2";
|
||||
magic_end_seq = "corp";
|
||||
magic_prefix = "take";
|
||||
ldap_host =
|
||||
"${magic_prefix}${magic_number}.t${magic_number}.${magic_end_seq}";
|
||||
ldap_port = 636;
|
||||
ldap_dc_1 = "${magic_prefix}${magic_number}";
|
||||
ldap_dc_2 = "t${magic_number}";
|
||||
ldap_dc_3 = magic_end_seq;
|
||||
ldap_script = pkgs.writeShellScriptBin "ldap" ''
|
||||
# if ! [ "$LDAP_HOST" ]; then
|
||||
# echo "No LDAP_HOST specified!"
|
||||
# exit 1
|
||||
# fi
|
||||
SEARCH_FILTER="$@"
|
||||
ldapsearch -LLL \
|
||||
-B -o ldif-wrap=no \
|
||||
-H "${ldap_scheme}://${ldap_host}:${builtins.toString ldap_port}" \
|
||||
-D "${pkgs.lib.toUpper magic_prefix}${magic_number}\\${
|
||||
pkgs.lib.toLower config.user
|
||||
}" \
|
||||
-w "$(${pkgs._1password}/bin/op item get T${magic_number} --fields label=password)" \
|
||||
-b "DC=${ldap_dc_1},DC=${ldap_dc_2},DC=${ldap_dc_3}" \
|
||||
-s "sub" -x "(cn=$SEARCH_FILTER)" \
|
||||
| jq --slurp \
|
||||
--raw-input 'split("\n\n")|map(split("\n")|map(select(.[0:1]!="#" and length>0)) |select(length > 0)|map(capture("^(?<key>[^:]*:?): *(?<value>.*)") |if .key[-1:.key|length] == ":" then .key=.key[0:-1]|.value=(.value|@base64d) else . end)| group_by(.key) | map({key:.[0].key,value:(if .|length > 1 then [.[].value] else .[].value end)}) | from_entries)' | jq -r 'del(.[].thumbnailPhoto)'
|
||||
'';
|
||||
ldapm_script = pkgs.writeShellScriptBin "ldapm" ''
|
||||
${ldap_script}/bin/ldap "$@" | jq '[ .[].memberOf] | add'
|
||||
'';
|
||||
ldapg_script = pkgs.writeShellScriptBin "ldapg" ''
|
||||
${ldap_script}/bin/ldap "$@" | jq '[ .[].member] | add'
|
||||
'';
|
||||
in [ ldap_script ldapm_script ldapg_script ];
|
||||
|
||||
home.packages =
|
||||
let
|
||||
ldap_scheme = "ldaps";
|
||||
magic_number = "2";
|
||||
magic_end_seq = "corp";
|
||||
magic_prefix = "take";
|
||||
ldap_host = "${magic_prefix}${magic_number}.t${magic_number}.${magic_end_seq}";
|
||||
ldap_port = 636;
|
||||
ldap_dc_1 = "${magic_prefix}${magic_number}";
|
||||
ldap_dc_2 = "t${magic_number}";
|
||||
ldap_dc_3 = magic_end_seq;
|
||||
ldap_script = pkgs.writeShellScriptBin "ldap" ''
|
||||
# if ! [ "$LDAP_HOST" ]; then
|
||||
# echo "No LDAP_HOST specified!"
|
||||
# exit 1
|
||||
# fi
|
||||
SEARCH_FILTER="$@"
|
||||
ldapsearch -LLL \
|
||||
-B -o ldif-wrap=no \
|
||||
-H "${ldap_scheme}://${ldap_host}:${builtins.toString ldap_port}" \
|
||||
-D "${pkgs.lib.toUpper magic_prefix}${magic_number}\\${pkgs.lib.toLower config.user}" \
|
||||
-w "$(${pkgs._1password}/bin/op item get T${magic_number} --fields label=password)" \
|
||||
-b "DC=${ldap_dc_1},DC=${ldap_dc_2},DC=${ldap_dc_3}" \
|
||||
-s "sub" -x "(cn=$SEARCH_FILTER)" \
|
||||
| jq --slurp \
|
||||
--raw-input 'split("\n\n")|map(split("\n")|map(select(.[0:1]!="#" and length>0)) |select(length > 0)|map(capture("^(?<key>[^:]*:?): *(?<value>.*)") |if .key[-1:.key|length] == ":" then .key=.key[0:-1]|.value=(.value|@base64d) else . end)| group_by(.key) | map({key:.[0].key,value:(if .|length > 1 then [.[].value] else .[].value end)}) | from_entries)' | jq -r 'del(.[].thumbnailPhoto)'
|
||||
'';
|
||||
ldapm_script = pkgs.writeShellScriptBin "ldapm" ''
|
||||
${ldap_script}/bin/ldap "$@" | jq '[ .[].memberOf] | add'
|
||||
'';
|
||||
ldapg_script = pkgs.writeShellScriptBin "ldapg" ''
|
||||
${ldap_script}/bin/ldap "$@" | jq '[ .[].member] | add'
|
||||
'';
|
||||
in
|
||||
[
|
||||
ldap_script
|
||||
ldapm_script
|
||||
ldapg_script
|
||||
];
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user