2023-09-12 08:44:05 -06:00
|
|
|
{ lib, ... }:
|
|
|
|
let
|
2023-06-02 13:53:27 -06:00
|
|
|
inherit (builtins) toString readFile fromJSON filter;
|
2023-09-12 08:44:05 -06:00
|
|
|
getPrStatus = pr:
|
|
|
|
let
|
|
|
|
prstr = toString pr;
|
|
|
|
prStatus = fromJSON (readFile ../pull_requests/${prstr}.json);
|
|
|
|
in
|
2023-07-11 09:12:50 -06:00
|
|
|
prStatus;
|
2023-06-01 18:45:02 -06:00
|
|
|
prIsOpen = {
|
2024-04-24 14:29:20 -06:00
|
|
|
str = pr: a:
|
|
|
|
let
|
|
|
|
prStatus = getPrStatus pr;
|
|
|
|
in
|
|
|
|
if prStatus.status == "open"
|
2024-04-25 07:15:38 -06:00
|
|
|
then
|
2024-04-24 14:29:20 -06:00
|
|
|
lib.warn
|
2024-04-25 07:15:38 -06:00
|
|
|
"PR: ${toString pr} (${prStatus.title}) is open.. disabling option"
|
|
|
|
null
|
2024-04-24 14:29:20 -06:00
|
|
|
else a;
|
2023-09-12 08:44:05 -06:00
|
|
|
option = pr: a:
|
|
|
|
let
|
|
|
|
prStatus = getPrStatus pr;
|
|
|
|
in
|
2023-07-11 09:12:50 -06:00
|
|
|
if prStatus.status == "open"
|
|
|
|
then a
|
2023-09-12 08:44:05 -06:00
|
|
|
else { };
|
|
|
|
pkg = pr: localPkg: upstreamPkg:
|
|
|
|
let
|
|
|
|
prStatus = getPrStatus pr;
|
|
|
|
in
|
2023-07-11 09:12:50 -06:00
|
|
|
if prStatus.status == "open"
|
|
|
|
then localPkg
|
2023-06-01 18:45:02 -06:00
|
|
|
else
|
2023-06-02 13:53:27 -06:00
|
|
|
lib.warn
|
2023-09-12 08:44:05 -06:00
|
|
|
"PR: ${toString pr} (${prStatus.title}) is complete, ignoring pkg..."
|
|
|
|
upstreamPkg;
|
2023-06-01 18:45:02 -06:00
|
|
|
|
2023-09-12 08:44:05 -06:00
|
|
|
overlay = pr: overlay:
|
|
|
|
let
|
|
|
|
prStatus = getPrStatus pr;
|
|
|
|
in
|
2023-07-11 09:12:50 -06:00
|
|
|
if pr == 0 || prStatus.status == "open"
|
|
|
|
then overlay
|
2023-06-01 18:45:02 -06:00
|
|
|
else
|
|
|
|
lib.warn "PR: ${
|
2023-06-02 13:53:27 -06:00
|
|
|
toString pr
|
2023-09-12 08:44:05 -06:00
|
|
|
} (${prStatus.title}) is complete, ignoring overlay..."
|
|
|
|
(_: _: { });
|
2023-06-01 18:45:02 -06:00
|
|
|
};
|
2023-05-23 06:59:57 -06:00
|
|
|
|
2023-06-13 07:19:13 -06:00
|
|
|
todo = msg: lib.warn "TODO: ${msg}";
|
|
|
|
|
2023-06-02 13:53:27 -06:00
|
|
|
filterList = pkgList: filter (x: x != null) pkgList;
|
|
|
|
|
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-09-12 08:44:05 -06:00
|
|
|
serviceConfig = { Type = "oneshot"; };
|
2023-03-03 07:06:30 -07:00
|
|
|
};
|
|
|
|
};
|
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-06-16 10:24:22 -06:00
|
|
|
serviceConfig = {
|
|
|
|
User = "${job.user}";
|
2023-06-16 10:27:45 -06:00
|
|
|
Type = "oneshot";
|
2023-06-16 10:24:22 -06:00
|
|
|
};
|
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; '
|
|
|
|
'';
|
|
|
|
nativeBuildInputs = with pkgs; [
|
2023-05-23 12:05:33 -06:00
|
|
|
curl
|
2023-08-29 17:53:40 -06:00
|
|
|
dasel
|
2023-02-02 05:48:19 -07:00
|
|
|
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
|
2023-08-31 05:34:25 -06:00
|
|
|
nix-prefetch-github
|
2023-02-02 05:48:19 -07:00
|
|
|
shfmt
|
|
|
|
sops
|
|
|
|
ssh-to-age
|
|
|
|
ssh-to-pgp
|
|
|
|
statix
|
2024-06-28 09:27:48 -06:00
|
|
|
treefmt2
|
|
|
|
perlPackages.PerlTidy
|
2023-02-02 05:48:19 -07:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
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-09-12 08:44:05 -06:00
|
|
|
buildVer = self:
|
|
|
|
let
|
|
|
|
state = self.rev or "DIRTY";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
system.configurationRevision = state;
|
|
|
|
system.autoUpgrade.enable = lib.mkDefault (state != "DIRTY");
|
|
|
|
};
|
2023-02-02 05:35:19 -07:00
|
|
|
|
2023-03-03 07:48:42 -07:00
|
|
|
xinlib = {
|
2023-07-11 09:12:50 -06:00
|
|
|
inherit
|
|
|
|
buildVer
|
|
|
|
mkCronScript
|
|
|
|
jobToUserService
|
|
|
|
jobToService
|
|
|
|
buildShell
|
|
|
|
prIsOpen
|
|
|
|
filterList
|
|
|
|
todo
|
|
|
|
;
|
2023-03-03 07:48:42 -07:00
|
|
|
};
|
2023-07-11 09:12:50 -06:00
|
|
|
in
|
2023-09-12 08:44:05 -06:00
|
|
|
xinlib
|