summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorMichael Hoang <Enzime@users.noreply.github.com>2024-01-16 08:06:44 +1000
committerGitHub <noreply@github.com>2024-01-16 08:06:44 +1000
commit44a6ec1faeff61a6404c25ef1a263fc2d98d081b (patch)
tree2eb9e19f69bf093537d08255e95c8f82cfe75b57 /modules
parent0dd382b70c351f528561f71a0a7df82c9d2be9a4 (diff)
parentc4ea346d0f74bfaaeb6a0afbc27bbdf5963a153b (diff)
Merge pull request #850 from tfc/master
linux-builder: Add `ephemeral` option to delete VM's disk image on service restart
Diffstat (limited to 'modules')
-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;
};
};