💾 Archived View for unixcat.coffee › techne › nixos.gmi captured on 2021-12-03 at 14:04:38. Gemini links have been rewritten to link to archived content

View Raw

More Information

➡️ Next capture (2022-01-08)

-=-=-=-=-=-=-

Nix and NixOS

sudo no password for user

Place the following in /etc/nixos/configuration.nix:

security.sudo.extraRules = [{
    users = [ "jas" ];
    commands = [{
        command = "ALL";
        options = [ "SETENV" "NOPASSWD" ];
    }];
}];

Nix daemon garbage collection and optimization

nix = {
    * Automate `nix-store --optimize`
    autoOptimiseStore = true;
    
    * Automate garbage collection
    gc = {
        automatic = true;
        dates = "weekly";
        options = "--delete-older-than 7d";
    };
    trustedUsers = [ "root" "jas" ];
    extraOptions = ''
        keep-outputs = true
        keep-derivations = true
    '';
};

Intel audio probe mask

boot.extraModprobeConfig = "options snd-hda-intel probe_mask=1";

Tmpfs

fileSystems."/home/jas/tmp" = {
    device = "tmpfs";
    fsType = "tmpfs";
    options = [ "nodev" "nosuid" "uid=1000" "gid=1000" "size=10G" "noexec"
    "mode=1700" ];
};

Make /etc/resolv.conf immutable

environment.etc."resolv.conf" = with lib; with pkgs; {
    source = writeText "resolv.conf" ''
        ${concatStringsSep "\n" (map (ns: "nameserver ${ns}")
        config.networking.nameservers)}
        options edns0
    '';
};

Use external display with Nvidia

services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia = {
    prime.intelBusId = "PCI:0:2:0";
    prime.nvidiaBusId = "PCI:1:0:0";
    prime.sync.enable = true;
    modesetting.enable = true;
};

Regular Nvidia config

let
    nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" ''
        export __NV_PRIME_RENDER_OFFLOAD=1
        export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
        export __GLX_VENDOR_LIBRARY_NAME=nvidia
        export __VK_LAYER_NV_optimus=NVIDIA_only
        exec -a "$0" "$@"
    '';
in

{
    environment.systemPackages = [ nvidia-offload ];
    services.xserver.videoDrivers = [ "nvidia" ];
    hardware.nvidia.modesetting.enable = true;
    hardware.nvidia.prime = {
        offload.enable = true;
        intelBusId = "PCI:0:2:0";
        nvidiaBusId = "PCI:1:0:0";
    };
}

~~~

Last updated: 2021-11-19

Back to Techne index

Back to unixcat.coffee