xin/lib/default.nix

46 lines
902 B
Nix
Raw Normal View History

2023-02-02 05:35:19 -07:00
let
mkCronScript = name: src: ''
. /etc/profile;
set -x
# autogenreated ${name}
${src}
'';
jobToService = job: {
name = "${job.name}";
value = {
script = mkCronScript "${job.name}_script" job.script;
inherit (job) startAt path;
};
};
buildShell = pkgs:
pkgs.mkShell {
shellHook = ''
PS1='\u@\h:\w; '
( . ./common.sh; start ) || true;
'';
nativeBuildInputs = with pkgs; [
deadnix
git
jq
nil
nix-diff
nix-output-monitor
shfmt
sops
ssh-to-age
ssh-to-pgp
statix
];
};
buildVer = self:
let state = self.rev or "DIRTY";
in {
system.configurationRevision = state;
system.autoUpgrade.enable = state != "DIRTY";
};
2023-02-02 05:35:19 -07:00
xinlib = { inherit buildVer mkCronScript jobToService buildShell; };
2023-02-02 05:35:19 -07:00
in xinlib