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": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1660167503,
|
"lastModified": 1660196186,
|
||||||
"narHash": "sha256-RAjzibSoilQ7+okrwvez59Ho6Nvf0FJm/F6ZJGjTksg=",
|
"narHash": "sha256-A7GzG9HA7MJs/OQlg5F0jeHCv91PeQVTwjznVgYK2sM=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "ebcea6302e4b221e79656f7a718f5cb55affde2f",
|
"rev": "aaa1c973c8c189195e1b1a702d3b74dbcde91538",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
args@{ pkgs, ... }:
|
args@{ pkgs, config, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
secret = import ../../secret/hosts/Styx.nix;
|
secret = import ../../secret/hosts/Styx.nix;
|
||||||
|
@ -69,4 +69,26 @@ in
|
||||||
programs = {
|
programs = {
|
||||||
zoxide.enable = true;
|
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 mkdir ${cache.rootDir}/.aws 2> /dev/null
|
||||||
sudo cp "$HOME/.aws/credentials" ${cache.rootDir}/.aws/
|
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}")
|
uncachedHashes=$(echo "SELECT DISTINCT hashPart FROM NARs WHERE present = 0 AND timestamp >= $minTimestamp;" | sudo sqlite3 "${cache.database}")
|
||||||
signingKey="$HOME/.config/nifoc-nix/${cache.signingKey}"
|
signingKey="$HOME/.config/nifoc-nix/${cache.signingKey}"
|
||||||
|
|
||||||
|
@ -23,24 +23,31 @@ in
|
||||||
|
|
||||||
if [[ $storePath == *"darwin-system"* ]] ||
|
if [[ $storePath == *"darwin-system"* ]] ||
|
||||||
[[ $storePath == *"nixos-system"* ]] ||
|
[[ $storePath == *"nixos-system"* ]] ||
|
||||||
[[ $storePath == *"home-manager-generation"* ]] ||
|
[[ $storePath == *"home-manager"* ]] ||
|
||||||
[[ $storePath == *"-etc" ]] ||
|
[[ $storePath == *"-etc" ]] ||
|
||||||
[[ $storePath == *"-source" ]] ||
|
[[ $storePath == *"-source" ]] ||
|
||||||
[[ $storePath == *".drv" ]] ||
|
[[ $storePath == *".drv" ]] ||
|
||||||
[[ $storePath == *".drv.chroot" ]] ||
|
[[ $storePath == *".drv.chroot" ]] ||
|
||||||
[[ $storePath == *".check" ]] ||
|
[[ $storePath == *".check" ]] ||
|
||||||
[[ $storePath == *".lock" ]]; then
|
[[ $storePath == *".lock" ]] ||
|
||||||
|
[[ $storePath == *"-*" ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = "--list" ]; then
|
if [ "$1" = "--list" ]; then
|
||||||
echo "$storePath"
|
echo "$storePath"
|
||||||
|
else
|
||||||
|
curl -I --fail --silent "https://cache.nixos.org/$uncachedHash.narinfo" > /dev/null
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Already cached: $storePath ..."
|
||||||
else
|
else
|
||||||
sudo -H nix store sign --key-file $signingKey $storePath
|
sudo -H nix store sign --key-file $signingKey $storePath
|
||||||
|
|
||||||
echo "Uploading $storePath ..."
|
echo "Uploading $storePath ..."
|
||||||
sudo -H nix copy --to '${cache.s3Url}' $storePath
|
sudo -H nix copy --to '${cache.s3Url}' $storePath
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
|
@ -410,13 +410,11 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
home = {
|
home = {
|
||||||
activation = {
|
activation.neovimActivation = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||||
neovimActivation = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
|
||||||
echo -n 'Removing luacache files: '
|
echo -n 'Removing luacache files: '
|
||||||
$DRY_RUN_CMD rm -f $HOME/.cache/nvim/luacache*
|
$DRY_RUN_CMD rm -f $HOME/.cache/nvim/luacache*
|
||||||
echo 'Done'
|
echo 'Done'
|
||||||
'';
|
'';
|
||||||
};
|
|
||||||
|
|
||||||
sessionVariables.EDITOR = "nvim";
|
sessionVariables.EDITOR = "nvim";
|
||||||
|
|
||||||
|
|
|
@ -417,12 +417,12 @@
|
||||||
};
|
};
|
||||||
nvim-ts-autotag = pkgs.vimUtils.buildVimPluginFrom2Nix {
|
nvim-ts-autotag = pkgs.vimUtils.buildVimPluginFrom2Nix {
|
||||||
pname = "nvim-ts-autotag";
|
pname = "nvim-ts-autotag";
|
||||||
version = "2022-04-22";
|
version = "2022-08-11";
|
||||||
src = pkgs.fetchFromGitHub {
|
src = pkgs.fetchFromGitHub {
|
||||||
owner = "windwp";
|
owner = "windwp";
|
||||||
repo = "nvim-ts-autotag";
|
repo = "nvim-ts-autotag";
|
||||||
rev = "044a05c4c51051326900a53ba98fddacd15fea22";
|
rev = "fdefe46c6807441460f11f11a167a2baf8e4534b";
|
||||||
sha256 = "0c94vnhl216p36x19cplhypr1b3z0f7l5jdr19hl79qvdfp9djk2";
|
sha256 = "0cwz18risvkgwr3ppc2vqs6rk94kgra4vmhswn4699fnsmha5lcn";
|
||||||
fetchSubmodules = false;
|
fetchSubmodules = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,10 +26,9 @@ switch $os
|
||||||
sudo nixos-rebuild switch --flake .
|
sudo nixos-rebuild switch --flake .
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if test $status -eq 0
|
||||||
set system_new (readlink /run/current-system)
|
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"
|
if test -e "$HOME/.bin/upload-nifoc-nix-cache"
|
||||||
|
@ -37,4 +36,7 @@ if test -e "$HOME/.bin/upload-nifoc-nix-cache"
|
||||||
upload-nifoc-nix-cache
|
upload-nifoc-nix-cache
|
||||||
end
|
end
|
||||||
|
|
||||||
|
nvd diff "$system_old" "$system_new"
|
||||||
|
end
|
||||||
|
|
||||||
popd
|
popd
|
||||||
|
|
Loading…
Reference in a new issue