summaryrefslogtreecommitdiff
path: root/modules/nix
diff options
context:
space:
mode:
authorJacek Galowicz <jacek@galowicz.de>2024-01-14 19:01:24 +0100
committerJacek Galowicz <jacek@galowicz.de>2024-01-15 13:51:34 +0100
commitc4ea346d0f74bfaaeb6a0afbc27bbdf5963a153b (patch)
tree2eb9e19f69bf093537d08255e95c8f82cfe75b57 /modules/nix
parent0dd382b70c351f528561f71a0a7df82c9d2be9a4 (diff)
Dedupe the WorkingDirectory path of the linux-builder
Diffstat (limited to 'modules/nix')
-rw-r--r--modules/nix/linux-builder.nix23
1 files changed, 21 insertions, 2 deletions
diff --git a/modules/nix/linux-builder.nix b/modules/nix/linux-builder.nix
index da8d791..d487800 100644
--- a/modules/nix/linux-builder.nix
+++ b/modules/nix/linux-builder.nix
@@ -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
@@ -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 {
@@ -89,7 +108,7 @@ in
} ];
system.activationScripts.preActivation.text = ''
- mkdir -p /var/lib/darwin-builder
+ mkdir -p ${cfg.workingDirectory}
'';
launchd.daemons.linux-builder = {
@@ -103,7 +122,7 @@ in
];
KeepAlive = true;
RunAtLoad = true;
- WorkingDirectory = "/var/lib/darwin-builder";
+ WorkingDirectory = cfg.workingDirectory;
};
};