about summary refs log tree commit diff
path: root/machines/dnyarri.nix
blob: ce0bc6ba5ecb96bbeed19192512549684c5cc09d (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
123
124
125
126
{ pkgs, ... }:

with pkgs.lib;
with import ../lib;

{
  require = singleton ../common.nix;

  boot = let
    patch51Name = "patch51.fw";
    extraKernelParams = [ "snd-hda-intel.patch=${patch51Name}" ];

    patch51 = pkgs.writeText patch51Name ''
      [codec]
      0x10ec0889 0x80860033 2

      [pincfg]
      0x11 0x01442130
      0x12 0x411111f0
      0x14 0x01014410
      0x15 0x0321403f
      0x16 0x40f000f0
      0x17 0x40f000f0
      0x18 0x03a19020
      0x19 0x40f000f0
      0x1a 0x01014412
      0x1b 0x01014411
      0x1c 0x411111f0
      0x1d 0x411111f0
      0x1e 0x01451140
      0x1f 0x01c51170

      [model]
      auto
    '';

    builtinFW = [
      "${pkgs.radeonR600}/radeon/R600_rlc.bin"
      "${pkgs.radeonR700}/radeon/R700_rlc.bin"
    ];

    linuxAszlig = pkgs.linuxManualConfig {
      inherit (pkgs.kernelSourceAszlig) version src;

      configfile = pkgs.substituteAll {
        name = "aszlig-with-firmware.kconf";
        src = generateKConf (import ./dnyarri-kconf.nix);

        builtin_firmware = pkgs.stdenv.mkDerivation {
          name = "builtin-firmware";
          buildCommand = ''
            mkdir -p "$out/radeon"
            ${concatMapStrings (x: "cp -Lv -t \"$out/radeon\" \"${x}\";") builtinFW}

            cp "${patch51}" "$out/${patch51Name}"
          '';
        };
      };
      allowImportFromDerivation = true; # XXX
    };
  in rec {
    kernelPackages = let
      kpkgs = pkgs.linuxPackagesFor linuxAszlig kernelPackages;
      virtualbox = kpkgs.virtualbox.override {
        enableExtensionPack = true;
      };
    in pkgs.recurseIntoAttrs (kpkgs // { inherit virtualbox; });
    inherit extraKernelParams;

    initrd = {
      mdadmConf = ''
        ARRAY /dev/md0 metadata=1.2 UUID=f5e9de04:89efc509:4e184fcc:166b0b67
        ARRAY /dev/md1 metadata=0.90 UUID=b85aa8be:cea0faf2:7abcbee8:eeae037b
      '';
      luks.enable = true;
      luks.devices = [
        { name = "system_crypt";
          device = "/dev/md1";
          preLVM = true;
        }
      ];
    };

    loader.grub.devices = [
      "/dev/disk/by-id/ata-ST31500541AS_5XW0AMNH"
      "/dev/disk/by-id/ata-ST31500541AS_6XW0M217"
    ];
  };

  networking.hostName = "dnyarri";

  fileSystems = {
    "/boot" = {
      label = "boot";
      fsType = "ext2";
    };
    "/" = {
      device = "/dev/shofixti/root";
      fsType = "xfs";
    };
  };

  powerManagement.powerUpCommands = ''
    ${pkgs.hdparm}/sbin/hdparm -B 255 /dev/disk/by-id/ata-ST31500541AS_5XW0AMNH
    ${pkgs.hdparm}/sbin/hdparm -B 255 /dev/disk/by-id/ata-ST31500541AS_6XW0M217
  '';

  swapDevices = singleton {
    device = "/dev/shofixti/swap";
  };

  # TODO: Try to avoid this, but as there is only a single user using audio on
  # this machine, it's okay for now. But remember that this will break heavily,
  # should there be another user accessing the audio devices.
  users.extraUsers.aszlig.extraGroups = [ "audio" ];

  services.xserver = {
    videoDrivers = [ "ati" ];

    xrandrHeads = [ "HDMI-0" "DVI-0" ];

    displayManager.sessionCommands = ''
      ${pkgs.synergy}/bin/synergyc mmrnmhrm
    '';
  };
}