Skip to content

Commit

Permalink
file: add file_name attribute to DeploymentTrash
Browse files Browse the repository at this point in the history
Fixes #209
See FC-42677

This won't work for multiple deployments on the same host using all the
same file since all of those deployments will override each other's
trash.nix (or fail trying if each deployment uses its own service user).
  • Loading branch information
Ma27 committed Dec 27, 2024
1 parent 588b2b7 commit 149c873
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Allow to configure the name of the `.nix` file created by `batou_ext.file.DeploymentTrash`.
6 changes: 5 additions & 1 deletion src/batou_ext/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class SymlinkAndCleanup(batou.component.Component):
systemd_read_max_iops = 100
systemd_write_max_iops = 100
trashdir = None
trash_config_file_name = batou.component.Attribute(str, default="trash.nix")

## DEPRECATED, do not use
use_systemd_run_async_cleanup = False
Expand All @@ -58,6 +59,7 @@ def configure(self):
read_iops_limit=self.systemd_read_max_iops,
write_iops_limit=self.systemd_write_max_iops,
trashdir=self.trashdir,
file_name=self.trash_config_file_name,
)
self.trash = self._

Expand Down Expand Up @@ -170,6 +172,8 @@ def update(self):
```
"""

file_name = batou.component.Attribute(str, default="trash.nix")

read_iops_limit = 100
write_iops_limit = 100

Expand All @@ -181,7 +185,7 @@ def configure(self):

self += batou.lib.file.File(self.trashdir, ensure="directory")
self += batou.lib.file.File(
"/etc/local/nixos/trash.nix",
f"/etc/local/nixos/{self.file_name}",
content=dedent(
"""\
{
Expand Down

0 comments on commit 149c873

Please sign in to comment.