Tarsnap, nix shell tweaks, services

main
mat ess 2022-10-10 17:54:15 -04:00
parent 609291820e
commit cd209ea820
8 changed files with 109 additions and 42 deletions

View File

@ -48,7 +48,7 @@ in
homebrew.masApps = {
Bitwarden = 1352778147;
Spark = 1176895641;
Wireguard = 1451685025;
Tailscale = 1475387142;
Xcode = 497799835;
};
@ -89,7 +89,7 @@ in
# Configuration related to casks
environment.variables.SSH_AUTH_SOCK = mkIfCaskPresent "secretive"
"/Users/${config.users.primaryUser.username}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
"${config.home.homeDirectory}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
# For cli packages that aren't currently available for macOS in `nixpkgs`.Packages should be
# installed in `../home/default.nix` whenever possible.
@ -98,6 +98,7 @@ in
"fileicon"
"fzf"
"gifsicle"
"tarsnap"
"unison-language"
];
}

View File

@ -274,7 +274,10 @@
# configs
configs-starship-symbols = import ./home/configs/starship-symbols.nix;
copyApplications = import ./home/copyApplications.nix;
dark-mode-notify-service = import ./home/dark-mode-notify-service.nix;
# services
dark-mode-notify-service = import ./home/services/dark-mode-notify.nix;
tarsnap-service = import ./home/services/tarsnap.nix;
# etc
files = import ./home/files.nix;
fish = import ./home/fish.nix;
git = import ./home/git.nix;

View File

@ -1,20 +0,0 @@
{ pkgs, ... }: {
# dark-mode-notify configuration
# {{{
launchd.agents.dark-mode-notify = {
enable = true;
config = {
Label = "ke.bou.dark-mode-notify";
KeepAlive = true;
StandardErrorPath = null;
StandardOutPath = null;
ProgramArguments = [
"${pkgs.dark-mode-notify}/bin/dark-mode-notify"
"${pkgs.fish}/bin/fish"
"-c"
"set-background-to-env DARKMODE"
];
};
};
# }}}
}

View File

@ -5,11 +5,21 @@
enable = true;
};
home.file.".pijulconfig".text = ''
[author]
name = "mat"
full_name = "${config.programs.git.userName}"
email = "${config.programs.git.userEmail}"
'';
home.file = {
".pijulconfig".text = ''
[author]
name = "${config.home.primaryUser.username}"
full_name = "${config.home.primaryUser.fullName}"
email = "${config.home.primaryUser.email}"
'';
".tarsnaprc".text = ''
cachedir ${config.xdg.cacheHome}
keyfile ${config.xdg.configHome}/tarsnap/read-write-delete.key
nodump
print-stats
checkpoint-bytes 1G
humanize-numbers
'';
};
# }}}
}

View File

