summaryrefslogtreecommitdiff
path: root/nixos/kusanagi.nix
blob: cf5450ca57dd486a09018586b2b9afe9e91889aa (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
# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

let
    home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz";
in
{
  imports =
    [
      (modulesPath + "/installer/scan/not-detected.nix")
      ./common.nix
      ./icewm.nix
      (import "${home-manager}/nixos")
    ];

  networking.hostName = "kusanagi";
  networking.hostId = "b807fe35";

  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usb_storage" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];

  boot.initrd.luks.devices = {
    lukszfs = {
      device = "/dev/disk/by-uuid/90f30f15-3ee3-4a15-bab6-36fb31630e2a";
      allowDiscards = true;
    };
  };

  # ---- standard filesystems ----

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/E2FA-FB92";
      fsType = "vfat";
    };

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

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

  swapDevices = [ ];

  # ---- tmpfs root filesystem with special persisted directory ----

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

  fileSystems."/persist" =
    { device = "kusanagi/nixos/persist";
      fsType = "zfs";
      neededForBoot = true;  # because contains /var/log
    };

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

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

  fileSystems."/var/log" =
    { device = "/persist/var/log";
      fsType = "none";
      depends = [ "/persist" "/mnt-root/persist" ];
      options = [ "bind" ];
    };

  # ---- immutable user config for tmpfs root ----

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

  # ---- no persistent home, use home manager to set everything up ----

  # nur has to be imported twice, otherwise doesn't work
  nixpkgs.config.packageOverrides = pkgs: {
    nur = import (builtins.fetchTarball
      "https://github.com/nix-community/NUR/archive/master.tar.gz") {
        inherit pkgs;
      };
  };
  home-manager.users.lx = import ../nixpkgs/kusanagi.nix { inherit pkgs; };

  # ----

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