]> git.scottworley.com Git - nix-currently-building/blame - nix_currently_building.py
Show what nix-daemon is currently building
[nix-currently-building] / nix_currently_building.py
CommitLineData
879c383c
SW
1import os
2import subprocess
3import time
4
5
6BLOCK_SIZE = 4096
7MIN_AGE = time.time() - 86400 * 7
8
9
10def removesuffix(s, suf): # Until python 3.9
11 return s[:len(s) - len(suf)] if s.endswith(suf) else s
12
13
14def truncated(log):
15 return subprocess.run(['bunzip2', '--test', log], stderr=subprocess.DEVNULL).returncode == 2
16
17
18def main():
19 for d, _, files in os.walk(os.environ.get('NIX_LOG_DIR', '/nix/var/log/nix')):
20 for f in files:
21 path = os.path.join(d, f)
22 st = os.stat(path)
23 if (st.st_size % BLOCK_SIZE) == 0 and st.st_mtime > MIN_AGE and truncated(path):
24 print(d[-2:] + removesuffix(f, '.bz2'))
25
26
27if __name__ == '__main__':
28 main()