@ -6,9 +6,7 @@
programs.fish.enable = true;
# Add Fish plugins
home.packages = with pkgs.fishPlugins; [
done
];
home.packages = with pkgs.fishPlugins; [ done ];
programs.fish.plugins = [
{
@ -154,7 +152,7 @@
};
darwin-rebuild-edit-with = {
argumentNames = [ "file" "editor" ];
argumentNames = [ "editor" "file" ];
body = ''
if test -z "$file"
set file flake.nix
@ -162,6 +160,13 @@
from-nix $editor $file
'';
};
nix-unfree = {
argumentNames = [ "cmd" ];
body = ''
env NIX_ALLOW_UNFREE=1 nix $cmd --impure
'';
};
};
# }}}
@ -170,11 +175,11 @@
# Aliases
programs.fish.shellAliases =
let
nixConfigDir = "${config.home.homeDirectory}/dotfiles.nix";
inherit (config.home.primaryUser) nixConfigDirectory;
in
with pkgs; {
# Nix related
from-nix = "from-dir ${nixConfigDir}";
from-nix = "from-dir ${nixConfigDirectory}";
# darwin-rebuild build
drb = "from-nix darwin-rebuild build --flake .";
# darwin-rebuild switch full
@ -182,19 +187,22 @@
# darwin-rebuild switch (no homebrew)
drs = "from-nix darwin-rebuild switch --flake . --override-input homebrew-enabled github:boolean-option/false";
# edit darwin-rebuild config in code/codium
drc = "code ${nixConfigDir}";
drc = "code ${nixConfigDirectory}";
# edit darwin-rebuild config in vim
drv = "vim ${nixConfigDir}";
drv = "vim ${nixConfigDirectory}";
# edit darwin-rebuild config in helix
drh = "darwin-rebuild-edit-with hx";
flakeup = "nix flake update ${nixConfigDir}/";
flakeup = "nix flake update ${nixConfigDirectory}/";
nb = "nix build";
nd = "nix develop";
nf = "nix flake";
nr = "nix run";
nru = "nix-unfree run";
ns = "nix search nixpkgs";
nsh = "nix shell";
nrp = "nix repl --expr '{pkgs=(import <nixpkgs> {});}'";
nshu = "nix-unfree shell";
nrp = "nix repl --expr '{ pkgs = (import <nixpkgs> { }); }'";
nrpu = "nix repl --expr '{ pkgs = (import <nixpkgs> { config.allowUnfree = true; }); }' --impure";
# Other
".." = "cd ..";
@ -212,7 +220,7 @@
tb = "toggle-background";
} // lib.optionalAttrs stdenv.isDarwin {
sb = "set-background-to-macOS";
conda-init = "eval /opt/homebrew/Caskroom/miniforge/base/bin/conda 'shell.fish' 'hook' $argv | source";
conda-init = "eval /opt/homebrew/bin/conda 'shell.fish' 'hook' $argv | source";
};
# Configuration that should be above `loginShellInit` and `interactiveShellInit`.

View File

@ -51,8 +51,7 @@
UseKeychain = "yes";
AddKeysToAgent = "yes";
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
# TODO: gate this behind a check if the cask is present
IdentityAgent = "~/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
IdentityAgent = "${config.home.homeDirectory}/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
};
};
# vscode

View File

@ -0,0 +1,22 @@
{ pkgs, ... }: {
# dark-mode-notify configuration
# {{{
launchd.agents.dark-mode-notify =
let logPath = "/var/log/dark-mode-notify"; in
{
enable = true;
config = {
Label = "ke.bou.dark-mode-notify";
KeepAlive = true;
StandardErrorPath = "${logPath}/error.log";
StandardOutPath = "${logPath}/out.log";
ProgramArguments = [
"${pkgs.dark-mode-notify}/bin/dark-mode-notify"
"${pkgs.fish}/bin/fish"
"-c"
"set-background-to-env DARKMODE"
];
};
};
# }}}
}

44
home/services/tarsnap.nix Normal file
View File

@ -0,0 +1,44 @@
{ config, pkgs, ... }: {
# tarsnap periodic backup configuration
# {{{
launchd.agents.tarsnap =
let
logPath = "/var/log/tarsnap";
tarsnapBackup = pkgs.writeShellScriptBin "tarsnap-backup-helper" ''
/opt/homebrew/bin/tarsnap -v -c \
--configfile ${config.home.homeDirectory}/.tarsnaprc \
-f $(uname -n)-$(date -u +%Y-%m-%dT%H:%M:%SZ) \
${config.home.homeDirectory}/{dotfiles.nix,Desktop,Development,Documents,Downloads}
'';
in
{
enable = true;
config = {
Label = "com.tarsnap.tarsnap";
StandardErrorPath = "${logPath}/error.log";
StandardOutPath = "${logPath}/out.log";
StartCalendarInterval = [
{
# every sunday
Weekday = 0;
# at midnight
Hour = 0;
Minute = 0;
}
{
# every wednesday
Weekday = 3;
# at noon
Hour = 12;
Minute = 0;
}
];
Program = "${tarsnapBackup}/bin/tarsnap-backup-helper";
};
};
# }}}
}