S3 caching improvements
This commit is contained in:
parent
c2c2236733
commit
78192c1cce
6 changed files with 55 additions and 26 deletions
|
@ -160,11 +160,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1660167503,
|
||||
"narHash": "sha256-RAjzibSoilQ7+okrwvez59Ho6Nvf0FJm/F6ZJGjTksg=",
|
||||
"lastModified": 1660196186,
|
||||
"narHash": "sha256-A7GzG9HA7MJs/OQlg5F0jeHCv91PeQVTwjznVgYK2sM=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ebcea6302e4b221e79656f7a718f5cb55affde2f",
|
||||
"rev": "aaa1c973c8c189195e1b1a702d3b74dbcde91538",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
args@{ pkgs, ... }:
|
||||
args@{ pkgs, config, lib, ... }:
|
||||
|
||||
let
|
||||
secret = import ../../secret/hosts/Styx.nix;
|
||||
|
@ -69,4 +69,26 @@ in
|
|||
programs = {
|
||||
zoxide.enable = true;
|
||||
};
|
||||
|
||||
# Source: https://github.com/nix-community/home-manager/issues/1341#issuecomment-1190875080
|
||||
home.activation.copyApplications =
|
||||
let
|
||||
apps = pkgs.buildEnv {
|
||||
name = "home-manager-applications";
|
||||
paths = config.home.packages;
|
||||
pathsToLink = "/Applications";
|
||||
};
|
||||
in
|
||||
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
baseDir="$HOME/Applications/Home Manager Apps"
|
||||
if [ -d "$baseDir" ]; then
|
||||
rm -rf "$baseDir"
|
||||
fi
|
||||
mkdir -p "$baseDir"
|
||||
for appFile in ${apps}/Applications/*; do
|
||||
target="$baseDir/$(basename "$appFile")"
|
||||
$DRY_RUN_CMD cp ''${VERBOSE_ARG:+-v} -fHRL "$appFile" "$baseDir"
|
||||
$DRY_RUN_CMD chmod ''${VERBOSE_ARG:+-v} -R +w "$target"
|
||||
done
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ in
|
|||
sudo mkdir ${cache.rootDir}/.aws 2> /dev/null
|
||||
sudo cp "$HOME/.aws/credentials" ${cache.rootDir}/.aws/
|
||||
|
||||
minTimestamp=$(expr $(date +%s) - 3600)
|
||||
minTimestamp=$(expr $(date +%s) - 1800)
|
||||
uncachedHashes=$(echo "SELECT DISTINCT hashPart FROM NARs WHERE present = 0 AND timestamp >= $minTimestamp;" | sudo sqlite3 "${cache.database}")
|
||||
signingKey="$HOME/.config/nifoc-nix/${cache.signingKey}"
|
||||
|
||||
|
@ -23,23 +23,30 @@ in
|
|||
|
||||
if [[ $storePath == *"darwin-system"* ]] ||
|
||||
[[ $storePath == *"nixos-system"* ]] ||
|
||||
[[ $storePath == *"home-manager-generation"* ]] ||
|
||||
[[ $storePath == *"home-manager"* ]] ||
|
||||
[[ $storePath == *"-etc" ]] ||
|
||||
[[ $storePath == *"-source" ]] ||
|
||||
[[ $storePath == *".drv" ]] ||
|
||||
[[ $storePath == *".drv.chroot" ]] ||
|
||||
[[ $storePath == *".check" ]] ||
|
||||
[[ $storePath == *".lock" ]]; then
|
||||
[[ $storePath == *".lock" ]] ||
|
||||
[[ $storePath == *"-*" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$1" = "--list" ]; then
|
||||
echo "$storePath"
|
||||
else
|
||||
sudo -H nix store sign --key-file $signingKey $storePath
|
||||
curl -I --fail --silent "https://cache.nixos.org/$uncachedHash.narinfo" > /dev/null
|
||||
|
||||
echo "Uploading $storePath ..."
|
||||
sudo -H nix copy --to '${cache.s3Url}' $storePath
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Already cached: $storePath ..."
|
||||
else
|
||||
sudo -H nix store sign --key-file $signingKey $storePath
|
||||
|
||||
echo "Uploading $storePath ..."
|
||||
sudo -H nix copy --to '${cache.s3Url}' $storePath
|
||||
fi
|
||||
fi
|
||||
done
|
||||
'';
|
||||
|
|
|
@ -410,13 +410,11 @@ in
|
|||
};
|
||||
|
||||
home = {
|
||||
activation = {
|
||||
neovimActivation = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
echo -n 'Removing luacache files: '
|
||||
$DRY_RUN_CMD rm -f $HOME/.cache/nvim/luacache*
|
||||
echo 'Done'
|
||||
'';
|
||||
};
|
||||
activation.neovimActivation = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
echo -n 'Removing luacache files: '
|
||||
$DRY_RUN_CMD rm -f $HOME/.cache/nvim/luacache*
|
||||
echo 'Done'
|
||||
'';
|
||||
|
||||
sessionVariables.EDITOR = "nvim";
|
||||
|
||||
|
|
|
@ -417,12 +417,12 @@
|
|||
};
|
||||
nvim-ts-autotag = pkgs.vimUtils.buildVimPluginFrom2Nix {
|
||||
pname = "nvim-ts-autotag";
|
||||
version = "2022-04-22";
|
||||
version = "2022-08-11";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "windwp";
|
||||
repo = "nvim-ts-autotag";
|
||||
rev = "044a05c4c51051326900a53ba98fddacd15fea22";
|
||||
sha256 = "0c94vnhl216p36x19cplhypr1b3z0f7l5jdr19hl79qvdfp9djk2";
|
||||
rev = "fdefe46c6807441460f11f11a167a2baf8e4534b";
|
||||
sha256 = "0cwz18risvkgwr3ppc2vqs6rk94kgra4vmhswn4699fnsmha5lcn";
|
||||
fetchSubmodules = false;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -26,15 +26,17 @@ switch $os
|
|||
sudo nixos-rebuild switch --flake .
|
||||
end
|
||||
|
||||
set system_new (readlink /run/current-system)
|
||||
if test $status -eq 0
|
||||
set system_new (readlink /run/current-system)
|
||||
|
||||
nvd diff "$system_old" "$system_new"
|
||||
rm -f result
|
||||
|
||||
rm -f result
|
||||
if test -e "$HOME/.bin/upload-nifoc-nix-cache"
|
||||
echo "Updating nifoc-nix-cache ..."
|
||||
upload-nifoc-nix-cache
|
||||
end
|
||||
|
||||
if test -e "$HOME/.bin/upload-nifoc-nix-cache"
|
||||
echo "Updating nifoc-nix-cache ..."
|
||||
upload-nifoc-nix-cache
|
||||
nvd diff "$system_old" "$system_new"
|
||||
end
|
||||
|
||||
popd
|
||||
|
|
Loading…
Reference in a new issue