summaryrefslogblamecommitdiff
path: root/nixos/kusanagi.nix
blob: d2cd13c4b449dc299920fa07c6425b1763abd378 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12




                                                                           
   





                                                                                                     


                                                                                                                  
    
  
 



                                                        
                   
                 
                                      
      

                                   
                                 
 

                                              
 


                                                                                    


                                       
                              

                                                                        


                           
 






                                             
                    













                                                                        
                     

                     
                                                  
    
 




                                                        
 
                                                                  
 





                                                                
 









                                                   
                                                  
                            
                                                        
 



                                                                       


                         


                                                                           



                            



                                               







                                              
                      
 
                                  
                                                            



                                     

              
                                      

                                               
        
 
                                                      

                                                                                                   
 
# 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
  nurSrc = builtins.fetchTarball {
    url =
      "https://github.com/nix-community/NUR/archive/687ed97c4379e9ad1346fc673e3e0fc88210de14.tar.gz";
    sha256 = "sha256:0pxljc5bzcwb8c43qmm5l49p03snq7piqnshglqday2dw6cfcd6l";
  };
  home-manager = builtins.fetchTarball {
    # branch release-23.11 as of 2023-12-25
    url = "https://github.com/nix-community/home-manager/archive/d5824a76bc6bb93d1dce9ebbbcb09a9b6abcc224.tar.gz";
    sha256 = "sha256:16ab1k33aivqc5ighi95nh28pssbds5glz3bb371gb06qpiydihl";
  };
in
{
  imports =
    [
      (modulesPath + "/installer/scan/not-detected.nix")
      ./common.nix
      ./wayfire.nix
      ./local.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=8G" "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;
  users.users.lx.extraGroups = [ "vboxusers" "docker" ];

  # ---- 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 nurSrc {
      inherit pkgs;
    };
  };
  home-manager.users.lx = import ../nixpkgs/kusanagi.nix { inherit pkgs; };

  # ---- disable nix gc ----

  nix.gc.automatic = false;

  # ---- disable unbound dns resolution ----

  services.unbound.resolveLocalQueries = false;

  # ---- improve graphics ----

  services.xserver.videoDrivers = [ "intel" ];
  services.xserver.deviceSection = ''
    Option "DRI" "2"
    Option "TearFree" "true"
  '';

  # ---- printing ----

  services.printing.enable = true;
  services.printing.drivers = [ pkgs.cups-brother-hl1210w ];
  services.avahi.enable = true;
  services.avahi.nssmdns = true;
  services.avahi.openFirewall = true;

  # ---- other

  virtualisation.docker.enable = true;
  virtualisation.virtualbox.host.enable = true;

  # ----

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