Skip to content

Commit

Permalink
Dedupe the WorkingDirectory path of the linux-builder
Browse files Browse the repository at this point in the history
  • Loading branch information
tfc committed Jan 15, 2024
1 parent 0dd382b commit c4ea346
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions modules/nix/linux-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ let
rm -rf $TMPDIR
mkdir -p $TMPDIR
trap "rm -rf $TMPDIR" EXIT
${lib.optionalString cfg.ephemeral ''
rm -f ${cfg.workingDirectory}/${builderWithOverrides.nixosConfig.networking.hostName}.qcow2
''}
${builderWithOverrides}/bin/create-builder
'';
in
Expand Down Expand Up @@ -77,6 +80,22 @@ in
This sets the corresponding `nix.buildMachines.*.supportedFeatures` option.
'';
};

workingDirectory = mkOption {
type = types.str;
default = "/var/lib/darwin-builder";
description = lib.mdDoc ''
The working directory of the Linux builder daemon process.
'';
};

ephemeral = mkEnableOption (lib.mdDoc ''
wipe the builder's filesystem on every restart.
This is disabled by default as maintaining the builder's Nix Store reduces
rebuilds. You can enable this if you don't want your builder to accumulate
state.
'');
};

config = mkIf cfg.enable {
Expand All @@ -89,7 +108,7 @@ in
} ];

system.activationScripts.preActivation.text = ''
mkdir -p /var/lib/darwin-builder
mkdir -p ${cfg.workingDirectory}
'';

launchd.daemons.linux-builder = {
Expand All @@ -103,7 +122,7 @@ in
];
KeepAlive = true;
RunAtLoad = true;
WorkingDirectory = "/var/lib/darwin-builder";
WorkingDirectory = cfg.workingDirectory;
};
};

Expand Down

0 comments on commit c4ea346

Please sign in to comment.