From fd398a72263d9d9c53d70733038038b82d2f07b3 Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Mon, 20 May 2024 14:43:35 +0200 Subject: [PATCH] fileserver --- fileserver/configuration.nix | 94 +++++++++++++++++++++++++++ fileserver/configuration.nix~ | 93 ++++++++++++++++++++++++++ fileserver/hardware-configuration.nix | 43 ++++++++++++ fileserver/transmission.nix | 7 ++ fileserver/transmission.nix~ | 0 5 files changed, 237 insertions(+) create mode 100644 fileserver/configuration.nix create mode 100644 fileserver/configuration.nix~ create mode 100644 fileserver/hardware-configuration.nix create mode 100644 fileserver/transmission.nix create mode 100644 fileserver/transmission.nix~ diff --git a/fileserver/configuration.nix b/fileserver/configuration.nix new file mode 100644 index 0000000..651b11a --- /dev/null +++ b/fileserver/configuration.nix @@ -0,0 +1,94 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +{ config, lib, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ./transmission.nix + ]; + + # Kernel + boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; + # Use the Grub boot loader. + boot.loader.grub = { + enable = true; + zfsSupport = true; + efiSupport = true; + efiInstallAsRemovable = true; + mirroredBoots = [ + { devices = [ "nodev" ]; path = "/boot"; } + ]; + }; + boot.supportedFilesystems = [ "zfs" ]; + boot.loader.grub.memtest86.enable = true; + zramSwap = { + enable = true; + algorithm = "zstd"; + }; + + # ZFS + services.zfs.autoScrub.enable = true; + services.zfs.trim.enable = true; + + # Firmware + services.fwupd.enable = true; + hardware.firmware = with pkgs; [ firmwareLinuxNonfree ]; + hardware.enableAllFirmware = true; + hardware.enableRedistributableFirmware = true; + + # enable unfree + nixpkgs.config.allowUnfree = true; + + # Network + networking.hostName = "files"; + services.tailscale.enable = true; + networking.networkmanager.enable = true; + networking.hostId = "8425e349"; + + # TimeZone + time.timeZone = "Europe/Oslo"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Lat2-Terminus16"; + keyMap = "no"; + }; + + users.users.geir= { + isNormalUser = true; + extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + packages = with pkgs; [ + tree fastfetch kitty + ]; + }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + emacs zfs + wget curl git + ]; + + + # Enable services + services.openssh.enable = true; + services.nfs.server.enable = true; + services.nfs.server.exports = '' + /mnt/storage 10.0.0.0/24(rw,fsid=0,no_subtree_check) 100.64.0.0/10(rw,fsid=0,no_subtree_check) + ''; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ 2049 ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + networking.firewall.enable = false; + + system.stateVersion = "23.11"; + +} + diff --git a/fileserver/configuration.nix~ b/fileserver/configuration.nix~ new file mode 100644 index 0000000..807f882 --- /dev/null +++ b/fileserver/configuration.nix~ @@ -0,0 +1,93 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +{ config, lib, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Kernel + boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; + # Use the Grub boot loader. + boot.loader.grub = { + enable = true; + zfsSupport = true; + efiSupport = true; + efiInstallAsRemovable = true; + mirroredBoots = [ + { devices = [ "nodev" ]; path = "/boot"; } + ]; + }; + boot.supportedFilesystems = [ "zfs" ]; + boot.loader.grub.memtest86.enable = true; + zramSwap = { + enable = true; + algorithm = "zstd"; + }; + + # ZFS + services.zfs.autoScrub.enable = true; + services.zfs.trim.enable = true; + + # Firmware + services.fwupd.enable = true; + hardware.firmware = with pkgs; [ firmwareLinuxNonfree ]; + hardware.enableAllFirmware = true; + hardware.enableRedistributableFirmware = true; + + # enable unfree + nixpkgs.config.allowUnfree = true; + + # Network + networking.hostName = "files"; + services.tailscale.enable = true; + networking.networkmanager.enable = true; + networking.hostId = "8425e349"; + + # TimeZone + time.timeZone = "Europe/Oslo"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Lat2-Terminus16"; + keyMap = "no"; + }; + + users.users.geir= { + isNormalUser = true; + extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + packages = with pkgs; [ + tree fastfetch kitty + ]; + }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + emacs zfs + wget curl git + ]; + + + # Enable services + services.openssh.enable = true; + services.nfs.server.enable = true; + services.nfs.server.exports = '' + /mnt/storage 10.0.0.0/24(rw,fsid=0,no_subtree_check) 100.64.0.0/10(rw,fsid=0,no_subtree_check) + ''; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ 2049 ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + networking.firewall.enable = false; + + system.stateVersion = "23.11"; + +} + diff --git a/fileserver/hardware-configuration.nix b/fileserver/hardware-configuration.nix new file mode 100644 index 0000000..24efc75 --- /dev/null +++ b/fileserver/hardware-configuration.nix @@ -0,0 +1,43 @@ +# 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 = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/e7fc0e32-b9e5-4080-859e-fe9dea60823d"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/2C7A-9F08"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + fileSystems."/mnt/storage" = + { device = "storage/media"; + fsType = "zfs"; + }; + + swapDevices = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp3s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/fileserver/transmission.nix b/fileserver/transmission.nix new file mode 100644 index 0000000..3d7d6de --- /dev/null +++ b/fileserver/transmission.nix @@ -0,0 +1,7 @@ +{ config, pkgs, ... }: + +{ + services.transmission = { + enable = true; + }; +} diff --git a/fileserver/transmission.nix~ b/fileserver/transmission.nix~ new file mode 100644 index 0000000..e69de29