about summary refs log tree commit diff
path: root/machines/aszlig/dnyarri.nix
blob: 5651b73ff839d1a6fd60447086469004a8584077 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{ config, pkgs, utils, lib, ... }:

let
  mkDevice = category: num: uuid: {
    name = "dnyarri-${category}-crypt-${toString num}";
    value.device = "/dev/disk/by-uuid/${uuid}";
  };

  cryptDevices = {
    root = lib.imap (mkDevice "root") [
      "36260b1f-b403-477f-ab0e-505061c4e9d8"
      "3d5d71fa-ca2a-4144-a656-c68378cd2128"
    ];
    swap = lib.imap (mkDevice "swap") [
      "537b8b6b-0f03-4b2a-b0bb-6ebf18f7d9a0"
      "82d5a52d-1661-474d-859d-85c7d400d4b5"
    ];
  };

in {
  vuizvui.user.aszlig.profiles.workstation.enable = true;

  nix.settings.max-jobs = 24;

  hardware.printers.ensureDefaultPrinter = "Bunti";
  hardware.printers.ensurePrinters = lib.singleton {
    name = "Bunti";
    deviceUri = "hp:/usb/HP_Color_LaserJet_2700?serial=00CNFNL14079";
    model = "HP/hp-color_laserjet_2700-ps.ppd.gz";
    location = "Living room";
    description = "Color laser printer";
    ppdOptions.PageSize = "A4";
  };

  boot = {
    loader.systemd-boot.enable = true;
    loader.grub.enable = false;
    loader.efi.canTouchEfiVariables = true;

    kernelPackages = pkgs.linuxPackages_latest;

    initrd = {
      availableKernelModules = [ "xhci_pci" "ahci" "nvme" ];
      luks.devices =
        lib.listToAttrs (lib.concatLists (lib.attrValues cryptDevices));
    };
  };

  environment.systemPackages = [
    (pkgs.gpodder.overrideAttrs (drv: {
      propagatedBuildInputs = (drv.propagatedBuildInputs or []) ++ [
        pkgs.python3Packages.youtube-dl
      ];
    }))
    pkgs.paperwork
  ];

  services.fwupd.enable = true;
  services.fwupd.package = pkgs.fwupd.overrideAttrs (drv: {
    # This is to disable reports because they include identifying information.
    postInstall = (drv.postInstall or "") + ''
      sed -i -e '/ReportURI/d' "$out"/etc/fwupd/remotes.d/*.conf
    '';
  });

  hardware.cpu.amd.updateMicrocode = true;

  hardware.sane.enable = true;

  hardware.enableRedistributableFirmware = true;

  networking.hostName = "dnyarri";
  networking.interfaces.enp1s0.useDHCP = true;

  fileSystems = {
    "/boot" = {
      device = "/dev/disk/by-uuid/8C65-450D";
      fsType = "vfat";
    };
    "/" = {
      label = "dnyarri-root";
      fsType = "btrfs";
      options = [
        "autodefrag" "space_cache" "compress=zstd" "noatime" "discard=async"
      ];
    };
  };

  services.btrfs.autoScrub.enable = true;

  # The machine has two identical sound cards, so let's give them stable
  # identifiers because the device names assigned by the kernel are based on
  # initialisation order.
  services.udev.extraRules = let
    mkRule = id: path: ''
      ACTION=="add", DEVPATH=="${path}", SUBSYSTEM=="sound", ATTR{id}="${id}"
    '';
  in lib.concatStrings (lib.mapAttrsToList mkRule {
    lower = "/devices/pci0000:00/0000:00:03.1/0000:02:00.0/*/sound/card?*";
    upper = "/devices/pci0000:40/0000:40:01.1/0000:41:00.0/*/sound/card?*";
  });

  swapDevices = map ({ name, ... }: {
    device = "/dev/mapper/${name}";
  }) cryptDevices.swap;

  users.users.aszlig.extraGroups = [ "scanner" ];

  services.xserver.videoDrivers = [ "amdgpu" ];
  services.xserver.xrandrHeads = [ "DisplayPort-0" "DisplayPort-1" ];
  services.xserver.wacom.enable = true;

  vuizvui.user.aszlig.services.i3.workspaces."1" = {
    label = "XMPP";
    assign = lib.singleton { class = "^(?:Tkabber|Gajim|Psi)\$"; };
  };

  vuizvui.user.aszlig.services.i3.workspaces."3" = {
    label = "Browser";
    assign = lib.singleton { class = "^Firefox\$"; };
  };
}