102 lines
2.5 KiB
Nix
102 lines
2.5 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
let
|
|
patchScriptBin =
|
|
{
|
|
filename,
|
|
contents,
|
|
path ? [ ],
|
|
}:
|
|
((pkgs.writeScriptBin filename contents).overrideAttrs (old: {
|
|
buildInputs = [ pkgs.makeWrapper ];
|
|
buildCommand = "${old.buildCommand}\n patchShebangs $out\nwrapProgram $out/bin/${filename} --prefix PATH : ${lib.makeBinPath path}";
|
|
}));
|
|
build_odo = (
|
|
patchScriptBin {
|
|
filename = "build_odo";
|
|
contents = (builtins.readFile ./files/build_odo.bash);
|
|
path = with pkgs; [
|
|
bash
|
|
git
|
|
nix
|
|
nix-output-monitor
|
|
nixos-rebuild
|
|
];
|
|
}
|
|
);
|
|
in
|
|
{
|
|
imports = [ ];
|
|
|
|
options.me = {
|
|
hydra.enable = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
example = true;
|
|
description = "Whether we want to install hydra.";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf config.me.hydra.enable {
|
|
environment.systemPackages = with pkgs; [
|
|
build_odo
|
|
];
|
|
|
|
environment.persistence."/persist" = lib.mkIf (config.me.mountPersistence) {
|
|
hideMounts = true;
|
|
users.nixworker = {
|
|
directories = [
|
|
{
|
|
directory = "persist";
|
|
user = "nixworker";
|
|
group = "nixworker";
|
|
mode = "0700";
|
|
}
|
|
];
|
|
};
|
|
};
|
|
|
|
# Nix 2.30.0 (2025-07-07) changed the build directory from /tmp to /nix/var/nix/builds which broke a number of builds because my ZFS datasets were utf8only.
|
|
fileSystems."/home/nixworker/persist/root/nix/var/nix/builds" = {
|
|
device = "tmpfs";
|
|
fsType = "tmpfs";
|
|
options = [
|
|
"size=40G" # adjust for your situation and needs
|
|
"mode=700"
|
|
"uid=11400"
|
|
"gid=11400"
|
|
];
|
|
};
|
|
|
|
systemd.timers."build-cache" = {
|
|
wantedBy = [ "timers.target" ];
|
|
timerConfig = {
|
|
OnCalendar = "Mon *-*-* 02:00:00 America/New_York";
|
|
Unit = "build-cache.service";
|
|
};
|
|
};
|
|
|
|
systemd.services."build-cache" = {
|
|
script = ''
|
|
set -euo pipefail
|
|
IFS=$'\n\t'
|
|
DIR="$( cd "$( dirname "''${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
${build_odo}/bin/build_odo
|
|
'';
|
|
restartIfChanged = false;
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
User = "nixworker";
|
|
RemainAfterExit = true; # Prevents the service from automatically starting on rebuild. See https://discourse.nixos.org/t/how-to-prevent-custom-systemd-service-from-restarting-on-nixos-rebuild-switch/43431
|
|
LimitNOFILE = 8192;
|
|
};
|
|
};
|
|
};
|
|
}
|