cleverca22
3/12/2016 - 2:37 AM

gistfile1.nix

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, lib, pkgs, ... }:

let
      local_dwm  = lib.overrideDerivation pkgs.dwm (o: {
        nativeBuildInputs = o.nativeBuildInputs ++ [ pkgs.xorg.libXcursor ];
        patches = [
          ../pkgs/dwm/dwm-6.1-xcursor-fix.diff
          ../pkgs/dwm/dwm-6.1-gaps.diff
          ../pkgs/dwm/dwm-6.1-htile.diff
          ../pkgs/dwm/dwm-6.1-pertag_without_bar.diff
          ../pkgs/dwm/dwm-6.1-push.diff
          ../pkgs/dwm/dwm-6.1-attachabove.diff
          ../pkgs/dwm/dwm-6.1-gaplessgrid.diff
          ../pkgs/dwm/dwm-6.1-config.diff
          ../pkgs/dwm/dwm-6.1-bar-padding.diff
          ../pkgs/dwm/dwm-6.1-config.laptop.diff
          ../pkgs/dwm/dwm-6.1-config.colors.diff
        ];
      });
in
{
  imports = [
    ../profiles/common.nix
    ../profiles/desktop.nix
    ../profiles/develop.nix
    ../profiles/network.nix
    ../profiles/documents.nix
  ];
    
  boot = {
    loader.grub = {
      enable = true;
      device = "/dev/sdb";
      version = 2;
      memtest86.enable = true;
      extraEntries = ''
        menuentry "Windows 10" {
          chainloader (hd1,1)+1
        }

       menuentry 'Arch Linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-ccaec69b-c4c5-4fa6-96e6-3af7523cafcb' {
          load_video
          set gfxpayload=keep
          insmod gzio
          insmod part_msdos 
          insmod ext2
          set root='hd1,msdos1'
          if [ x$feature_platform_search_hint = xy ]; then
            search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1  b1f6d398-fe1e-4195-8d9b-baca3df4f61b
          else
            search --no-floppy --fs-uuid --set=root b1f6d398-fe1e-4195-8d9b-baca3df4f61b
          fi
          echo	'Loading Linux linux ...'
          linux	/vmlinuz-linux root=UUID=ccaec69b-c4c5-4fa6-96e6-3af7523cafcb rw  quiet
          echo	'Loading initial ramdisk ...'
          initrd	 /initramfs-linux.img
       }
      '';
      extraConfig = ''
        set gfxpayload=1920x1080x32
      '';
    };
    kernelPackages = pkgs.linuxPackages_4_3;
    kernelModules = [ 
      "acpi-cpufreq"
      "msr" 
      "i951"
    ];
  };


  # TODO: Move to proper service .nix file
  systemd.services.powertopTune = {
    description = "Auto-tune tunables with powertop";
    wantedBy = [ "multi-user.target" ];
    path = [ pkgs.powertop ];
    serviceConfig = {
      Type = "idle";
      ExecStart = "${pkgs.powertop}/bin/powertop --auto-tune";
      User = "root";
    };
    restartIfChanged = false;
  };

  hardware.enableAllFirmware = true;
  networking = {
    hostName = "h04x-laptop"; 
    wireless.enable = true;  
  };

  environment.systemPackages = with pkgs; [
    powertop 
    xorg.xbacklight xorg.xf86inputsynaptics
    audacity inkscape mpv librecad openscad #freecad
  ];

  i18n = {
    consoleFont = "Lat2-Terminus16";
    consoleKeyMap = /etc/nixos/files/us-capswap.map.gz;
    defaultLocale = "en_US.UTF-8";
  };

  services = { 
    redshift = {
      enable = true;
      latitude = "53.3";
      longitude = "10";
      temperature = {
        day = 6500;
        night = 3400;
      };
    };

    xserver = {
      videoDrivers = [ "intel" ];
      vaapiDrivers = [ pkgs.vaapiIntel pkgs.vaapiVdpau ];
      modules = [ pkgs.xorg.xf86inputsynaptics ];
      desktopManager.session = [{
        name = "laptop";
        start = ''
          export XCURSOR_PATH=${config.system.path}/share/icons
          export XCURSOR_THEME="Vanilla-DMZ"
          export XCURSOR_SIZE=32
          #${pkgs.xorg.xsetroot}/bin/xsetroot -cursor_name left_ptr
          #${pkgs.compton}/bin/compton -b --config ${../dotfiles/compton.conf}
          ${pkgs.feh}/bin/feh --bg-scale ${../files/bg.jpg} &
          ${pkgs.xlibs.xrdb}/bin/xrdb -load ${../dotfiles/Xresources_laptop}
          (${pkgs.conky}/bin/conky -c ${../dotfiles/bar_laptop} | while read LINE; \
            do ${pkgs.xorg.xsetroot}/bin/xsetroot -name "$LINE"; \
          done) & 

          ${local_dwm}/bin/dwm &
          waitPID=$!
        '';
      }];
      deviceSection = ''
        Option  "TearFree"    "true"
        Option  "AccelMethod" "SNA"
        #Option  "DRI"         "3"
      '';
      config = ''
        Section "InputClass"
           Identifier "Clickpad"
           MatchIsTouchpad "on"
           MatchDevicePath "/dev/input/event*"
           Driver "synaptics"
           # Synaptics options come here.
            Option "TapButton1" "1"
            Option "TapButton2" "3"
            Option "TapButton3" "2"
            Option "SoftButtonAreas" "60% 0 0 40% 40% 60% 0 40%"
           Option "AreaTopEdge"          "30%"
           Option "AreaBottomEdge"       "0"
        
        
           Option "VertTwoFingerScroll"  "1"
           Option "HorizTwoFingerScroll"  "1"
           Option "VertScrollDelta"	   "-99"
           Option "HorizScrollDelta"	   "-99"
           
           Option "AccelFactor"       "0"
           Option "MaxSpeed"          "1"
           Option "MinSpeed"          "15"
        
           Option "VertResolution" "100"
           Option "HorizResolution" "65"
           # disable synaptics driver pointer acceleration
           Option "MinSpeed" "1"
           Option "MaxSpeed" "1"
           # tweak the X-server pointer acceleration
           Option "AccelerationProfile" "2"
           Option "AdaptiveDeceleration" "16"
           Option "ConstantDeceleration" "16"
           Option "VelocityScale" "272"
        
        EndSection
        
        Section "InputClass"
           Identifier   "TrackPoint"
           MatchProduct "TrackPoint"
           MatchDriver  "synaptics"
           #MatchDevicePath  "/dev/input/event*"
           Option       "EmulateWheel"       "true"
           Option       "EmulateWheelButton" "2"
           Option       "Emulate3Buttons"    "false"
           Option       "XAxisMapping" 	  "6 7"
           Option       "YAxisMapping" 	  "4 5"
        EndSection
      '';
    }; 
  };
}