]> gitweb.ps.run Git - flake_server/blob - configuration.nix
08c1921c2b35f0a46b5bb73ccd7a5f82132d971f
[flake_server] / configuration.nix
1 # Edit this configuration file to define what should be installed on
2 # your system. Help is available in the configuration.nix(5) man page, on
3 # https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
4
5 { config, lib, pkgs, chirp, ... }:
6
7 {
8   imports =
9     [ # Include the results of the hardware scan.
10       ./hardware-configuration.nix
11     ];
12
13   # Use the GRUB 2 boot loader.
14   boot.loader.systemd-boot.enable = true;
15   # boot.loader.grub.efiSupport = true;
16   # boot.loader.grub.efiInstallAsRemovable = true;
17   # boot.loader.efi.efiSysMountPoint = "/boot/efi";
18   # Define on which hard drive you want to install Grub.
19   # boot.loader.grub.device = "/dev/sda"; # or "nodev" for efi only
20
21   nix.settings.experimental-features = [ "nix-command" "flakes" ];
22   nix.package = pkgs.nixVersions.nix_2_28;
23
24   nix.gc = {
25     automatic = true;
26     options = "--delete-older-than 30d";
27   };
28   nix.optimise.automatic = true;
29   system.autoUpgrade = {
30     enable = true;
31     allowReboot = true;
32   };
33
34   networking.hostName = "pschdev"; # Define your hostname.
35   # Pick only one of the below networking options.
36   # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.
37   # networking.networkmanager.enable = true;  # Easiest to use and most distros use this by default.
38
39   networking.firewall = {
40     enable = true;
41     allowedTCPPorts = [ 80 443 9418 ];
42   };
43
44   # Set your time zone.
45   time.timeZone = "Europe/Amsterdam";
46
47   # Configure network proxy if necessary
48   # networking.proxy.default = "http://user:password@proxy:port/";
49   # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
50
51   # Select internationalisation properties.
52   i18n.defaultLocale = "de_DE.UTF-8";
53   console = {
54     font = "Lat2-Terminus16";
55     keyMap = "de-latin1-nodeadkeys";
56     # useXkbConfig = true; # use xkb.options in tty.
57   };
58
59   # Enable the X11 windowing system.
60   # services.xserver.enable = true;
61
62   # Configure keymap in X11
63   # services.xserver.xkb.layout = "us";
64   # services.xserver.xkb.options = "eurosign:e,caps:escape";
65
66   # Enable CUPS to print documents.
67   # services.printing.enable = true;
68
69   # Enable sound.
70   # hardware.pulseaudio.enable = true;
71   # OR
72   # services.pipewire = {
73   #   enable = true;
74   #   pulse.enable = true;
75   # };
76
77   # Enable touchpad support (enabled default in most desktopManager).
78   # services.libinput.enable = true;
79
80   # Define a user account. Don't forget to set a password with ‘passwd’.
81   users.users.ps = {
82     isNormalUser = true;
83     extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
84     packages = with pkgs; [
85     ];
86   };
87
88   security = {
89     polkit.enable = true;
90     sudo.wheelNeedsPassword = false;
91   };
92
93   # nixpkgs.config.allowUnfree = true;
94
95   # List packages installed in system profile. To search, run:
96   # $ nix search wget
97   environment.systemPackages = with pkgs; [
98     vim wget file git fzf bat
99     helix
100     gitui
101     bintools
102     btop htop
103     systemctl-tui
104     tmux
105     md4c
106
107     pkg-config
108   ];
109
110   # git
111   users.users.git = {
112     isSystemUser = true;
113     group = "git";
114     home = "/srv/git";
115     createHome = true;
116     homeMode = "750";
117     shell = "${pkgs.git}/bin/git-shell";
118     openssh.authorizedKeys.keys = [
119       "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICQOPefMnq0qvFjYxlrdlSmUgyCbvV85gkfRykVlTnrn ps@nixos"
120     ];
121   };
122   users.groups.git = {};
123
124   programs.git = {
125     enable = true;
126     config = {
127       init.defaultBranch = "main";
128       user.name = "Patrick";
129       user.email = "patrick.schoenberger@posteo.de";
130     };
131   };
132
133   # Some programs need SUID wrappers, can be configured further or are
134   # started in user sessions.
135   # programs.mtr.enable = true;
136   # programs.gnupg.agent = {
137   #   enable = true;
138   #   enableSSHSupport = true;
139   # };
140
141   # List services that you want to enable:
142
143   # Enable the OpenSSH daemon.
144   services.openssh = {
145     enable = true;
146     extraConfig = ''
147       Match user git
148         AllowTcpForwarding no
149         AllowAgentForwarding no
150         PasswordAuthentication no
151         PermitTTY no
152         X11Forwarding no
153     '';
154   };
155   services.qemuGuest.enable = true;
156   # virtualisation.qemu.guestAgent.enable = true;
157
158   services.caddy = {
159     enable = true;
160     virtualHosts."psch.dev".extraConfig = ''
161       respond "hello :D"
162     '';
163     virtualHosts."chirp.psch.dev".extraConfig = ''
164       reverse_proxy http://localhost:8080 {
165         request_buffers 8192
166       }
167       tls {
168         protocols tls1.3 tls1.3
169       }
170     '';
171     virtualHosts."git.psch.dev".extraConfig = ''
172       redir / /cgit
173       reverse_proxy localhost:8082
174     '';
175   };
176
177   # services.chirp = {
178   #   enable = true;
179   # };
180   users.users.chirp = {
181     isSystemUser = true;
182     group = "chirp";
183     home = "/var/lib/chirp";
184     createHome = true;
185   };
186   users.groups.chirp = {};
187   
188   systemd.services.chirp = {
189     description = "Chirp SystemD Service";
190     wantedBy = ["multi-user.target"];
191     after = ["network.target"];
192     serviceConfig = {
193       WorkingDirectory = "/var/lib/chirp";
194       ExecStart = "${chirp.packages.${pkgs.system}.default}/bin/chirp";
195       Restart = "always";
196       Type = "simple";
197       User = "chirp";
198       Group = "chirp";
199     };
200   };
201
202   services.gitDaemon = {
203     enable = true;
204     basePath = "/srv/git";
205     repositories = [ "/srv/git" ];
206     exportAll = true;
207     port = 9418;
208   };
209
210   services.lighttpd = {
211     enable = true;
212     document-root = "/srv/www";
213     port = 8082;
214
215     cgit = {
216       enable = true;
217       subdir = "cgit";
218       configText = ''
219         scan-path=/srv/git
220         robots=noindex, nofollow
221         readme=:readme.md
222         about-filter=${pkgs.writeShellScript "markdown" ''
223           ${pkgs.md4c}/bin/md2html --github --ftables
224         ''}
225       '';
226     };
227     gitweb.enable = true;
228   };
229   users.users."lighttpd".extraGroups = [ "git" ];
230
231   services.gitweb = {
232     gitwebTheme = false;
233     projectroot = "/srv/git";
234   };
235
236   # Open ports in the firewall.
237   # networking.firewall.allowedTCPPorts = [ ... ];
238   # networking.firewall.allowedUDPPorts = [ ... ];
239   # Or disable the firewall altogether.
240   # networking.firewall.enable = false;
241
242   # Copy the NixOS configuration file and link it from the resulting system
243   # (/run/current-system/configuration.nix). This is useful in case you
244   # accidentally delete configuration.nix.
245   # system.copySystemConfiguration = true;
246
247   # This option defines the first version of NixOS you have installed on this particular machine,
248   # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
249   #
250   # Most users should NEVER change this value after the initial install, for any reason,
251   # even if you've upgraded your system to a new NixOS release.
252   #
253   # This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
254   # so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
255   # to actually do that.
256   #
257   # This value being lower than the current NixOS release does NOT mean your system is
258   # out of date, out of support, or vulnerable.
259   #
260   # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
261   # and migrated your data accordingly.
262   #
263   # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
264   system.stateVersion = "24.05"; # Did you read the comment?
265
266 }
267