kore / nixos / roles / workstation.nix58 lines · 1621B · raw
1{ inputs, outputs, config, pkgs, lib, ... }:
2
3let
4 roleName = "workstation";
5 roleEnabled = lib.elem roleName config.kore.currentHost.roles;
6in {
7 imports = [ inputs.home-manager.nixosModules.home-manager ];
8
9 config = lib.mkMerge [{} (lib.mkIf roleEnabled {
10 home-manager = {
11 useGlobalPkgs = true;
12 useUserPackages = true;
13 extraSpecialArgs = { inherit inputs outputs; };
14
15 users.lostduk = outputs.homeConfigurations.${config.networking.hostName};
16 };
17
18 systemd.services.wipe-trash = {
19 restartIfChanged = false;
20 wantedBy = [ "multi-user.target" ];
21 serviceConfig = {
22 Type = "oneshot";
23 RemainAfterExit = true;
24 ExecStart = pkgs.writeShellScript "" ''
25 set -e
26
27 TARGET="/home/lostduk"
28
29 find "$TARGET" -mindepth 1 -maxdepth 1 \
30 ! -name 'documents' \
31 ! -name '.gnupg' \
32 ! -name '.password-store' \
33 ! -name '.local' \
34 -exec rm -r {} +
35
36 if [ -d "$TARGET/.local" ]; then
37 find "$TARGET/.local" -mindepth 1 -maxdepth 1 \
38 ! -name 'share' \
39 -exec rm -r {} +
40 fi
41
42 if [ -d "$TARGET/.local/share" ]; then
43 find "$TARGET/.local/share" -mindepth 1 -maxdepth 1 \
44 ! -name 'opencode' \
45 -exec rm -r {} +
46 fi
47
48 if [ -d "$TARGET/.local/share/opencode" ]; then
49 find "$TARGET/.local/share/opencode" -mindepth 1 -maxdepth 1 \
50 ! -name 'auth.json' \
51 -exec rm -r {} +
52 fi
53 '';
54 };
55 };
56 })];
57}
58