about summary refs log tree commit diff
path: root/platforms/linux/configuration.nix
blob: a472bb9da3dce6f23e65631df142a38687387b4f (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
# 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, pkgs, ... }:
let
  busybox_utils = pkgs.stdenv.mkDerivation {
    name = "strings";
    unpackPhase = "true";
    installPhase = ''
      mkdir -p $out/bin
      cp ${pkgs.busybox}/bin/strings $out/bin/strings
      cp ${pkgs.busybox}/bin/telnet $out/bin/telnet
    '';
  };
in
{
  nix.useSandbox = true;

  # Add NUR
  nixpkgs.config.packageOverrides = pkgs: {
    nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
      inherit pkgs;
    };
  };

  # NUR cachable
  #nixpkgs.config.packageOverrides = pkgs: {
  #  nur = import (builtins.fetchTarball {
  #    url = "https://github.com/nix-community/NUR/archive/02ba8936dec5010545a97bba41a52a03078a2644.tar.gz";
  #    sha256 = "0ix86b53l9hv5minkjhbydi82n6dc4s700k8pwlm0z5fwlgvhy09";
  #  }) {
  #    inherit pkgs;
  #  };
  #};


  imports =
    [ # Include the results of the hardware scan.
      # <home-manager>/nixos
      ../../modules/dockd.nix
      ../../modules/trackpad.nix
      ../../modules/agetty.nix
      ../../hardware-configuration.nix
    ];

  # Use the GRUB 2 boot loader.
  boot.loader.grub.enable = true;
  boot.loader.grub.version = 2;
  # boot.loader.grub.efiSupport = true;
  # boot.loader.grub.efiInstallAsRemovable = true;
  # boot.loader.efi.efiSysMountPoint = "/boot/efi";
  # Define on which hard drive you want to install Grub.
  boot.loader.grub.device = "/dev/sda"; # or "nodev" for efi only
  boot.plymouth.enable = true;
  boot.binfmt.emulatedSystems = [ "aarch64-linux" ];

  boot.extraModulePackages = with pkgs.linuxPackages; [
    v4l2loopback
    acpi_call
  ];

  boot.kernelModules = [ "v4l2loopback" ];
  boot.extraModprobeConfig = ''
    options v4l2loopback exclusive_caps=1 video_nr=9 card_label="obs"
  '';

  fileSystems = {
    "/home" = {
      device = "/dev/disk/by-label/home";
      fsType = "ext4";
    };
    "/nix" = {
      device = "/dev/disk/by-label/nix";
      fsType = "ext4";
    };
    "/var/lib/docker" = {
      device = "/dev/disk/by-label/docker";
      fsType = "ext4";
    };
    # "/media" = {
    #   device = "/dev/disk/by-label/media";
    #   fsType = "ext4";
    # };
    # "/backup" = {
    #   device = "/dev/disk/by-label/backup";
    #   fsType = "ext4";
    # };
    "/mnt/qnap" = {
      device = "//192.168.1.119/Patryk";
      fsType = "cifs";
      options = let
        # this line prevents hanging on network split
        automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,vers=1.0";

      in ["${automount_opts},credentials=/etc/nixos/smb-secrets"];
    };
  };

  networking = {
    networkmanager = {
     enable = true;
     wifi.backend = "iwd";
    };

    nameservers = [
      "1.1.1.1"
      "8.8.8.8"
    ];
  };

  networking.hostName = "nixos"; # Define your hostname.
  networking.extraHosts = "${ pkgs.stdenv.lib.readFile "${pkgs.fetchurl {
    url = "https://raw.githubusercontent.com/StevenBlack/hosts/5a5016ab5bf0166e004147cb49ccd0114ed29b72/alternates/fakenews-gambling-porn/hosts";
    sha256 = "1c60fyzxz89bic6ymcvb8fcanyxpzr8v2z5vixxr79d8mj0vjswm";
  }}"}";

  # The global useDHCP flag is deprecated, therefore explicitly set to false here.
  # Per-interface useDHCP will be mandatory in the future, so this generated config
  # replicates the default behaviour.
  networking.useDHCP = false;
  #networking.interfaces.enp0s25.useDHCP = true;
  #networking.interfaces.wlp3s0.useDHCP = true;

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Select internationalisation properties.
  # i18n.defaultLocale = "en_US.UTF-8";
  # console = {
  #   font = "Lat2-Terminus16";
  #   keyMap = "us";
  # };

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

  nixpkgs.config = {
    allowUnfree = true;
  };

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    # Basic tools
    stdenv wget vim curl htop dnsutils zip unzip
    zsh neovim ripgrep jq groff file pinentry_gnome
    ssh-ident busybox_utils

    # XORG perfs
    xorg.xorgserver xorg.xf86inputevdev xorg.xf86inputsynaptics xorg.xf86inputlibinput
    xorg.xf86videointel
    noto-fonts-extra dunst xclip
    xwallpaper xdotool

    # UI apps
    zathura brave sxiv pulsemixer
    lynx lf nur.repos.pn.st arandr wpa_supplicant_gui
    system-config-printer libreoffice
    vscodium abook

    # Audio/Video
    mpd mpc_cli mpv ffmpeg youtube-dl

    # CLIs
    lm_sensors
    gitAndTools.gh docker-compose xsel
    bc libnotify
    pamixer maim killall
    quickserve ueberzug chafa

    # Thinkpad utils
    nur.repos.pn.dockd acpi tpacpi-bat

    wineStaging

  ];

  fonts.fonts = with pkgs; [
    roboto-slab
  ];

  # Pure conf
  environment.etc = {
    "zsh/zshenv".text = ''
      export ZDOTDIR=$HOME/.config/zsh
    '';
  };

  environment.variables = {
    XDG_CONFIG_HOME = "$HOME/.config";
    XDG_DATA_HOME = "$HOME/.local/share";
  };

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  programs.gnupg = {
    agent = {
      enable = true;
      enableSSHSupport = true;
      pinentryFlavor = "gnome3";
    };
  };

  programs.zsh = {
    enable = true;
    enableCompletion = true;
    autosuggestions.enable = true;
    histFile = "$XDG_DATA_HOME/zsh/history";

    syntaxHighlighting.enable = true;
  };

  programs.vim.defaultEditor = true;
  programs.slock.enable = true;
  programs.browserpass.enable = true;
  programs.dockd.enable = true;
  programs.adb.enable = true;

  virtualisation.docker.enable = true;
  # virtualisation.anbox.enable = true;

  # List services that you want to enable:

  # services.udev.packages = [
  #   pkgs.android-udev-rules
  # ];
  services.udev.packages = [ pkgs.libu2f-host ];

  services.pcscd.enable = true;

  services.agetty = {
    defaultUser = "pn";
  };

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

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  networking.firewall.enable = false;

  # Enable CUPS to print documents.
  services.printing = {
    enable = true;
    drivers = [ pkgs.epson_201207w ];
  };

  services.cron.enable = true;
  # services.fcron.enable = true;

  services.acpid.enable = true;

  # Battery
  services.tlp.enable = true;

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

  # Enable the X11 windowing system.
  services.xserver.enable = true;
  services.xserver.displayManager.startx.enable = true;
  services.xserver.layout = "pl";
  # services.xserver.xkbOptions = "eurosign:e";

  # Enable touchpad support.
  services.xserver.libinput = {
    enable = true;
    accelSpeed = "0.8";
  };

  # Enable the KDE Desktop Environment.
  #services.xserver.displayManager.sddm.enable = true;
  #services.xserver.desktopManager.plasma5 = {
  #  enable = true;
  #};

  # i3
  #services.xserver.desktopManager.xterm.enable = false;
  #services.xserver.displayManager.defaultSession = "none+i3";
  #services.xserver.windowManager.i3 = {
  #  enable = true;
  #  package = pkgs.i3-gaps;
  #  extraPackages = with pkgs; [
  #    i3status
  #    i3lock
  #    i3blocks
  #  ];
  #};

  # XFCE + i3
  #services.xserver.displayManager.defaultSession = "xfce+i3";
  #services.xserver.desktopManager = {
  #  xterm.enable = false;
  #  xfce = {
  #    enable = true;
  #    noDesktop = true;
  #    enableXfwm = false;
  #  };
  #};
  #services.xserver.windowManager.i3 = {
  #  enable = true;
  #  package = pkgs.i3-gaps;
  #  extraPackages = with pkgs; [
  #    i3status
  #    i3lock
  #    i3blocks
  #  ];
  #};


  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.pn = {
    isNormalUser = true;
    extraGroups = [ "wheel" "video" "docker" "adbusers" "scanner" "lp" ]; # Enable ‘sudo’ for the user.
  };

  users.defaultUserShell = "/run/current-system/sw/bin/zsh";
  security.sudo.wheelNeedsPassword = false;

  security.pam.u2f = {
    enable = true;
    cue = 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 = "20.09"; # Did you read the comment?

}