about summary refs log tree commit diff
path: root/nix/hosts/hacknix/configuration.nix
blob: 388626cc3e17bc63507d6619bae23edbc6c48710 (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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# Edit ths 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’).

{
  nixpkgs,
  nixpkgs-unstable,
  config,
  lib,
  pkgs,
  ...
}:

let
  burppro = pkgs.callPackage ./burpsuitepro {
    inherit pkgs;
    nixpkgs = pkgs;
  };
in
# TODO: pull licence from git
{
  imports = [
    # Include the results of the hardware scan.
    ./hardware-configuration.nix
    ./overlay
  ];

  nixpkgs = {
    config.allowUnfree = true; # for virtualisation.virtualbox
  };

  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  networking.hostName = "hacknix";

  # Set your time zone.
  time.timeZone = "Europe/Berlin";

  i18n.defaultLocale = "en_US.UTF-8";

  # fileSystems."/home/hack/Documents/datapool.lan" = {
  #   device = "datapool.lan:/mnt/data/dump";
  #   fsType = "nfs";
  # };

  services = {
    dbus.enable = true;
    xserver = {
      enable = true;

      # Keyboard settings
      layout = "us";
      xkbOptions = "caps:compose";

      desktopManager = {
        xterm.enable = false;

        # we don't use the xfce interface, only the fancy desktopManager
        # settings and the session
        xfce = {
          enable = true;
          noDesktop = true;
          enableXfwm = false;
        };
      };

      # default display manager when logging in
      displayManager = {
        defaultSession = "xfce+i3";
        sessionCommands = '''';
      };

      windowManager.i3 = {
        enable = true;
        configFile = "/etc/i3.conf"; # see environment.etc."i3.conf".text
        extraPackages = with pkgs; [
          dmenu
          i3status
          i3blocks
        ];
      };
    };
  };

  environment.etc."i3.conf".text = pkgs.callPackage ./i3-config.nix { };

  # Enable CUPS to print documents.
  # services.printing.enable = true;

  # Enable sound.
  # sound.enable = true;
  # hardware.pulseaudio.enable = true;
  hardware.opengl.enable = true;

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  users.users.hack = {
    isNormalUser = true;
    extraGroups = [
      "wheel" # Enable ‘sudo’ for the user.
      "vboxsf" # Allow access to the shared /pentest folder mounted in via virtualbox
      "docker" # access to the docker socket
    ];
    shell = pkgs.zsh;
  };

  environment = {
    shellAliases = {
      #ls = "lsd";
      ls = "eza";
    };
    systemPackages =
      with pkgs;
      [
        unstable.obsidian

        kitty

        # editors
        vim

        helix
        marksman # markdown lsp
        cuelsp # cue lsp
        terraform-lsp
        terraform-ls # terraform lsp
        # rnix-lsp # nix lsp (CVE-2024-27297, that's why it's commented!)

        # command line tools
        fd
        ripgrep
        htop
        fzf
        jq
        eza
        lsd
        du-dust
        pwgen

        # x11 foo
        arandr
        feh

        # shell
        zsh
        oh-my-zsh

        # browser
        chromium
        firefox

        # programming languages
        go
        gopls # (Official language server for the Go language)
        go-outline # (Utility to extract JSON representation of declarations from a Go source file)
        go-tools # staticcheck (A collection of tools and libraries for working with Go code, including linters and static analysis)
        gocode-gomod # (An autocompletion daemon for the Go programming language)
        gotest # (go test with colors)
        gotests # (Generate Go tests from your source code)
        gomodifytags # (Go tool to modify struct field tags)
        impl # (Generate method stubs for implementing an interface)
        delve # dlv (debugger for the Go programming language)

        (pkgs.python3.withPackages (
          ps: with ps; [
            pwntools
            requests
            tqdm
            beautifulsoup4
            mitmproxy

            (buildPythonPackage rec {
              pname = "pandoc";
              version = "2.3";
              src = fetchPypi {
                inherit pname version;
                sha256 = "sha256-53LCxthxFGiUV5go268e/VOOtk/H5x1KazoRoYuu+Q0=";
              };
              doCheck = false;
              propagatedBuildInputs = [
                # pkgs.python310Packages.ply
                # pkgs.python310Packages.plumbum
                # Specify dependencies
                #pkgs.python3Packages.numpy
              ];
            })
          ]
        ))

        # dev
        vscode
        docker-compose

        # analysis
        binwalk
        file

        # communication
        element-desktop

        # view pdfs
        zathura
        okular

        # infra 
        cue
        cuetools

        #radare2
        # r2
        capstone # Advanced disassembly library
        keystone # Lightweight multi-platform, multi-architecture assembler framework
        unicorn # Lightweight multi-platform CPU emulator library

        # hashicorp stuff
        # vault vault-bin vaultenv vault-medusa
        # nomad_1_4
        # consul
        # terraform

        #unstable.mitmproxy
        #mitmproxy_bs4

        dex
        xss-lock
        networkmanagerapplet

        p7zip
        m4

        libreoffice

        pandoc
        tmux

        python311Packages.python-lsp-server
      ]
      ++ [ burppro ];
  };

  fonts.packages = with pkgs; [
    ubuntu_font_family # the font used in the "Sogeti" logo
    #nerdfonts
    #font-awesome
    #powerline-fonts
  ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  programs = {

    vim.defaultEditor = true;

    htop = {
      enable = true;
      settings = {
        hide_kernel_threads = true;
      };
    };

    #fish.enable = true;
    zsh = {
      enable = true;
      syntaxHighlighting = {
        enable = true;
      };
      ohMyZsh = {
        enable = true;
        plugins = [ "nmap" ];
      };

      # this par in ~/.zshrc:
      # 
      # PROMPT="; "
      # RPROMPT="%F{green}%/%F{reset}"
      # ZSH_THEME=
      # PATH=$PATH:/home/hack/.cargo/bin
    };

    chromium = {
      enable = true;
      homepageLocation = "https://emile.space";
      extraOpts = {
        "ClientCertificateManagementAllowed" = 0;
      };
    };

    git = {
      enable = true;
      config = {
        core.editor = "vim";
        user = {
          name = "Emile Hansmaennel";
          email = "git@emile.space";
        };
      };
    };
  };

  # virtualbox guest additions
  virtualisation.virtualbox.guest.enable = true;

  nix = {
    settings.experimental-features = [
      "nix-command"
      "flakes"
    ];

    gc = {
      automatic = true;
      dates = "12:00"; # daily, docs on format in `man 7 systemd.time`
      persistent = true;
    };

    settings = {
      substituters = [
        "https://nix-community.cachix.org"
        "https://cache.nixos.org/"
      ];
      trusted-public-keys = [
        "nixbinarycache.lan:JDjlVLc+5VUKOtFAFBGCDtlgVpLEaaR2JdTw2mQUIb8="
        "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
      ];
    };
  };

  # security.pki.certificates = [
  #   # office.lan
  #   ''
  #   ''
  # ];

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  networking = {
    nameservers = [
      "192.168.1.1"
      #"8.8.8.8"
    ];

    hosts = {
      # 127.0.0.1 localhost
      # ::1 localhost
    };

    firewall = {
      enable = true;

      # open further TCP and/or UDP ports in the firewall
      allowedTCPPorts = [
        80
        443
        8123
        8080
      ];
      #allowedUDPPorts = [ 53 ];
    };

    wg-quick.interfaces = {
      "wg0" = {
        address = [
          "10.10.10.12/24" # our IP
        ];
        dns = [ "192.168.1.1" ];
        mtu = 1380;
        listenPort = 51820;

        # TODO: add private key to repo using agenix, then link here
        privateKeyFile = "/etc/wireguard/private_key";

        peers = [
          {
            publicKey = "9+4OWuqZ0rZsi/oaaXd3YhE1p+Z0tbxwfNbcDnVqRxg=";
            allowedIPs = [ "0.0.0.0/0" ];
            endpoint = "PUBLIC_IP:51820";
            persistentKeepalive = 25;
          }
        ];
      };
    };
  };

  virtualisation.docker.enable = true;

  # Copy the NixOS configuration file and link it from the resulting system
  # (/run/current-system/configuration.nix). This is useful in case you
  # accidentally delete configuration.nix.
  # system.copySystemConfiguration = true;

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "22.11"; # Did you read the comment?
}