summaryrefslogtreecommitdiff
path: root/bragi.nix
blob: ad5ceee82ffabc1c779a3e3842e666e989a7ca0b (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
{ config, pkgs, ... }:

{
  imports =
    [
      ./bragi-hw.nix
      ./customized/autofs.nix
    ];

  boot.loader.grub.enable = true;
  boot.loader.grub.version = 2;
  boot.loader.grub.device = "/dev/sda";

  boot.loader.grub.extraConfig = "serial; terminal_output.serial";
  boot.kernelParams = [ "console=ttyS0,115200"
                      ];

  networking.hostName = "bragi";
  networking.hostId = "2af11085";
  networking.wireless.enable = true;

  networking.firewall = {
    enable = false;
  };

  nixpkgs.config.packageOverrides = pkgs:
    {
      trivmix = pkgs.callPackage ./customized/trivmix.nix {};
      jack2 = pkgs.callPackage ./customized/jack2.nix {};
      mpd = pkgs.callPackage ./customized/mpd.nix {
        gmeSupport = false;
        game-music-emu = null;
      };
      mpv = pkgs.stdenv.lib.overrideDerivation pkgs.mpv (oldAttrs: {
        buildInputs = oldAttrs.buildInputs ++ [pkgs.makeWrapper]
        postInstall = ''
          wrapProgram $out/bin/mpv \
            --set JACK_PROMISCUOUS_SERVER 1 \
            --run "umask 0"
        '';
      });
    };

  environment.systemPackages = with pkgs; [
    git
    mosh
    rsync
    tmux
    nfs-utils
    jack2
  ];

  # List services that you want to enable:

  services.openssh.enable = true;

  services.fcron = {
    enable = true;
    systab = ''
      %weekly * * nix-collect-garbage --delete-older-than '7d'
    '';
  };

  services.autofs = {
    enable = true;
    autoMaster = let
      mapConf = pkgs.writeText "auto" ''
        odin -fstype=nfs,ro odin.asgard.yggdrasil:/srv/media
      '';
      in ''
        /media file:${mapConf}
      '';
  };

  systemd.services.jack = {
    wantedBy = [ "sound.target" ];
    serviceConfig = {
      Type = "simple";
      ExecStart = "${pkgs.jack2}/bin/jackd -d alsa -M -H -r 96000";
      User = "jack";
      Group = "audio";
    };
  };

  services.mpd = {
    enable = true;
    musicDirectory = "/media/odin/music";
    extraConfig = ''
      audio_output {
        name "JACK"
        type "jack"
        client_name "mpd"
      }
    '';
  };

  users.extraUsers.jack = {
    name = "jack";
    isSystemUser = true;
    group = "audio";
  };

  users.extraUsers.gkleen = {
    name = "gkleen";
    isNormalUser = true;
    uid = 1000;
    createHome = true;
    home = "/home/gkleen";
    shell = "${pkgs.zsh}/bin/zsh";
    openssh.authorizedKeys.keys = [ "ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBABVMu+0txXdxdTSY8POAYVXbuOEDW6VxJzaYwQljc9kzM63VUZuE606R0g2ZGr9A+Gk6qO6fpCiq4SM+1Yygz5yHgGlbO750TOGaTe6KSGw+u3miaeDviejmxTqetGmiJe7BTLRAbYHjRgD5SkK/Ovos0cDSyOfZ5aha/ehox+proQKGA== gkleen@cathy"
                                  ];
    extraGroups = [ "wheel" "audio" ];
    hashedPassword = "$6$MBq4kwM68$Eg8O6m76mM2905VppNZO67J3EHqJVBuIWQkz.MFFa7afVQKhGuSSYHl50WkkFYXHEY5MIM7IjWYZ0UJwq2IDJ0";
  };

  security.setuidPrograms = ["mount.nfs"];

  security.pam.loginLimits =
  [
    { domain = "@audio"; item = "memlock"; type = "-"; value = "unlimited"; }
    { domain = "@audio"; item = "rtprio"; type = "-"; value = "99"; }
    { domain = "@audio"; item = "nofile"; type = "soft"; value = "99999"; }
    { domain = "@audio"; item = "nofile"; type = "hard"; value = "99999"; }
  ];
}