summaryrefslogtreecommitdiff
path: root/nixos/lindy.nix
blob: 471026d0e559bccf81daede154e2ed93f0fb35f9 (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
{ config, lib, pkgs, modulesPath, ... }:

{
  imports = [
    (modulesPath + "/installer/scan/not-detected.nix")
    ./common.nix
    ./kde.nix
    #./95theme.nix
    #./gnome.nix
    #./fdn-vpn.nix
  ];

  networking.hostName = "lindy";
  networking.hostId = "b8149765";

  # Driver config
  boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ];
  boot.initrd.kernelModules = [ "dm-snapshot" ];
  boot.kernelModules = [ "kvm-intel" "wl" ];
  boot.extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];

  # ZFS config
  boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
  boot.supportedFilesystems = [ "zfs" ];
  boot.zfs.devNodes = "/dev/mapper";
  boot.zfs.extraPools = [ "Zonz" ];
  services.zfs.autoScrub.enable = true;
  services.zfs.autoScrub.pools = [ "Zonz" ];
  services.zfs.autoScrub.interval = "quarterly";

  # Use Grub
  boot.loader.grub.enable = true;
  boot.loader.grub.efiSupport = true;
  boot.loader.grub.device = "nodev";
  boot.loader.grub.extraGrubInstallArgs = [ "--bootloader-id=NixOS" ];
  boot.loader.efi.efiSysMountPoint = "/boot/efi";
  boot.loader.efi.canTouchEfiVariables = true;

  boot.initrd.luks.devices = {
    cryptssd = {
      device = "/dev/disk/by-uuid/a5aad0b3-fb8c-4711-80db-d8fdcc832f83";
      allowDiscards = true;
    };
  };

  fileSystems."/" =
    { device = "none";
      fsType = "tmpfs";
      options = [ "defaults" "size=6G" "mode=755" ];
    };

  fileSystems."/var" =
    { device = "lindy/nixos/var";
      fsType = "zfs";
    };

  fileSystems."/home" =
    { device = "lindy/home";
      fsType = "zfs";
      neededForBoot = true; # because contains password files used below
    };

  fileSystems."/nix" =
    { device = "lindy/nixos/nix";
      fsType = "zfs";
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/b9f80731-ac5a-476e-9454-32fef4ebc40f";
      fsType = "ext4";
      options = [ "discard" ];
    };

  fileSystems."/boot/efi" =
    { device = "/dev/disk/by-uuid/02D0-F1C6";
      fsType = "vfat";
    };

  fileSystems."/root" =     # /root contains the Borg cache for the backup script
    { device = "/nix/persist/root";
      fsType = "none";
      options = [ "bind" ];
    };

  fileSystems."/etc/NetworkManager/system-connections" =
    { device = "/nix/persist/etc/NetworkManager/system-connections";
      fsType = "none";
      options = [ "bind" ];
    };

  environment.etc."machine-id".source = "/nix/persist/etc/machine-id";

  # ---- zonz (encrypted zfs) ----

  environment.etc.crypttab = {
    enable = true;
    text = ''
Kurisu UUID=f593d307-66cc-4586-a899-f1ca20d74430 /nix/persist/root/kurisu_key
Kogami UUID=61534c91-df18-4c71-9244-54e677f5d4fa /nix/persist/root/kogami_key
    '';
  };

  # ---- immutable user config ----

  users.mutableUsers = false;
  users.users.lx.passwordFile = "/home/lx/.password";
  users.users.lx.uid = 1000;

  # ----

  # Backup
  services.cron.enable = true;
  services.cron.systemCronJobs = [ "0 20 * * * root /media/Zonz/lindy/do-backup.sh" ];

  # Nvidia graphics
  boot.kernelParams = [ "i915.modeset=0" ];
  hardware.nvidia.modesetting.enable = true;
  services.xserver.videoDrivers = [ "nvidia" ];
  hardware.opengl.enable = true;

  # Docker, VirtualBox
  virtualisation.docker.enable = true;
  virtualisation.virtualbox.host.enable = true;
  users.users.lx.extraGroups = [ "docker" "vboxusers" ];

  # Making dev work available outside
  networking.firewall.allowedTCPPorts = [
    8910
    8920
  ];

  # GnuPG agent at system level, if at home level conflicts with arch
  programs.gnupg.agent = {
    enable = true;
    enableSSHSupport = false;
  };

  environment.systemPackages = with pkgs; [ zfs docker-compose ];

  nix.gc.automatic = false;

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand";
  hardware.cpu.intel.updateMicrocode =
    lib.mkDefault config.hardware.enableRedistributableFirmware;
}