diff options
author | Nicholas Van Doorn <vandoorn.nick@gmail.com> | 2021-08-16 01:20:46 -0700 |
---|---|---|
committer | Nick Van Doorn <nick@nv.delivery> | 2022-07-04 14:12:27 -0700 |
commit | 426f5c1a45808cda1fc615bb19571bd4f03bd0c6 (patch) | |
tree | c12a6c3e7aeb57deabfb42054c6f9a3e8c8fbf35 |
Initial commit
-rw-r--r-- | configuration.nix | 336 | ||||
-rw-r--r-- | hardware-configuration.nix | 46 | ||||
-rw-r--r-- | nodejs.nix | 36 |
3 files changed, 418 insertions, 0 deletions
diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..8ba625d --- /dev/null +++ b/configuration.nix @@ -0,0 +1,336 @@ +# 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 + ./cgit.nix + ]; + services.xserver.videoDrivers = [ "nvidia" ]; + hardware.opengl.enable = true; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "vandoorn-server"; # Define your hostname. + networking.hostId = "0f647db6"; + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Set your time zone. + time.timeZone = "America/Pacific"; + + # 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.enp6s0.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"; + # }; + + # Enable the X11 windowing system. + # services.xserver.enable = true; + + # Configure keymap in X11 + # services.xserver.layout = "us"; + # services.xserver.xkbOptions = "eurosign:e"; + + # Enable CUPS to print documents. + # services.printing.enable = true; + + # Enable sound. + # sound.enable = true; + # hardware.pulseaudio.enable = true; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.nick = { + isNormalUser = true; + extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + }; + + users.users.peter = { + isNormalUser = true; + }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + tailscale + python3 + wget + telnet + vim + flac + lame + imagemagick + neofetch + ffmpeg + htop + parted + tree + firefox + smartmontools + config.services.samba.package + git + unzip + nodejs-14_x + libstdcxx5 + cgit + rclone + ]; + + # 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; + # }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + + networking.firewall.enable = true; + networking.firewall.allowedTCPPorts = [ + 548 + 6789 + 8989 + 5050 + 8112 + 2049 + 445 + 139 + 8096 + 7878 + 6595 + 80 + 443 + ]; + networking.firewall.allowedUDPPorts = [ 137 138 ]; + networking.firewall.allowPing = true; + + services = { + netatalk = { + enable = true; + + volumes = { + "home" = { + path = "/mnt/cluster1/home"; + "valid users" = "nick"; + }; + "media0" = { + path = "/mnt/cluster0/media"; + "valid users" = "nick"; + }; + "media1" = { + path = "/mnt/cluster1/media"; + "valid users" = "nick"; + }; + + }; + }; + + avahi = { + enable = true; + nssmdns = true; + + publish = { + enable = true; + userServices = true; + }; + }; + }; + + services.samba = { + enable = true; + securityType = "user"; + extraConfig = '' + server role = standalone server + workgroup = WORKGROUP + server string = vandoorn-server + netbios name = vandoorn-server + security = user + guest account = nobody + map to guest = bad user + wide links = yes + unix extensions = no + follow symlinks = yes + ''; + shares = { + media0 = { + path = "/mnt/cluster0/media"; + browseable = "yes"; + "valid users" = "nick"; + "read only" = "no"; + "guest ok" = "no"; + "create mask" = "0644"; + "directory mask" = "0755"; + }; + cache = { + path = "/mnt/cache"; + browseable = "yes"; + "valid users" = "nick"; + "read only" = "no"; + "guest ok" = "no"; + "create mask" = "0644"; + "directory mask" = "0755"; + }; + media1 = { + path = "/mnt/cluster1/media"; + browseable = "yes"; + "valid users" = "nick"; + "read only" = "no"; + "guest ok" = "no"; + "create mask" = "0644"; + "directory mask" = "0755"; + }; + home = { + path = "/mnt/cluster1/home"; + browseable = "yes"; + "valid users" = "nick"; + "read only" = "no"; + "guest ok" = "no"; + "create mask" = "0644"; + "directory mask" = "0755"; + }; + family = { + path = "/mnt/cluster1/family"; + browseable = "yes"; + "valid users" = "nick peter"; + "read only" = "yes"; + "guest ok" = "no"; + "create mask" = "0644"; + "directory mask" = "0755"; + + }; + }; + }; + services.nfs.server.enable = true; + services.tailscale.enable = true; + + fileSystems."/export/media1" = { + device = "/mnt/cluster1/media"; + options = [ "bind" ]; + }; + fileSystems."/export/media0" = { + device = "/mnt/cluster0/media"; + options = [ "bind" ]; + }; + fileSystems."/export/home" = { + device = "/mnt/cluster1/home"; + options = [ "bind" ]; + }; + services.nfs.server.exports = '' + /export 192.168.2.0/24(insecure,rw,sync,no_subtree_check,crossmnt,fsid=0) + /export/media0 192.168.2.0/24(insecure,rw,sync,no_subtree_check) + /export/media1 192.168.2.0/24(insecure,rw,sync,no_subtree_check) + /export/home 192.168.2.0/24(insecure,rw,sync,no_subtree_check) + ''; + + services.postfix = { + enable = true; + + rootAlias = "vandoorn.nick@gmail.com"; + }; + + services.smartd = { + enable = true; + autodetect = true; + notifications = { + mail = { + enable = true; + }; + test = true; + }; + }; + + users.groups.media.members = [ + "deluge" + "sonarr" + "radarr" + "nzbget" + "nick" + ]; + users.groups.family.members = [ + "nick" + "peter" + ]; + + services.nzbget.enable = true; + services.nzbget.group = "media"; + + services.deluge.enable = true; + services.deluge.group = "media"; + services.deluge.web.enable = true; + + services.sonarr.enable = true; + services.sonarr.group = "media"; + + services.radarr.enable = true; + services.radarr.group = "media"; + + services.jellyfin.enable = true; + services.plex = { + enable = true; + openFirewall = true; + }; + + systemd.services.deemix = { + script = '' + /home/nick/node/bin/node /home/nick/deemix-gui/server/dist/app.js --host 0.0.0.0 + ''; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + User = "root"; + Group = "media"; + }; + }; + + services.fcgiwrap.enable = true; + services.nginx.enable = true; + security.acme.email = "vandoorn.nick@gmail.com"; + security.acme.acceptTerms = true; + services.nginx.virtualHosts."localhost" = { + cgit = { + enable = true; + virtual-root = "/"; + scan-path = "/srv/git"; + root-title = "nvd-git"; + root-desc = "Nicholas Van Doorn's home Git server"; + include = [ + (builtins.toFile "cgitrc-extra-2" '' + enable-http-clone=1 + '') + ]; + }; + }; + + + nixpkgs.config.allowUnfree = 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? +} diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..a7e0b1d --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,46 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "ehci_pci" "ata_piix" "xhci_pci" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/4ff8487c-9ef9-4071-9296-a982245c579e"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/D02A-D9BE"; + fsType = "vfat"; + }; + + fileSystems."/mnt/cluster0" = + { device = "/dev/disk/by-uuid/88e3ad6d-75c8-480c-9d55-ab31b8ccdd5e"; + fsType = "ext4"; + }; + + fileSystems."/mnt/cluster1" = + { device = "/dev/disk/by-uuid/582c8c85-6497-4cff-8398-104199d1ba8c"; + fsType = "ext4"; + }; + + fileSystems."/mnt/cache" = + { device = "/dev/disk/by-uuid/a1d6d1d9-2dd1-4d3e-8f21-8de30f072dca"; + fsType = "ext4"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/a30f1323-570f-4cd6-8acd-d7428e9327d3"; } + ]; + + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; +} diff --git a/nodejs.nix b/nodejs.nix new file mode 100644 index 0000000..71e8d04 --- /dev/null +++ b/nodejs.nix @@ -0,0 +1,36 @@ +{ pkgs ? import <nixpkgs> {}, version, sha256 }: + + let + inherit (pkgs) stdenv autoPatchelfHook platforms fetchurl; + inherit (stdenv) mkDerivation lib; + + in mkDerivation { + inherit version; + + name = "nodejs-${version}"; + + src = fetchurl { + url = "https://nodejs.org/dist/v${version}/node-v${version}-linux-x64.tar.xz"; + inherit sha256; + }; + + # QUESTION: put glib and autoPatchelfHook in nativeBuildInputs or buildInputs? + nativeBuildInputs = with pkgs; [autoPatchelfHook]; + buildInputs = with pkgs; [glib]; + + installPhase = '' + echo "joe is installing nodejs" + mkdir -p $out + cp -R ./ $out/ + ''; + + meta = { + description = "Event-driven I/O framework for the V8 JavaScript engine"; + homepage = https://nodejs.org; + license = lib.licenses.mit; + platforms = lib.platforms.linux; + }; + + #TODO do I need this? + #passthru.python = python2; # to ensure nodeEnv uses the same version + } |