infra/build01/nixpkgs-update.nix

98 lines
3.2 KiB
Nix
Raw Normal View History

{ pkgs, lib, config, ... }:
let
userLib = import ../users/lib.nix { inherit lib; };
sources = import ../nix/sources.nix;
nixpkgs-update = (import sources.nixpkgs-update {}).overrideAttrs(old: {
patches = old.patches or [] ++ [
./nixpkgs-update-disable-post-build-hook.patch
];
});
nixpkgsUpdateSystemDependencies = with pkgs; [
2020-03-29 23:59:38 -07:00
gnugrep
cachix
2020-02-05 20:33:57 -08:00
curl
] ++ [ nixpkgs-update ] ++ nixpkgs-update.propagatedBuildInputs;
2020-01-25 15:05:09 -08:00
nixpkgs-update-github-releases = "${sources.nixpkgs-update-github-releases}/main.py";
2020-03-29 23:59:38 -07:00
nixpkgs-update-pypi-releases = "${sources.nixpkgs-update-pypi-releases}/main.py";
2020-01-25 15:05:09 -08:00
nixpkgsUpdateServiceConfigCommon = {
Type = "oneshot";
User = "r-ryantm";
Group = "r-ryantm";
WorkingDirectory = "/var/lib/nixpkgs-update";
StateDirectory = "nixpkgs-update";
StateDirectoryMode = "700";
CacheDirectory = "nixpkgs-update";
CacheDirectoryMode = "700";
LogsDirectory = "nixpkgs-update";
2020-03-21 19:05:01 -07:00
LogsDirectoryMode = "755";
2020-01-22 12:37:13 +01:00
StandardOutput = "journal";
};
2020-01-22 12:37:13 +01:00
in
{
users.users.r-ryantm.packages = [ pkgs.cachix ];
2020-01-22 12:37:13 +01:00
users.groups.r-ryantm = {};
users.users.r-ryantm = {
useDefaultShell = true;
isNormalUser = true; # The hub cli seems to really want stuff to be set up like a normal user
uid = userLib.mkUid "rrtm";
extraGroups = [ "r-ryantm" ];
};
nix.trustedUsers = [
"r-ryantm"
];
systemd.services.nixpkgs-update = {
description = "nixpkgs-update service";
enable = true;
restartIfChanged = false;
path = nixpkgsUpdateSystemDependencies;
environment.XDG_CONFIG_HOME = "/var/lib/nixpkgs-update";
environment.XDG_CACHE_HOME = "/var/cache/nixpkgs-update";
2020-01-25 15:05:09 -08:00
# API_TOKEN is used by nixpkgs-update-github-releases
environment.API_TOKEN_FILE = "/var/lib/nixpkgs-update/github_token_with_username.txt";
# Used by nixpkgs-update-github-releases to install python dependencies
# Used by nixpkgs-update-pypi-releases
environment.NIX_PATH = "nixpkgs=/var/cache/nixpkgs-update/nixpkgs";
serviceConfig = nixpkgsUpdateServiceConfigCommon;
2020-03-29 23:59:38 -07:00
script = ''
2020-07-03 15:24:05 -07:00
nixpkgs-update delete-done --delete
2020-04-16 13:04:50 -07:00
grep -rl $XDG_CACHE_HOME/nixpkgs -e buildPython | grep default | \
${nixpkgs-update-pypi-releases} > /var/lib/nixpkgs-update/packages-to-update.txt
nixpkgs-update update-list --pr --cve --cachix --outpaths --nixpkgs-review
2020-07-03 15:24:05 -07:00
nixpkgs-update delete-done --delete
${nixpkgs-update-github-releases} > /var/lib/nixpkgs-update/packages-to-update.txt
nixpkgs-update update-list --pr --cve --cachix --outpaths --nixpkgs-review
2020-07-03 15:24:05 -07:00
nixpkgs-update delete-done --delete
2020-03-29 23:59:38 -07:00
nixpkgs-update fetch-repology > /var/lib/nixpkgs-update/packages-to-update.txt
nixpkgs-update update-list --pr --cve --cachix --outpaths --nixpkgs-review
'';
};
systemd.timers.nixpkgs-update = {
description = "nixpkgs-update";
enable = true;
timerConfig = { OnCalendar = "daily"; };
wantedBy = [ "timers.target" ];
};
2020-03-21 19:05:01 -07:00
services.nginx.virtualHosts."r.ryantm.com" = {
forceSSL = true;
enableACME = true;
locations."/log/" = {
alias = "/var/log/nixpkgs-update/";
2020-07-03 20:26:52 -07:00
extraConfig = ''
charset utf-8;
autoindex on;
'';
2020-03-21 19:05:01 -07:00
};
};
}