2025-03-28 17:26:50 -04:00
{
config ,
lib ,
2026-01-11 16:38:56 -05:00
pkgs ,
2025-03-28 17:26:50 -04:00
. . .
} :
2026-01-11 16:38:56 -05:00
let
patchScriptBin =
{
filename ,
contents ,
path ? [ ] ,
} :
( ( pkgs . writeScriptBin filename contents ) . overrideAttrs ( old : {
buildInputs = [ pkgs . makeWrapper ] ;
buildCommand = " ${ old . buildCommand } \n p a t c h S h e b a n g s $ o u t \n w r a p P r o g r a m $ o u t / b i n / ${ filename } - - p r e f i x P A T H : ${ lib . makeBinPath path } " ;
} ) ) ;
build_odo = (
patchScriptBin {
filename = " b u i l d _ o d o " ;
contents = ( builtins . readFile ./files/build_odo.bash ) ;
path = with pkgs ; [
bash
git
nix
nix-output-monitor
nixos-rebuild
] ;
}
) ;
in
2025-03-28 17:26:50 -04:00
{
imports = [ ] ;
options . me = {
hydra . enable = lib . mkOption {
type = lib . types . bool ;
default = false ;
example = true ;
description = " W h e t h e r w e w a n t t o i n s t a l l h y d r a . " ;
} ;
} ;
2025-10-11 00:08:02 -04:00
config = lib . mkIf config . me . hydra . enable {
2026-01-11 16:38:56 -05:00
environment . systemPackages = with pkgs ; [
build_odo
] ;
environment . persistence . " / p e r s i s t " = lib . mkIf ( config . me . mountPersistence ) {
hideMounts = true ;
users . nixworker = {
directories = [
{
directory = " p e r s i s t " ;
user = " n i x w o r k e r " ;
group = " n i x w o r k e r " ;
mode = " 0 7 0 0 " ;
}
] ;
} ;
} ;
# 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 . " / h o m e / n i x w o r k e r / p e r s i s t / r o o t / n i x / v a r / n i x / b u i l d s " = {
device = " t m p f s " ;
fsType = " t m p f s " ;
options = [
" s i z e = 4 0 G " # adjust for your situation and needs
" m o d e = 7 0 0 "
" u i d = 1 1 4 0 0 "
" g i d = 1 1 4 0 0 "
] ;
2025-10-11 00:08:02 -04:00
} ;
2025-03-28 17:26:50 -04:00
2026-01-11 16:38:56 -05:00
systemd . timers . " b u i l d - c a c h e " = {
wantedBy = [ " t i m e r s . t a r g e t " ] ;
timerConfig = {
OnCalendar = " M o n * - * - * 0 2 : 0 0 : 0 0 A m e r i c a / N e w _ Y o r k " ;
Unit = " b u i l d - c a c h e . s e r v i c e " ;
} ;
} ;
systemd . services . " b u i l d - c a c h e " = {
script = ''
set - euo pipefail
IFS = $ ' \ n \ t'
DIR = " $ ( c d " $ ( dirname " ' ' ${ BASH_SOURCE [ 0 ] } " ) " & & p w d ) "
$ { build_odo } /bin/build_odo
'' ;
restartIfChanged = false ;
serviceConfig = {
Type = " s i m p l e " ;
User = " n i x w o r k e r " ;
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 ;
} ;
} ;
2025-10-11 00:08:02 -04:00
} ;
2025-03-28 17:26:50 -04:00
}