summaryrefslogtreecommitdiff
path: root/nix/configuration.nix
blob: a9c0830bc0843d2c471026ded69285ff9a0055dc (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
# 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, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
       <nixos-hardware/lenovo/thinkpad/x200s>
       <home-manager/nixos>
       
    ];

  nix = {
    package = pkgs.nixUnstable;
    extraOptions = ''
      experimental-features = nix-command flakes
    '';
  };
  
  # Bootloader
  boot.kernelPackages = pkgs.linuxPackages_latest;
  boot.loader.grub.enable = true;
  boot.loader.grub.device = "/dev/sdb";
  boot.loader.grub.useOSProber = true;
  boot.kernel.sysctl = { "net.ipv4.ip_forward" = 1; };

  networking.hostName = "nixos"; # Define your hostname.
  #networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

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

  # Enable networking
  networking.networkmanager.enable = true;

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

  fonts.fonts = with pkgs; [
    unifont
    dejavu_fonts
  ];

  fonts.fontDir.enable = true;

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

  services.lorri.enable = true;

  # Configure keymap in X11
  services.xserver = {
    enable = true;
    layout = "us,ru";
    xkbOptions = "grp:shifts_toggle,caps:ctrl_modifier";
    videoDrivers = [ "intel" ];

    windowManager.ratpoison.enable = true;
    displayManager.startx.enable = true;
    displayManager.defaultSession = "none+ratpoison";
  };

  powerManagement = {
    enable = true;
    cpuFreqGovernor = "ondemand";
  };

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.w96k = {
    isNormalUser = true;
    description = "Mikhail Kirillov";
    extraGroups = [ "networkmanager" "wheel" "audio" "docker" "libvirtd"];
  };

  nix.trustedUsers = [ "root" "w96k" ];

  home-manager.useGlobalPkgs = true;

  home-manager.users.w96k = { pkgs, ... }: {
    home.stateVersion = "22.05";
    home.packages = [
    pkgs.gparted
    pkgs.python3
    pkgs.nodejs
    # pkgs.php81
    # # Minimal requirements for symfony
    # pkgs.php81Extensions.redis
    # pkgs.php81Extensions.amqp
    # pkgs.php81Extensions.xsl
    pkgs.php81Packages.psysh
    pkgs.gimp
    pkgs.php81Packages.composer
    pkgs.direnv
    pkgs.openjdk17
    pkgs.firefox
    pkgs.tdesktop
    pkgs.imagemagick
    pkgs.arandr
    pkgs.symfony-cli
    pkgs.shellcheck
    pkgs.gnome.gnome-boxes
    pkgs.cachix
    pkgs.tor-browser-bundle-bin
    pkgs.htop
    pkgs.ghc
    pkgs.nix-prefetch-scripts
    pkgs.libreoffice
    pkgs.mpv
    pkgs.musescore
    pkgs.yarn
    pkgs.postgresql
    pkgs.unzip
    pkgs.sloc
    ];

    programs.git = {
      enable = true;
      userName = "Mikhail Kirillov";
      userEmail = "w96k.ru@gmail.com";
    };
    programs.autorandr.enable = true;
    programs.direnv.enable = true;
    programs.direnv.nix-direnv.enable = true;
    programs.bash.enable = true;
    programs.emacs = {
      enable = true;
      extraPackages = epkgs: with epkgs; [
      flycheck
      avy
      anaconda-mode
      auctex
      beginend
      composer
      cinspect
      debian-el
      dpkg-dev-el
      edebug-inline-result
      magit
      git-dwim
      gitpatch
      goto-chg
      debbugs
      direnv
      docker
      docker-cli
      docker-tramp
      mastodon
      exec-path-from-shell
      expand-region
      geiser
      geiser-guile
      guix
      gnuplot
      isearch-mb
      minibuffer-line
      org-roam
      org-roam-ui
      org-download
      org-babel-eval-in-repl
      on-screen
      pdf-tools
      lsp-mode
      lsp-java
      company
      company-quickhelp
      # ac-php
      # php-mode
      # php-quickhelp
      phan
      php-cs-fixer
      # company-php
      # php-eldoc
      realgud
      kiwix
      slime
      simple-httpd
      sudo-edit
      imenu-list
      telega
      mini-frame
      mini-modeline
      undo-tree
      yasnippet
      yasnippet-snippets
      vimrc-mode
      no-littering
      web-mode
      reverse-im
      restclient
      # php-scratch
      yaml-mode
      php-quickhelp
      nix-mode
    ];
};
  };

  # nixpkgs.config.allowUnfree = true;
  # Nixos optimizations for thinkpadg
  # nixpkgs.localSystem = {
  #   system = "x86_64-linux";
  #   gcc.arch = "core2";
  #   gcc.tune = "core2";
  # };

  # Enable sound
  sound.enable = true;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
  wget
  lm_sensors
  emacs28NativeComp
  nix-tree
  xorg.xf86inputevdev
  xorg.xf86videointel
  xorg.xorgserver
  xorg.xinit
  thinkfan
  home-manager
  neofetch
  git
  wmname
  docker-compose
  niv

  (pkgs.php81.buildEnv {
    extensions = ({ enabled, all }: enabled ++ (with all; [
      xdebug
      amqp
      redis
      xsl
    ]));
    extraConfig = ''
      xdebug.mode=debug
    '';
  })
  ];

  services.emacs.package = pkgs.emacs28NativeComp;
  services.emacs.defaultEditor = true;

  # services.postgresql = {
  #   enable = true;
  #   package = pkgs.postgresql_14;
  #   enableTCPIP = true;
  #   authentication = pkgs.lib.mkOverride 10 ''
  #     local all all trust
  #     host all all 127.0.0.1/32 trust
  #     host all all ::1/128 trust
  #   '';
  #   initialScript = pkgs.writeText "backend-initScript" ''
  #     CREATE ROLE w96k WITH LOGIN PASSWORD 'w96k' CREATEDB;
  #     CREATE DATABASE symfony;
  #     GRANT ALL PRIVILEGES ON DATABASE symfony TO w96k;
  #   '';
  # };

  services.tor.settings = {
      UseBridges = true;
      ClientTransportPlugin = "obfs4 exec ${pkgs.obfs4}/bin/obfs4proxy";
      Bridge = "obfs4 IP:ORPort [fingerprint]";
  };

  services.tor.client.enable = true;

  virtualisation.docker = {
    enable = true;
    enableOnBoot = true;
    # autoPrune.enable = true;
  };

  virtualisation.libvirtd.enable = true;

  systemd.mounts = [
  { what = "/dev/sda2";
    where = "/mnt/guix";
    mountConfig = {
      TimeoutSec = "1";
      Options = "uid=c184f446-df67-4103-b28e-465ac8776f10";
    };
  }
  ];

  # 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;
  };

  nix.autoOptimiseStore = true;
  nix.gc = {
    automatic = true;
    dates = "weekly";
    options = "--delete-older-than 60d";
  };

  # List services that you want to enable:

  # 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;

  # 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 leavecatenate(variables, "bootdev", bootdev)
  # 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.05"; # Did you read the comment?
}