summaryrefslogtreecommitdiffstats
path: root/makefu/1systems/shack-autoinstall/shack-config.nix
blob: 9fa54ae3280256582690a64bbeddcf4f95960bad (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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
{ config, pkgs, lib, ... }:

{
  imports = [
    ./hardware-configuration.nix
    # TODO:
  ];

  # shacks-specific
  networking.wireless = {
    enable = true;
    networks.shack.psk = "181471eb97eb23f12c6871227bc4a7b13c8f6af56dcc0d0e8b71f4d7a510cb4e";
  };
  networking.hostName = "shackbook";

  boot.tmpOnTmpfs = true;

  users.users.shack = {
    createHome = true;
    useDefaultShell = true;
    home = "/home/shack";
    uid = 9001;
    packages = with pkgs;[
      chromium
      firefox
    ];
    extraGroups = [ "audio" "wheel"  ];
    hashedPassword = "$6$KIxlQTLEnKl7cwC$LrmbwZ64Mlm7zqUUZ0EObPJMES3C0mQ6Sw7ynTuXzUo7d9EWg/k5XCGkDHMFvL/Pz19Awcv0knHB1j3dHT6fh/" ;
  };

  environment.variables = let
    ca-bundle = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
  in {
    EDITOR = lib.mkForce "vim";
    CURL_CA_BUNDLE = ca-bundle;
    GIT_SSL_CAINFO = ca-bundle;
    SSL_CERT_FILE  = ca-bundle;
  };

  services.printing = {
    enable = true;
    # TODO: shack-printer
  };


  environment.systemPackages = with pkgs;[
    parted
    ddrescue
    tmux
    jq git gnumake htop rxvt_unicode.terminfo
    (pkgs.vim_configurable.customize {
      name = "vim";
      vimrcConfig.customRC = ''
      set nocompatible
      syntax on
      set list
      set listchars=tab:▸\ 
      "set list listchars=tab:>-,trail:.,extends:>

      filetype off
      filetype plugin indent on

      colorscheme darkblue
      set background=dark

      set number
      set relativenumber
      set mouse=a
      set ignorecase
      set incsearch
      set wildignore=*.o,*.obj,*.bak,*.exe,*.os
      set textwidth=79
      set shiftwidth=2
      set expandtab
      set softtabstop=2
      set shiftround
      set smarttab
      set tabstop=2
      set et
      set autoindent
      set backspace=indent,eol,start


      inoremap <F1> <ESC>
      nnoremap <F1> <ESC>
      vnoremap <F1> <ESC>

      nnoremap <F5> :UndotreeToggle<CR>
      set undodir  =~/.vim/undo
      set undofile
      "maximum number of changes that can be undone
      set undolevels=1000000
      "maximum number lines to save for undo on a buffer reload
      set undoreload=10000000

      nnoremap <F2> :set invpaste paste?<CR>
      set pastetoggle=<F2>
      set showmode

      set showmatch
      set matchtime=3
      set hlsearch

      autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red


      " save on focus lost
      au FocusLost * :wa

      autocmd BufRead *.json set filetype=json
      au  BufNewFile,BufRead *.mustache set syntax=mustache

      cnoremap SudoWrite w !sudo tee > /dev/null %

      " create Backup/tmp/undo dirs
      set backupdir=~/.vim/backup
      set directory=~/.vim/tmp

      function! InitBackupDir()
        let l:parent = $HOME    . '/.vim/'
        let l:backup = l:parent . 'backup/'
        let l:tmpdir = l:parent . 'tmp/'
        let l:undodir= l:parent . 'undo/'


        if !isdirectory(l:parent)
          call mkdir(l:parent)
        endif
        if !isdirectory(l:backup)
          call mkdir(l:backup)
        endif
        if !isdirectory(l:tmpdir)
          call mkdir(l:tmpdir)
        endif
        if !isdirectory(l:undodir)
          call mkdir(l:undodir)
        endif
      endfunction
      call InitBackupDir()

      augroup Binary
        " edit binaries in xxd-output, xxd is part of vim
        au!
        au BufReadPre  *.bin let &bin=1
        au BufReadPost *.bin if &bin | %!xxd
        au BufReadPost *.bin set ft=xxd | endif
        au BufWritePre *.bin if &bin | %!xxd -r
        au BufWritePre *.bin endif
        au BufWritePost *.bin if &bin | %!xxd
        au BufWritePost *.bin set nomod | endif
      augroup END
      '';
      vimrcConfig.vam.knownPlugins = pkgs.vimPlugins;
      vimrcConfig.vam.pluginDictionaries = [
        { names = [ "undotree" ]; }
        # vim-nix handles indentation better but does not perform sanity
        { names = [ "vim-addon-nix" ]; ft_regex = "^nix\$"; }
      ];
    })

  ];
  programs.bash = {
    enableCompletion = true;
    interactiveShellInit = ''
      HISTCONTROL='erasedups:ignorespace'
      HISTSIZE=900001
      HISTFILESIZE=$HISTSIZE
      shopt -s checkhash
      shopt -s histappend histreedit histverify
      shopt -s no_empty_cmd_completion
      PS1='\[\e[1;32m\]\w\[\e[0m\] '
    '';
  };

  services.journald.extraConfig = ''
    SystemMaxUse=1G
    RuntimeMaxUse=128M
  '';
  nix = {
    package = pkgs.nixUnstable;
    optimise.automatic = true;
    useSandbox = true;
    gc.automatic = true;
  };

  system.autoUpgrade.enable = true;

  boot.loader.grub.enable = true;
  boot.loader.grub.version = 2;
  boot.loader.grub.device = "/dev/sda";
  fileSystems."/".options = [ "noatime" "nodiratime" "discard" ];


  # gui and stuff
  i18n = {
    consoleFont = "Lat2-Terminus16";
    consoleKeyMap = "us";
    defaultLocale = "en_US.UTF-8";
  };

  fonts = {
    enableFontDir = true;
    enableGhostscriptFonts = true;
    fonts = [ pkgs.terminus_font ];
  };

  time.timeZone = "Europe/Berlin";
  services.timesyncd.enable = true;


  # GUI
  hardware.pulseaudio.enable = true;
  services.xserver = {
    enable = true;
    displayManager.auto.enable = true;
    displayManager.auto.user = "shack";

    desktopManager.xfce.enable = true;

    layout = "us";
    xkbVariant = "altgr-intl";
    xkbOptions = "ctrl:nocaps, eurosign:e";
  };

  services.openssh = {
    enable = true;
    hostKeys = [
      { bits = 8192; type = "ed25519"; path = "/etc/ssh/ssh_host_ed25519_key"; }
    ];
  };
}