summary refs log tree commit diff
path: root/machines/moissanite/devices.nix
blob: 06c10ed02d45fb1e4ca7f397020cf227cac2d6cd (plain)
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
123
124
125
126
{
  config,
  lib,
  pkgs,
  nixos-apple-silicon,
  ...
}:

{
  imports = [
    nixos-apple-silicon.nixosModules.apple-silicon-support
  ];

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

    plymouth.enable = true;

    initrd.systemd.enable = true;

    # expand display to notch region
    kernelParams = [
      "appledrm.show_notch=1"
    ];

    # check nixos-apple-silicon documentation on this,
    # if keyboard weirdness ever comes up.
    # extraModprobeConfig = ''
    #   options hid_apple iso_layout=0
    # '';

    # show a nix logo on asahi m1n1 boot!
    m1n1CustomLogo = ../../assets/nix-256x256.png;
  };

  # swap
  zramSwap = {
    enable = true;
    algorithm = "zstd";
    swapDevices = 1;
    memoryPercent = 50;
  };

  # hardware
  hardware = {
    enableAllFirmware = true;
    enableRedistributableFirmware = true;

    graphics = {
      enable = true;
      enable32Bit = lib.mkForce false;
    };
    bluetooth.enable = true;

    # asahi-specific settings!
    asahi = {
      enable = true;

      # proprietary apple firmware extracted during installation.
      # it can also be found in /boot/asahi, but needs to be
      # included here for flake purity.
      peripheralFirmwareDirectory = ../../assets/m1-firmware;

      # sound
      setupAsahiSound = true;
    };
  };

  # internet/wifi
  networking = {
    networkmanager = {
      enable = true;
      wifi.backend = "iwd";
    };
    wireless.iwd = {
      enable = true;
      settings.General.EnableNetworkConfiguration = true;
    };
  };

  # sound
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa = {
      enable = true;
      support32Bit = true;
    };
    pulse.enable = true;
    jack.enable = true;
  };

  fileSystems =
    let
      options = [
        "users" # any user can mount and unmount dao, implies 'noexec', 'nodev', 'nosuid'
        "exec" # override 'users' 'noexec' default, executable files are nice!
        "nofail" # it's okay if dao can't be found
        "noatime" # do not update access timestamps (files+folders)

        # btrfs options
        "compress=zstd" # compress data with zstd, level 3
      ];
    in
    {
      # disk with all my personal projects & life in general
      "/mnt/Dao" = {
        device = "/dev/disk/by-label/Dao";
        fsType = "btrfs";

        inherit options;
      };

      # disk with consultancy work-related things
      "/mnt/Lao" = {
        device = "/dev/disk/by-label/Lao";
        fsType = "btrfs";

        inherit options;
      };
    };

  services.btrfs.autoScrub.enable = true;
}