mirror of
https://github.com/Misterio77/Foundry.git
synced 2026-08-24 10:04:09 -05:00
home: add a timer to fetch mic92's nix-index database
This commit is contained in:
@@ -1,7 +1,38 @@
|
||||
{ lib, persistence, ... }: {
|
||||
{ lib, persistence, pkgs, ... }:
|
||||
let update-script = pkgs.writeShellApplication {
|
||||
name = "fetch-nix-index-database";
|
||||
runtimeInputs = with pkgs; [ wget coreutils ];
|
||||
text = ''
|
||||
filename="index-x86_64-linux"
|
||||
mkdir -p ~/.cache/nix-index
|
||||
cd ~/.cache/nix-index
|
||||
wget -N "https://github.com/Mic92/nix-index-database/releases/latest/download/$filename"
|
||||
ln -f "$filename" files
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
programs.nix-index.enable = true;
|
||||
|
||||
home.persistence = lib.mkIf persistence {
|
||||
"/persist/home/misterio".directories = [ ".cache/nix-index" ];
|
||||
};
|
||||
|
||||
systemd.user.services.nix-index-database-sync = {
|
||||
Unit = { Description = "fetch mic92/nix-index-database"; };
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${update-script}/bin/fetch-nix-index-database";
|
||||
Restart = "on-failure";
|
||||
RestartSec = "5m";
|
||||
};
|
||||
};
|
||||
systemd.user.timers.nix-index-database-sync = {
|
||||
Unit = { Description = "Automatic github:mic92/nix-index-database fetching"; };
|
||||
Timer = {
|
||||
OnBootSec = "10m";
|
||||
OnUnitActiveSec = "24h";
|
||||
};
|
||||
Install = { WantedBy = [ "timers.target" ]; };
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user