summaryrefslogtreecommitdiffstats
path: root/systems/hu/config.nix
blob: d324a0a7f5df06466fc51699b52ae9bc720467b6 (plain)
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
{ config, lib, mylib, pkgs, ... }: {
  imports = [
    ../../configs/binary-cache/client.nix
    ../../configs/initrd/sshd.nix
    ../../configs/retiolum.nix
    ../../configs/wiregrill.nix

    ../../configs/hw/tiny5.nix
    ../../configs/networkd.nix
  ];

  boot.initrd.luks.devices.dona2.device = "/dev/sda2";
  boot.zfs.forceImportRoot = true;
  fileSystems."/" = {
    device = "dona2/root";
    fsType = "zfs";
  };
  fileSystems."/home" = {
    device = "dona2/home";
    fsType = "zfs";
  };
  fileSystems."/boot" = {
    device = "/dev/sda1";
    fsType = "vfat";
  };

  boot.loader.systemd-boot.enable = lib.mkForce false;
  boot.loader.grub.enable = true;
  boot.loader.grub.splashImage = null;
  boot.loader.grub.device = "/dev/sda";

  hrm.nftables.enable = true;

  krebs.build.host = config.krebs.hosts.hu;
  krebs.shadow.overridesFile =
    "${config.krebs.secret.directory}/shadow-overrides";

  services.pipewire.enable = true;

  system.stateVersion = "20.09";

  fonts.packages = [
    pkgs.fontschumachermisc
  ];

  services.displayManager.autoLogin.enable = true;
  services.displayManager.autoLogin.user = "guest";
  services.displayManager.logToJournal = true;
  services.libinput.enable = true;
  services.xserver.enable = true;
  services.xserver.xkb.layout = "de";
  services.xserver.xkb.options = "eurosign:e";
  services.xserver.windowManager.xmonad.enable = true;
  services.xserver.windowManager.xmonad.extraPackages = haskellPackages: [
    haskellPackages.xmonad-contrib
  ];
  services.xserver.windowManager.xmonad.config = /* haskell */ ''
    import System.Posix.Process (executeFile)
    import XMonad
    import XMonad.Actions.CycleWS
    import XMonad.Actions.DynamicWorkspaces
    import XMonad.Hooks.EwmhDesktops (ewmh)
    import XMonad.Hooks.ManageHelpers (doCenterFloat)
    import XMonad.Hooks.Place (placeHook, smart)
    import XMonad.Layout.NoBorders
    import XMonad.Layout.ResizableTile
    import XMonad.Prompt
    import XMonad.Util.EZConfig
    import qualified Data.Map as M
    import qualified Data.Maybe
    import qualified XMonad.StackSet as W

    myTermFontWidth = 6
    myTermPadding = 2
    myScreenWidth = 1366

    main = do
      directories <- getDirectories
      let
        config =
          ewmh $
          def
            { keys = myKeys
            , modMask = mod4Mask
            , layoutHook = smartBorders $
                ResizableTall
                  1
                  (fromIntegral (10 * myTermFontWidth) / fromIntegral myScreenWidth)
                  (fromIntegral (80 * myTermFontWidth + 2 * (myTermPadding + borderWidth def)) / fromIntegral myScreenWidth)
                  []
                |||
                Full
            , manageHook =
                composeAll
                  [ appName =? "DesktopPager" --> doCenterFloat
                  , placeHook (smart (1,0))
                  ]
            , focusedBorderColor = "#f000b0"
            , normalBorderColor  = "#1c1c1c"
            , workspaces = ["1", "2", "3"]
            }
      launch config directories

    myKeys conf = mkKeymap conf
      [ ("M4-<Esc>", spawn "slock")
      , ("M4-<F5>", spawn "${pkgs.pavucontrol}/bin/pavucontrol")

      , ("M4-<F10>", spawn "${pkgs.systemd}/bin/systemctl suspend -i")

      , ("<XF86Sleep>", spawn "${pkgs.systemd}/bin/systemctl suspend -i")

      , ("M4-S-c", kill)
      , ("M4-x", spawn "${pkgs.rxvt-unicode-unwrapped}/bin/urxvt")

      , ("M4-<Space>", sendMessage NextLayout)
      , ("M4-M1-<Space>", setLayout $ XMonad.layoutHook conf) -- resetLayout
      , ("M4-m", windows W.focusMaster)
      , ("M4-j", windows W.focusDown)
      , ("M4-k", windows W.focusUp)
      , ("M4-S-m", windows W.swapMaster)
      , ("M4-S-j", windows W.swapDown)
      , ("M4-S-k", windows W.swapUp)

      , ("M4-M1-h", sendMessage Shrink)
      , ("M4-M1-l", sendMessage Expand)
      , ("M4-M1-j", sendMessage MirrorShrink)
      , ("M4-M1-k", sendMessage MirrorExpand)
      , ("M4-t", withFocused $ windows . W.sink)

      , ("M4-<AudioMute>", spawn "${pkgs.pavucontrol}/bin/pavucontrol")

      , ("<XF86AudioLowerVolume>", spawn "${pkgs.alsa-utils}/bin/amixer -q sset Master 5%-")
      , ("<XF86AudioRaiseVolume>", spawn "${pkgs.alsa-utils}/bin/amixer -q sset Master 5%+")
      , ("<XF86AudioMute>", spawn "${pkgs.alsa-utils}/bin/amixer -q sset Master toggle")

      , ("M4-a", addWorkspacePrompt myPromptConfig)
      , ("M4-r", renameWorkspace myPromptConfig)
      , ("M4-<Delete>", removeEmptyWorkspace)
      ]
      <> M.fromList
      [ ((controlMask, xK_Menu), toggleWS)
      ]

    forkFile :: FilePath -> [String] -> Maybe [(String, String)] -> X ()
    forkFile path args env =
        xfork (executeFile path True args env) >> return ()

    myPromptConfig = def
      { font = "-*-clean-*-*-*-*-*-*-*-*-*-*-iso10646-*"
      }
  '';

  system.userActivationScripts.graphical-session = lib.mkBefore /* sh */ ''
    if ${pkgs.systemd}/bin/systemctl --user is-active --quiet graphical-session.target; then
      ${pkgs.systemd}/bin/systemctl --user start graphical-session.target
    fi
  '';

  users.users.guest = {
    uid = mylib.genid_uint31 "guest";
    isNormalUser = true;
    extraGroups = [
      "audio"
      "video"
      "pipewire"
    ];
  };
}