2023-04-19 07:20:51 -06:00
|
|
|
{ lib, ... }:
|
2023-02-02 05:35:19 -07:00
|
|
|
let
|
2023-05-23 06:59:57 -06:00
|
|
|
prStatus = builtins.fromJSON (builtins.readFile ../pr_status.json);
|
|
|
|
prIsOpen = pr: overlay:
|
|
|
|
if prStatus."${builtins.toString pr}".status == "open" then
|
|
|
|
overlay
|
|
|
|
else
|
|
|
|
null;
|
|
|
|
|
2023-02-02 05:35:19 -07:00
|
|
|
mkCronScript = name: src: ''
|
|
|
|
. /etc/profile;
|
|
|
|
set -x
|
|
|
|
# autogenreated ${name}
|
|
|
|
${src}
|
|
|
|
'';
|
2023-03-03 07:06:30 -07:00
|
|
|
jobToUserService = job: {
|
|
|
|
name = "${job.name}";
|
|
|
|
value = {
|
|
|
|
script = mkCronScript "${job.name}_script" job.script;
|
|
|
|
inherit (job) startAt path;
|
|
|
|
};
|
|
|
|
};
|
2023-02-02 05:35:19 -07:00
|
|
|
jobToService = job: {
|
|
|
|
name = "${job.name}";
|
|
|
|
value = {
|
|
|
|
script = mkCronScript "${job.name}_script" job.script;
|
|
|
|
inherit (job) startAt path;
|
2023-03-03 07:48:42 -07:00
|
|
|
serviceConfig = { User = "${job.user}"; };
|
2023-02-02 05:35:19 -07:00
|
|
|
};
|
|
|
|
};
|
2023-02-02 05:48:19 -07:00
|
|
|
buildShell = pkgs:
|
|
|
|
pkgs.mkShell {
|
|
|
|
shellHook = ''
|
|
|
|
PS1='\u@\h:\w; '
|
|
|
|
( . ./common.sh; start ) || true;
|
|
|
|
'';
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
deadnix
|
|
|
|
git
|
2023-03-02 06:34:36 -07:00
|
|
|
git-bug
|
2023-05-23 06:59:57 -06:00
|
|
|
jo
|
2023-02-02 05:48:19 -07:00
|
|
|
jq
|
|
|
|
nil
|
|
|
|
nix-diff
|
|
|
|
nix-output-monitor
|
|
|
|
shfmt
|
|
|
|
sops
|
|
|
|
ssh-to-age
|
|
|
|
ssh-to-pgp
|
|
|
|
statix
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-04-19 07:17:08 -06:00
|
|
|
# Set our configurationRevison based on the status of our git repo.
|
|
|
|
# If the repo is dirty, disable autoUpgrade as it means we are
|
|
|
|
# testing something.
|
2023-02-02 05:48:19 -07:00
|
|
|
buildVer = self:
|
|
|
|
let state = self.rev or "DIRTY";
|
|
|
|
in {
|
|
|
|
system.configurationRevision = state;
|
2023-04-19 07:20:51 -06:00
|
|
|
system.autoUpgrade.enable = lib.mkDefault (state != "DIRTY");
|
2023-02-02 05:48:19 -07:00
|
|
|
};
|
2023-02-02 05:35:19 -07:00
|
|
|
|
2023-03-03 07:48:42 -07:00
|
|
|
xinlib = {
|
2023-05-23 06:59:57 -06:00
|
|
|
inherit buildVer mkCronScript jobToUserService jobToService buildShell prStatus prIsOpen;
|
2023-03-03 07:48:42 -07:00
|
|
|
};
|
2023-02-02 05:35:19 -07:00
|
|
|
|
|
|
|
in xinlib
|