about summary refs log tree commit diff
path: root/machines/profpatsch/base-workstation.nix
blob: ac85398bc91e07356af0282ce3b93e2469778271 (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
147
148
# A base configuration for my workstations.
{ pkgs, lib, ... }:
let
  myPkgs = import ./pkgs.nix { inherit pkgs lib myLib; };
  myLib  = import ./lib.nix  { inherit pkgs lib; };

  philip = myLib.philip;

in {

  imports = [
    ./base.nix
  ];

  config = {

    time.timeZone = "Europe/Berlin";

    networking = {
      # it will be ready when it’s ready,,
      enableIPv6 = false;
      # better for untrusted networks
      firewall = {
        enable = true;
        # for manual/temporary stuff
        allowedTCPPortRanges =
          [{ from = 9990; to = 9999; }];
        allowedUDPPortRanges =
          [{ from = 9990; to = 9999; }];
      };
    };

    vuizvui.services.upower = {
      enable = true;
      settings = {
        UPower = {
          UsePercentageForPolicy = true;
          CriticalPowerAction = "Suspend";

          PercentageLow = 15;
          PercentageCritical = 8;
          PercentageAction = 5;
        };
      };
    };

    ###################
    # Graphical System

    services.xserver = {
      enable = true;
      layout = "de";
      xkbVariant = "neo";
      xkbOptions = "altwin:swap_alt_win";
      serverFlagsSection = ''
        Option "StandbyTime" "10"
        Option "SuspendTime" "20"
        Option "OffTime" "30"
      '';

      # otherwise xterm is enabled, creating an xterm that spawns the window manager.
      desktopManager.xterm.enable = false;

      windowManager.xmonad = {
        enable = true;
        enableContribAndExtras = true;
      };

      displayManager = {
        sessionCommands = with pkgs; ''
            #TODO add as nixpkg
            export PATH+=":$HOME/scripts" #add utility scripts
            export PATH+=":$HOME/bin" #add user-specific binaries (filled by nix-home)
            export EDITOR="emacsclient --create-frame"
            export TERMINAL=terminal-emulator

            ${xorg.xset}/bin/xset r rate 250 35

            set-background &
            # TODO xbindkeys user service file
            ${lib.getBin xbindkeys}/bin/xbindkeys
            # synchronize clipboards
            ${lib.getBin autocutsel}/bin/autocutsel -s PRIMARY &
          '';
      };

      # TODO: libinput?
      libinput.enable = false;
      synaptics = {
        enable = true;
        minSpeed = "0.6";
        maxSpeed = "1.5";
        accelFactor = "0.015";
        twoFingerScroll = true;
        vertEdgeScroll = false;
      };

    };

    fonts.fontconfig = {
      enable = true;
      defaultFonts = {
        monospace = [ "Source Code Pro" "DejaVu Sans Mono" ]; # TODO does not work
        sansSerif = [ "Liberation Sans" ];
      };
    };


    programs.ssh.startAgent = false;

    ###########
    # Packages

    environment.sessionVariables = { EDITOR = "${myPkgs.vim}/bin/vim"; };

    environment.systemPackages = with pkgs;
    let
      # of utmost necessity for me to function
      basePkgs = [
        smartmontools     # check disk state
        stow              # dotfile management
        wirelesstools     # iwlist (wifi scan)
        gitFull           # git with send-email
      ];
      # minimal set of gui applications
      guiPkgs = [
        dmenu             # minimal launcher
        (pkgs.vuizvui.profpatsch.binify { exe = pkgs.vuizvui.profpatsch.xdg-open; name = "xdg-open"; }) # override the crap freedesktop crap
      ];
    in basePkgs ++ guiPkgs;

    # friendly user shell
   programs.fish.enable = true;

    ###########
    # Services

    # services.openssh.enable = true;

    vuizvui.programs.fish.fasd.enable = true;

    ########
    # Users

    users.users = { inherit philip; };

  };
}