From 29ec754b2ffe74902c6eecb2a883064ef0af56c1 Mon Sep 17 00:00:00 2001 From: mjallen18 Date: Fri, 31 May 2024 16:11:42 -0500 Subject: [PATCH] formatting --- cachix/cachix.nix | 6 +- cachix/nix-community.nix | 4 +- flake.nix | 194 ++++++------ hosts/default.nix | 66 +++-- hosts/desktop/configuration.nix | 62 +++- hosts/desktop/hardware-configuration.nix | 60 +++- hosts/desktop/home.nix | 2 +- .../apple-silicon-support/default.nix | 4 +- .../modules/boot-m1n1/default.nix | 21 +- .../apple-silicon-support/modules/default.nix | 19 +- .../modules/kernel/default.nix | 21 +- .../modules/mesa/default.nix | 98 +++--- .../modules/peripheral-firmware/default.nix | 65 ++-- .../modules/sound/default.nix | 148 ++++++---- .../packages/alsa-ucm-conf-asahi/default.nix | 18 +- .../packages/asahi-audio/default.nix | 7 +- .../packages/asahi-fwextract/default.nix | 13 +- .../packages/bankstown-lv2/default.nix | 21 +- .../packages/linux-asahi/default.nix | 278 +++++++++++------- .../packages/m1n1/default.nix | 110 +++---- .../packages/mesa-asahi-edge/default.nix | 87 +++--- .../packages/speakersafetyd/default.nix | 13 +- .../packages/uboot-asahi/default.nix | 33 ++- hosts/mac-nixos/configuration.nix | 21 +- hosts/mac-nixos/hardware-configuration.nix | 86 +++--- hosts/mac-nixos/home.nix | 4 +- hosts/mac/configuration.nix | 47 ++- hosts/mac/home.nix | 15 +- hosts/mac/trampoline-apps/default.nix | 7 +- hosts/nas/configuration.nix | 128 ++++---- hosts/nas/hardware-configuration.nix | 59 +++- hosts/pi4/configuration.nix | 41 ++- hosts/pi4/docker-pi4.nix | 10 +- hosts/pi4/hardware-configuration.nix | 11 +- modules/apps/collabora/default.nix | 13 +- modules/apps/collabora/options.nix | 4 +- modules/apps/deluge/default.nix | 18 +- modules/apps/deluge/options.nix | 4 +- modules/apps/discover-wrapped/default.nix | 13 +- modules/apps/discover-wrapped/options.nix | 3 +- modules/apps/homarr/default.nix | 15 +- modules/apps/homarr/options.nix | 3 +- modules/apps/homepage/default.nix | 15 +- modules/apps/homepage/options.nix | 3 +- modules/apps/jackett/default.nix | 13 +- modules/apps/jackett/options.nix | 3 +- modules/apps/jellyfin/default.nix | 75 ++--- modules/apps/jellyfin/options.nix | 4 +- modules/apps/jellyseerr/default.nix | 13 +- modules/apps/jellyseerr/options.nix | 4 +- modules/apps/mariadb/default.nix | 13 +- modules/apps/mariadb/options.nix | 3 +- modules/apps/nextcloud/default.nix | 23 +- modules/apps/nextcloud/options.nix | 3 +- modules/apps/ollama/default.nix | 18 +- modules/apps/ollama/options.nix | 4 +- modules/apps/open-webui/default.nix | 51 ++-- modules/apps/open-webui/options.nix | 4 +- modules/apps/orca-slicer/default.nix | 18 +- modules/apps/orca-slicer/options.nix | 3 +- modules/apps/radarr/default.nix | 13 +- modules/apps/radarr/options.nix | 3 +- modules/apps/sabnzbd/default.nix | 13 +- modules/apps/sabnzbd/options.nix | 4 +- modules/apps/sonarr/default.nix | 13 +- modules/apps/sonarr/options.nix | 3 +- modules/apps/swag/default.nix | 33 ++- modules/apps/swag/options.nix | 3 +- modules/apps/vscode/default.nix | 17 +- modules/apps/vscode/options.nix | 3 +- modules/default.nix | 3 +- modules/samba/default.nix | 52 ++-- modules/samba/options.nix | 83 +++--- overlays/default.nix | 4 +- share/amd/default.nix | 22 +- share/amd/options.nix | 3 +- share/default.nix | 9 +- share/gaming/default.nix | 41 +-- share/gaming/options.nix | 3 +- share/impermanence/default.nix | 23 +- share/nvidia/default.nix | 22 +- share/nvidia/options.nix | 3 +- 82 files changed, 1521 insertions(+), 974 deletions(-) diff --git a/cachix/cachix.nix b/cachix/cachix.nix index 81515ed..7b880fa 100644 --- a/cachix/cachix.nix +++ b/cachix/cachix.nix @@ -5,9 +5,9 @@ let folder = ../cachix; toImport = name: value: folder + ("/" + name); filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key; - imports = lib.mapAttrsToList toImport - (lib.filterAttrs filterCaches (builtins.readDir folder)); -in { + imports = lib.mapAttrsToList toImport (lib.filterAttrs filterCaches (builtins.readDir folder)); +in +{ inherit imports; nix.settings.substituters = [ "https://cache.nixos.org/" ]; } diff --git a/cachix/nix-community.nix b/cachix/nix-community.nix index 5579717..c6e569f 100644 --- a/cachix/nix-community.nix +++ b/cachix/nix-community.nix @@ -2,9 +2,7 @@ nix = { settings = { substituters = [ "https://nix-community.cachix.org" ]; - trusted-public-keys = [ - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; + trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ]; }; }; } diff --git a/flake.nix b/flake.nix index 555b717..44a84c2 100644 --- a/flake.nix +++ b/flake.nix @@ -17,7 +17,7 @@ url = "github:nix-community/lanzaboote/v0.3.0"; inputs.nixpkgs.follows = "nixpkgs"; }; - + nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; home-manager-stable.url = "github:nix-community/home-manager/release-24.05"; @@ -31,98 +31,118 @@ nixos-hardware.url = "github:NixOS/nixos-hardware/master"; }; - outputs = { self, nixpkgs, nixpkgs-stable, chaotic, lanzaboote, impermanence, nix-flatpak, home-manager - , nixos-hardware, nix-darwin, nixos-apple-silicon, home-manager-stable, nix-inspect, nixpkgs-unstable }@inputs: -let - inherit (self) outputs; -in { - overlays = import ./overlays {inherit inputs;}; + outputs = + { + self, + nixpkgs, + nixpkgs-stable, + chaotic, + lanzaboote, + impermanence, + nix-flatpak, + home-manager, + nixos-hardware, + nix-darwin, + nixos-apple-silicon, + home-manager-stable, + nix-inspect, + nixpkgs-unstable, + }@inputs: + let + inherit (self) outputs; + in + { + overlays = import ./overlays { inherit inputs; }; - nixosConfigurations = { - # Desktop - "matt-nixos" = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = {inherit inputs outputs;}; - modules = [ - impermanence.nixosModules.impermanence - lanzaboote.nixosModules.lanzaboote - nix-flatpak.nixosModules.nix-flatpak - ./hosts/desktop/configuration.nix - ./share/impermanence - chaotic.nixosModules.default - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.matt = import ./hosts/desktop/home.nix; - } + nixosConfigurations = { + # Desktop + "matt-nixos" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { + inherit inputs outputs; + }; + modules = [ + impermanence.nixosModules.impermanence + lanzaboote.nixosModules.lanzaboote + nix-flatpak.nixosModules.nix-flatpak + ./hosts/desktop/configuration.nix + ./share/impermanence + chaotic.nixosModules.default + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.matt = import ./hosts/desktop/home.nix; + } - nixos-hardware.nixosModules.common-cpu-amd - nixos-hardware.nixosModules.common-gpu-amd - nixos-hardware.nixosModules.common-hidpi - nixos-hardware.nixosModules.common-pc - ]; + nixos-hardware.nixosModules.common-cpu-amd + nixos-hardware.nixosModules.common-gpu-amd + nixos-hardware.nixosModules.common-hidpi + nixos-hardware.nixosModules.common-pc + ]; + }; + + # NAS + "jallen-nas" = nixpkgs-stable.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { + inherit inputs outputs; + }; + modules = [ + ./hosts/nas/configuration.nix + home-manager-stable.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.admin = import ./hosts/nas/home.nix; + } + ]; + }; + + # mac nix + "mac-nixos" = nixpkgs.lib.nixosSystem { + system = "aarch64-linux"; + modules = [ + nixos-apple-silicon.nixosModules.apple-silicon-support + ./hosts/mac-nixos/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.matt = import ./hosts/mac-nixos/home.nix; + } + ]; + }; + + # Pi4 + "nixos-pi4" = nixpkgs.lib.nixosSystem { + system = "aarch64-linux"; + modules = [ + nixos-hardware.nixosModules.raspberry-pi-4 + ./hosts/pi4/configuration.nix + ]; + }; }; - # NAS - "jallen-nas" = nixpkgs-stable.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = {inherit inputs outputs;}; - modules = [ - ./hosts/nas/configuration.nix - home-manager-stable.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.admin = import ./hosts/nas/home.nix; - } - ]; + darwinConfigurations = { + "MacBook-Pro" = nix-darwin.lib.darwinSystem { + system = "aarch64-darwin"; + modules = [ + ./hosts/mac/configuration.nix + home-manager.darwinModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.mattjallen = import ./hosts/mac/home.nix; + } + ]; + }; }; - # mac nix - "mac-nixos" = nixpkgs.lib.nixosSystem { - system = "aarch64-linux"; - modules = [ - nixos-apple-silicon.nixosModules.apple-silicon-support - ./hosts/mac-nixos/configuration.nix - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.matt = import ./hosts/mac-nixos/home.nix; - } - ]; - }; + # Expose the package set, including overlays, for convenience. + darwinPackages = self.darwinConfigurations."MacBook-Pro".pkgs; - # Pi4 - "nixos-pi4" = nixpkgs.lib.nixosSystem { - system = "aarch64-linux"; - modules = [ - nixos-hardware.nixosModules.raspberry-pi-4 - ./hosts/pi4/configuration.nix - ]; - }; + # Set Git commit hash for darwin-version. + system.configurationRevision = self.rev or self.dirtyRev or null; }; - - darwinConfigurations = { - "MacBook-Pro" = nix-darwin.lib.darwinSystem { - system = "aarch64-darwin"; - modules = [ - ./hosts/mac/configuration.nix - home-manager.darwinModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.mattjallen = import ./hosts/mac/home.nix; - } - ]; - }; - }; - - # Expose the package set, including overlays, for convenience. - darwinPackages = self.darwinConfigurations."MacBook-Pro".pkgs; - - # Set Git commit hash for darwin-version. - system.configurationRevision = self.rev or self.dirtyRev or null; - }; } diff --git a/hosts/default.nix b/hosts/default.nix index 7d4a6aa..39f0bb6 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -1,11 +1,24 @@ -{ config, lib, pkgs, ... }: -let timezone = "America/Chicago"; -in { - imports = [ ../modules ../share ]; +{ + config, + lib, + pkgs, + ... +}: +let + timezone = "America/Chicago"; +in +{ + imports = [ + ../modules + ../share + ]; # Enable nix flakes and nix-command tools nix = { - settings.experimental-features = [ "nix-command" "flakes" ]; + settings.experimental-features = [ + "nix-command" + "flakes" + ]; # Garbage collect automatically every week gc.automatic = lib.mkDefault true; @@ -81,10 +94,8 @@ in { }; }; - environment.systemPackages = with pkgs; [ - pinentry-curses - ]; - + environment.systemPackages = with pkgs; [ pinentry-curses ]; + # Security config security = { rtkit.enable = lib.mkDefault true; @@ -92,24 +103,25 @@ in { # configure sudo sudo = { enable = lib.mkDefault true; - extraRules = [{ - commands = [ - { - command = "${pkgs.systemd}/bin/systemctl suspend"; - options = [ "NOPASSWD" ]; - } - { - command = "${pkgs.systemd}/bin/reboot"; - options = [ "NOPASSWD" ]; - } - { - command = "${pkgs.systemd}/bin/poweroff"; - options = [ "NOPASSWD" ]; - } - ]; - groups = [ "wheel" ]; - }]; + extraRules = [ + { + commands = [ + { + command = "${pkgs.systemd}/bin/systemctl suspend"; + options = [ "NOPASSWD" ]; + } + { + command = "${pkgs.systemd}/bin/reboot"; + options = [ "NOPASSWD" ]; + } + { + command = "${pkgs.systemd}/bin/poweroff"; + options = [ "NOPASSWD" ]; + } + ]; + groups = [ "wheel" ]; + } + ]; }; }; - } diff --git a/hosts/desktop/configuration.nix b/hosts/desktop/configuration.nix index 70d1493..00884d4 100644 --- a/hosts/desktop/configuration.nix +++ b/hosts/desktop/configuration.nix @@ -2,16 +2,23 @@ # 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, outputs, lib, pkgs, ... }: +{ + config, + outputs, + lib, + pkgs, + ... +}: let user = "matt"; - password = - "$y$j9T$EkPXmsmIMFFZ.WRrBYCxS1$P0kwo6e4.WM5DsqUcEqWC3MrZp5KfCjxffraMFZWu06"; + password = "$y$j9T$EkPXmsmIMFFZ.WRrBYCxS1$P0kwo6e4.WM5DsqUcEqWC3MrZp5KfCjxffraMFZWu06"; hostname = "matt-nixos"; gnome = false; plasma = true; -in { - imports = [ # Include the results of the hardware scan. +in +{ + imports = [ + # Include the results of the hardware scan. ./hardware-configuration.nix # ../../cachix/cachix.nix ../default.nix @@ -142,7 +149,9 @@ in { }; # Time config - time = { hardwareClockInLocalTime = true; }; + time = { + hardwareClockInLocalTime = true; + }; # xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-kde ]; # xdg.portal.extraPortals = mkIf plasma [ pkgs.xdg-desktop-portal-gtk ]; @@ -190,7 +199,11 @@ in { # Define a user account. Don't forget to set a password with ‘passwd’. users.users."${user}" = { isNormalUser = true; - extraGroups = [ "wheel" "networkmanager" "ratbagd" ]; # Enable ‘sudo’ for the user. + extraGroups = [ + "wheel" + "networkmanager" + "ratbagd" + ]; # Enable ‘sudo’ for the user. shell = pkgs.fish; }; @@ -213,19 +226,46 @@ in { fileSystems."/media/nas/backup" = { device = "//10.0.1.18/Backup"; fsType = "cifs"; - options = [ "sec=none" "x-systemd.automount" "auto" "rw" "file_mode=0775" "dir_mode=0775" "uid=matt" "gid=wheel" ]; + options = [ + "sec=none" + "x-systemd.automount" + "auto" + "rw" + "file_mode=0775" + "dir_mode=0775" + "uid=matt" + "gid=wheel" + ]; }; fileSystems."/media/nas/isos" = { device = "//10.0.1.18/isos"; fsType = "cifs"; - options = [ "sec=none" "x-systemd.automount" "auto" "rw" "file_mode=0775" "dir_mode=0775" "uid=matt" "gid=wheel" ]; + options = [ + "sec=none" + "x-systemd.automount" + "auto" + "rw" + "file_mode=0775" + "dir_mode=0775" + "uid=matt" + "gid=wheel" + ]; }; fileSystems."/media/nas/3d_printer" = { device = "//10.0.1.18/3d_printer"; fsType = "cifs"; - options = [ "sec=none" "x-systemd.automount" "auto" "rw" "file_mode=0775" "dir_mode=0775" "uid=matt" "gid=wheel" ]; + options = [ + "sec=none" + "x-systemd.automount" + "auto" + "rw" + "file_mode=0775" + "dir_mode=0775" + "uid=matt" + "gid=wheel" + ]; }; # This option defines the first version of NixOS you have installed on this particular machine, @@ -245,6 +285,4 @@ in { # # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . system.stateVersion = "23.11"; # Did you read the comment? - } - diff --git a/hosts/desktop/hardware-configuration.nix b/hosts/desktop/hardware-configuration.nix index 20fa386..748dcd6 100644 --- a/hosts/desktop/hardware-configuration.nix +++ b/hosts/desktop/hardware-configuration.nix @@ -1,13 +1,26 @@ # 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, ... }: +{ + config, + lib, + pkgs, + modulesPath, + ... +}: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = - [ "xhci_pci" "nvme" "ahci" "usbhid" "uas" "usb_storage" "sd_mod" ]; + boot.initrd.availableKernelModules = [ + "xhci_pci" + "nvme" + "ahci" + "usbhid" + "uas" + "usb_storage" + "sd_mod" + ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; @@ -15,37 +28,60 @@ fileSystems."/" = { device = "none"; fsType = "tmpfs"; - options = [ "defaults" "size=256G" "mode=755" ]; + options = [ + "defaults" + "size=256G" + "mode=755" + ]; }; fileSystems."/nix" = { device = "/dev/disk/by-uuid/c6cf43cb-d0d2-4111-bc81-994e41b2632d"; fsType = "btrfs"; - options = [ "subvol=nix" "compress=zstd" "noatime" ]; + options = [ + "subvol=nix" + "compress=zstd" + "noatime" + ]; }; fileSystems."/etc" = { device = "/dev/disk/by-uuid/c6cf43cb-d0d2-4111-bc81-994e41b2632d"; fsType = "btrfs"; - options = [ "subvol=etc" "compress=zstd" "noatime" ]; + options = [ + "subvol=etc" + "compress=zstd" + "noatime" + ]; }; fileSystems."/root" = { device = "/dev/disk/by-uuid/c6cf43cb-d0d2-4111-bc81-994e41b2632d"; fsType = "btrfs"; - options = [ "subvol=root" "compress=zstd" "noatime" ]; + options = [ + "subvol=root" + "compress=zstd" + "noatime" + ]; }; fileSystems."/var/log" = { device = "/dev/disk/by-uuid/c6cf43cb-d0d2-4111-bc81-994e41b2632d"; fsType = "btrfs"; - options = [ "subvol=log" "compress=zstd" "noatime" ]; + options = [ + "subvol=log" + "compress=zstd" + "noatime" + ]; }; fileSystems."/home" = { device = "/dev/disk/by-uuid/c6cf43cb-d0d2-4111-bc81-994e41b2632d"; fsType = "btrfs"; - options = [ "subvol=home" "compress=zstd" ]; + options = [ + "subvol=home" + "compress=zstd" + ]; }; fileSystems."/boot" = { @@ -53,8 +89,7 @@ fsType = "vfat"; }; - swapDevices = - [{ device = "/dev/disk/by-uuid/a94819f6-d4e1-4471-b972-703c80de1a5f"; }]; + swapDevices = [ { device = "/dev/disk/by-uuid/a94819f6-d4e1-4471-b972-703c80de1a5f"; } ]; fileSystems."/home/matt/Games" = { device = "/dev/disk/by-uuid/1adb3161-ef9e-45d9-be5f-dd718186f1b3"; @@ -74,6 +109,5 @@ # networking.interfaces.wlp9s0.useDHCP = lib.mkDefault true; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = - lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; } diff --git a/hosts/desktop/home.nix b/hosts/desktop/home.nix index 9521120..e065ada 100644 --- a/hosts/desktop/home.nix +++ b/hosts/desktop/home.nix @@ -61,7 +61,7 @@ vmware-horizon-client vorta ]; - + # dconf = { # enable = true; # settings = { diff --git a/hosts/mac-nixos/apple-silicon-support/default.nix b/hosts/mac-nixos/apple-silicon-support/default.nix index 71a5dd0..bfd5e33 100644 --- a/hosts/mac-nixos/apple-silicon-support/default.nix +++ b/hosts/mac-nixos/apple-silicon-support/default.nix @@ -1,7 +1,5 @@ { ... }: { - imports = [ - ./modules/default.nix - ]; + imports = [ ./modules/default.nix ]; } diff --git a/hosts/mac-nixos/apple-silicon-support/modules/boot-m1n1/default.nix b/hosts/mac-nixos/apple-silicon-support/modules/boot-m1n1/default.nix index ccbd40b..c755984 100644 --- a/hosts/mac-nixos/apple-silicon-support/modules/boot-m1n1/default.nix +++ b/hosts/mac-nixos/apple-silicon-support/modules/boot-m1n1/default.nix @@ -1,4 +1,9 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let pkgs' = config.hardware.asahi.pkgs; @@ -8,12 +13,10 @@ let customLogo = config.boot.m1n1CustomLogo; }; - bootUBoot = pkgs'.uboot-asahi.override { - m1n1 = bootM1n1; - }; + bootUBoot = pkgs'.uboot-asahi.override { m1n1 = bootM1n1; }; bootFiles = { - "m1n1/boot.bin" = pkgs.runCommand "boot.bin" {} '' + "m1n1/boot.bin" = pkgs.runCommand "boot.bin" { } '' cat ${bootM1n1}/build/m1n1.bin > $out cat ${config.boot.kernelPackages.kernel}/dtbs/apple/*.dtb >> $out cat ${bootUBoot}/u-boot-nodtb.bin.gz >> $out @@ -22,14 +25,18 @@ let fi ''; }; -in { +in +{ config = lib.mkIf config.hardware.asahi.enable { # install m1n1 with the boot loader boot.loader.grub.extraFiles = bootFiles; boot.loader.systemd-boot.extraFiles = bootFiles; # ensure the installer has m1n1 in the image - system.extraDependencies = lib.mkForce [ bootM1n1 bootUBoot ]; + system.extraDependencies = lib.mkForce [ + bootM1n1 + bootUBoot + ]; system.build.m1n1 = bootFiles."m1n1/boot.bin"; }; diff --git a/hosts/mac-nixos/apple-silicon-support/modules/default.nix b/hosts/mac-nixos/apple-silicon-support/modules/default.nix index 7990556..19dd67c 100644 --- a/hosts/mac-nixos/apple-silicon-support/modules/default.nix +++ b/hosts/mac-nixos/apple-silicon-support/modules/default.nix @@ -1,4 +1,9 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: { imports = [ ./kernel @@ -8,20 +13,22 @@ ./sound ]; - config = let + config = + let cfg = config.hardware.asahi; - in lib.mkIf cfg.enable { + in + lib.mkIf cfg.enable { nixpkgs.overlays = lib.mkBefore [ cfg.overlay ]; hardware.asahi.pkgs = - if cfg.pkgsSystem != "aarch64-linux" - then + if cfg.pkgsSystem != "aarch64-linux" then import (pkgs.path) { crossSystem.system = "aarch64-linux"; localSystem.system = cfg.pkgsSystem; overlays = [ cfg.overlay ]; } - else pkgs; + else + pkgs; }; options.hardware.asahi = { diff --git a/hosts/mac-nixos/apple-silicon-support/modules/kernel/default.nix b/hosts/mac-nixos/apple-silicon-support/modules/kernel/default.nix index 619a026..e1c4b87 100644 --- a/hosts/mac-nixos/apple-silicon-support/modules/kernel/default.nix +++ b/hosts/mac-nixos/apple-silicon-support/modules/kernel/default.nix @@ -1,11 +1,17 @@ # the Asahi Linux kernel and options that must go along with it -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: { config = lib.mkIf config.hardware.asahi.enable { - boot.kernelPackages = let - pkgs' = config.hardware.asahi.pkgs; - in + boot.kernelPackages = + let + pkgs' = config.hardware.asahi.pkgs; + in pkgs'.linux-asahi.override { _kernelPatches = config.boot.kernelPatches; withRust = config.hardware.asahi.withRust; @@ -93,8 +99,11 @@ }; imports = [ - (lib.mkRemovedOptionModule [ "hardware" "asahi" "addEdgeKernelConfig" ] - "All edge kernel config options are now the default.") + (lib.mkRemovedOptionModule [ + "hardware" + "asahi" + "addEdgeKernelConfig" + ] "All edge kernel config options are now the default.") ]; options.hardware.asahi.withRust = lib.mkOption { diff --git a/hosts/mac-nixos/apple-silicon-support/modules/mesa/default.nix b/hosts/mac-nixos/apple-silicon-support/modules/mesa/default.nix index cc3db2b..6189450 100644 --- a/hosts/mac-nixos/apple-silicon-support/modules/mesa/default.nix +++ b/hosts/mac-nixos/apple-silicon-support/modules/mesa/default.nix @@ -1,47 +1,57 @@ -{ config, pkgs, lib, ... }: { - config = let - isMode = mode: (config.hardware.asahi.useExperimentalGPUDriver - && config.hardware.asahi.experimentalGPUInstallMode == mode); - in lib.mkIf config.hardware.asahi.enable (lib.mkMerge [ - { - # required for proper DRM setup even without GPU driver - services.xserver.config = '' - Section "OutputClass" - Identifier "appledrm" - MatchDriver "apple" - Driver "modesetting" - Option "PrimaryGPU" "true" - EndSection - ''; - } - (lib.mkIf config.hardware.asahi.useExperimentalGPUDriver { - # install the drivers - hardware.opengl.package = config.hardware.asahi.pkgs.mesa-asahi-edge.drivers; - - # required for in-kernel GPU driver - hardware.asahi.withRust = true; - }) - (lib.mkIf (isMode "replace") { - # replace the Mesa linked into system packages with the Asahi version - # without rebuilding them to avoid rebuilding the world. - system.replaceRuntimeDependencies = [ - { original = pkgs.mesa; - replacement = config.hardware.asahi.pkgs.mesa-asahi-edge; + config, + pkgs, + lib, + ... +}: +{ + config = + let + isMode = + mode: + ( + config.hardware.asahi.useExperimentalGPUDriver + && config.hardware.asahi.experimentalGPUInstallMode == mode + ); + in + lib.mkIf config.hardware.asahi.enable ( + lib.mkMerge [ + { + # required for proper DRM setup even without GPU driver + services.xserver.config = '' + Section "OutputClass" + Identifier "appledrm" + MatchDriver "apple" + Driver "modesetting" + Option "PrimaryGPU" "true" + EndSection + ''; } - ]; - }) - (lib.mkIf (isMode "overlay") { - # replace the Mesa used in Nixpkgs with the Asahi version using an overlay, - # which requires rebuilding the world but ensures it is done faithfully - # (and in a way compatible with pure evaluation) - nixpkgs.overlays = [ - (final: prev: { - mesa = final.mesa-asahi-edge; + (lib.mkIf config.hardware.asahi.useExperimentalGPUDriver { + # install the drivers + hardware.opengl.package = config.hardware.asahi.pkgs.mesa-asahi-edge.drivers; + + # required for in-kernel GPU driver + hardware.asahi.withRust = true; }) - ]; - }) - ]); + (lib.mkIf (isMode "replace") { + # replace the Mesa linked into system packages with the Asahi version + # without rebuilding them to avoid rebuilding the world. + system.replaceRuntimeDependencies = [ + { + original = pkgs.mesa; + replacement = config.hardware.asahi.pkgs.mesa-asahi-edge; + } + ]; + }) + (lib.mkIf (isMode "overlay") { + # replace the Mesa used in Nixpkgs with the Asahi version using an overlay, + # which requires rebuilding the world but ensures it is done faithfully + # (and in a way compatible with pure evaluation) + nixpkgs.overlays = [ (final: prev: { mesa = final.mesa-asahi-edge; }) ]; + }) + ] + ); options.hardware.asahi.useExperimentalGPUDriver = lib.mkOption { type = lib.types.bool; @@ -54,7 +64,11 @@ }; options.hardware.asahi.experimentalGPUInstallMode = lib.mkOption { - type = lib.types.enum [ "driver" "replace" "overlay" ]; + type = lib.types.enum [ + "driver" + "replace" + "overlay" + ]; default = "replace"; description = '' Mode to use to install the experimental GPU driver into the system. diff --git a/hosts/mac-nixos/apple-silicon-support/modules/peripheral-firmware/default.nix b/hosts/mac-nixos/apple-silicon-support/modules/peripheral-firmware/default.nix index e10632f..27f1f34 100644 --- a/hosts/mac-nixos/apple-silicon-support/modules/peripheral-firmware/default.nix +++ b/hosts/mac-nixos/apple-silicon-support/modules/peripheral-firmware/default.nix @@ -1,8 +1,14 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: { config = lib.mkIf config.hardware.asahi.enable { assertions = lib.mkIf config.hardware.asahi.extractPeripheralFirmware [ - { assertion = config.hardware.asahi.peripheralFirmwareDirectory != null; + { + assertion = config.hardware.asahi.peripheralFirmwareDirectory != null; message = '' Asahi peripheral firmware extraction is enabled but the firmware location appears incorrect. @@ -10,26 +16,34 @@ } ]; - hardware.firmware = let - pkgs' = config.hardware.asahi.pkgs; - in - lib.mkIf ((config.hardware.asahi.peripheralFirmwareDirectory != null) - && config.hardware.asahi.extractPeripheralFirmware) [ - (pkgs.stdenv.mkDerivation { - name = "asahi-peripheral-firmware"; + hardware.firmware = + let + pkgs' = config.hardware.asahi.pkgs; + in + lib.mkIf + ( + (config.hardware.asahi.peripheralFirmwareDirectory != null) + && config.hardware.asahi.extractPeripheralFirmware + ) + [ + (pkgs.stdenv.mkDerivation { + name = "asahi-peripheral-firmware"; - nativeBuildInputs = [ pkgs'.asahi-fwextract pkgs.cpio ]; + nativeBuildInputs = [ + pkgs'.asahi-fwextract + pkgs.cpio + ]; - buildCommand = '' - mkdir extracted - asahi-fwextract ${config.hardware.asahi.peripheralFirmwareDirectory} extracted + buildCommand = '' + mkdir extracted + asahi-fwextract ${config.hardware.asahi.peripheralFirmwareDirectory} extracted - mkdir -p $out/lib/firmware - cat extracted/firmware.cpio | cpio -id --quiet --no-absolute-filenames - mv vendorfw/* $out/lib/firmware - ''; - }) - ]; + mkdir -p $out/lib/firmware + cat extracted/firmware.cpio | cpio -id --quiet --no-absolute-filenames + mv vendorfw/* $out/lib/firmware + ''; + }) + ]; }; options.hardware.asahi = { @@ -45,13 +59,12 @@ peripheralFirmwareDirectory = lib.mkOption { type = lib.types.nullOr lib.types.path; - default = lib.findFirst (path: builtins.pathExists (path + "/all_firmware.tar.gz")) null - [ - # path when the system is operating normally - /boot/asahi - # path when the system is mounted in the installer - /mnt/boot/asahi - ]; + default = lib.findFirst (path: builtins.pathExists (path + "/all_firmware.tar.gz")) null [ + # path when the system is operating normally + /boot/asahi + # path when the system is mounted in the installer + /mnt/boot/asahi + ]; description = '' Path to the directory containing the non-free non-redistributable diff --git a/hosts/mac-nixos/apple-silicon-support/modules/sound/default.nix b/hosts/mac-nixos/apple-silicon-support/modules/sound/default.nix index d76e713..6edd280 100644 --- a/hosts/mac-nixos/apple-silicon-support/modules/sound/default.nix +++ b/hosts/mac-nixos/apple-silicon-support/modules/sound/default.nix @@ -1,4 +1,10 @@ -{ config, options, pkgs, lib, ... }: +{ + config, + options, + pkgs, + lib, + ... +}: { imports = [ @@ -19,72 +25,96 @@ }; }; - config = let - cfg = config.hardware.asahi; + config = + let + cfg = config.hardware.asahi; - asahi-audio = pkgs.asahi-audio; # the asahi-audio we use + asahi-audio = pkgs.asahi-audio; # the asahi-audio we use - lsp-plugins = pkgs.lsp-plugins; # the lsp-plugins we use + lsp-plugins = pkgs.lsp-plugins; # the lsp-plugins we use - lsp-plugins-is-patched = (lsp-plugins.overrideAttrs (old: { - passthru = (old.passthru or {}) // { - lsp-plugins-is-patched = builtins.elem "58c3f985f009c84347fa91236f164a9e47aafa93.patch" - (builtins.map (p: p.name) (old.patches or [])); - }; - })).lsp-plugins-is-patched; + lsp-plugins-is-patched = + (lsp-plugins.overrideAttrs (old: { + passthru = (old.passthru or { }) // { + lsp-plugins-is-patched = builtins.elem "58c3f985f009c84347fa91236f164a9e47aafa93.patch" ( + builtins.map (p: p.name) (old.patches or [ ]) + ); + }; + })).lsp-plugins-is-patched; - lsp-plugins-is-safe = (pkgs.lib.versionAtLeast lsp-plugins.version "1.2.14") || lsp-plugins-is-patched; + lsp-plugins-is-safe = + (pkgs.lib.versionAtLeast lsp-plugins.version "1.2.14") || lsp-plugins-is-patched; - # https://github.com/NixOS/nixpkgs/pull/282377 - # options is the set of all module option declarations, rather than their - # values, to prevent infinite recursion - newHotness = builtins.hasAttr "configPackages" options.services.pipewire; + # https://github.com/NixOS/nixpkgs/pull/282377 + # options is the set of all module option declarations, rather than their + # values, to prevent infinite recursion + newHotness = builtins.hasAttr "configPackages" options.services.pipewire; - lv2Path = lib.makeSearchPath "lib/lv2" [ lsp-plugins pkgs.bankstown-lv2 ]; - in lib.mkIf (cfg.setupAsahiSound && cfg.enable) (lib.mkMerge [ - { - # enable pipewire to run real-time and avoid audible glitches - security.rtkit.enable = true; - # set up pipewire with the supported capabilities (instead of pulseaudio) - # and asahi-audio configs and plugins - services.pipewire = { - enable = true; + lv2Path = lib.makeSearchPath "lib/lv2" [ + lsp-plugins + pkgs.bankstown-lv2 + ]; + in + lib.mkIf (cfg.setupAsahiSound && cfg.enable) ( + lib.mkMerge [ + { + # enable pipewire to run real-time and avoid audible glitches + security.rtkit.enable = true; + # set up pipewire with the supported capabilities (instead of pulseaudio) + # and asahi-audio configs and plugins + services.pipewire = { + enable = true; - alsa.enable = true; - pulse.enable = true; - wireplumber.enable = true; - }; + alsa.enable = true; + pulse.enable = true; + wireplumber.enable = true; + }; - # set up enivronment so that UCM configs are used as well - environment.variables.ALSA_CONFIG_UCM2 = "${pkgs.alsa-ucm-conf-asahi}/share/alsa/ucm2"; - systemd.user.services.pipewire.environment.ALSA_CONFIG_UCM2 = config.environment.variables.ALSA_CONFIG_UCM2; - systemd.user.services.wireplumber.environment.ALSA_CONFIG_UCM2 = config.environment.variables.ALSA_CONFIG_UCM2; + # set up enivronment so that UCM configs are used as well + environment.variables.ALSA_CONFIG_UCM2 = "${pkgs.alsa-ucm-conf-asahi}/share/alsa/ucm2"; + systemd.user.services.pipewire.environment.ALSA_CONFIG_UCM2 = + config.environment.variables.ALSA_CONFIG_UCM2; + systemd.user.services.wireplumber.environment.ALSA_CONFIG_UCM2 = + config.environment.variables.ALSA_CONFIG_UCM2; - # enable speakersafetyd to protect speakers - systemd.packages = lib.mkAssert lsp-plugins-is-safe - "lsp-plugins is unpatched/outdated and speakers cannot be safely enabled" - [ pkgs.speakersafetyd ]; - services.udev.packages = [ pkgs.speakersafetyd ]; - } - (lib.optionalAttrs newHotness { - # use configPackages and friends to install asahi-audio and plugins - services.pipewire = { - configPackages = [ asahi-audio ]; - extraLv2Packages = [ lsp-plugins pkgs.bankstown-lv2 ]; - wireplumber = { - configPackages = [ asahi-audio ]; - extraLv2Packages = [ lsp-plugins pkgs.bankstown-lv2 ]; - }; - }; - }) - (lib.optionalAttrs (!newHotness) { - # use environment.etc and environment variables to install asahi-audio and plugins - environment.etc = builtins.listToAttrs (builtins.map - (f: { name = f; value = { source = "${asahi-audio}/share/${f}"; }; }) - asahi-audio.providedConfigFiles); + # enable speakersafetyd to protect speakers + systemd.packages = + lib.mkAssert lsp-plugins-is-safe + "lsp-plugins is unpatched/outdated and speakers cannot be safely enabled" + [ pkgs.speakersafetyd ]; + services.udev.packages = [ pkgs.speakersafetyd ]; + } + (lib.optionalAttrs newHotness { + # use configPackages and friends to install asahi-audio and plugins + services.pipewire = { + configPackages = [ asahi-audio ]; + extraLv2Packages = [ + lsp-plugins + pkgs.bankstown-lv2 + ]; + wireplumber = { + configPackages = [ asahi-audio ]; + extraLv2Packages = [ + lsp-plugins + pkgs.bankstown-lv2 + ]; + }; + }; + }) + (lib.optionalAttrs (!newHotness) { + # use environment.etc and environment variables to install asahi-audio and plugins + environment.etc = builtins.listToAttrs ( + builtins.map (f: { + name = f; + value = { + source = "${asahi-audio}/share/${f}"; + }; + }) asahi-audio.providedConfigFiles + ); - systemd.user.services.pipewire.environment.LV2_PATH = lv2Path; - systemd.user.services.wireplumber.environment.LV2_PATH = lv2Path; - }) - ]); + systemd.user.services.pipewire.environment.LV2_PATH = lv2Path; + systemd.user.services.wireplumber.environment.LV2_PATH = lv2Path; + }) + ] + ); } diff --git a/hosts/mac-nixos/apple-silicon-support/packages/alsa-ucm-conf-asahi/default.nix b/hosts/mac-nixos/apple-silicon-support/packages/alsa-ucm-conf-asahi/default.nix index ac9d15e..72ab0c6 100644 --- a/hosts/mac-nixos/apple-silicon-support/packages/alsa-ucm-conf-asahi/default.nix +++ b/hosts/mac-nixos/apple-silicon-support/packages/alsa-ucm-conf-asahi/default.nix @@ -1,6 +1,8 @@ -{ lib -, fetchFromGitHub -, alsa-ucm-conf }: +{ + lib, + fetchFromGitHub, + alsa-ucm-conf, +}: (alsa-ucm-conf.overrideAttrs (oldAttrs: rec { version = "5"; @@ -12,8 +14,10 @@ rev = "v${version}"; hash = "sha256-daUNz5oUrPfSMO0Tqq/WbtiLHMOtPeQQlI+juGrhTxw="; }; - - postInstall = oldAttrs.postInstall or "" + '' - cp -r ${src_asahi}/ucm2 $out/share/alsa - ''; + + postInstall = + oldAttrs.postInstall or "" + + '' + cp -r ${src_asahi}/ucm2 $out/share/alsa + ''; })) diff --git a/hosts/mac-nixos/apple-silicon-support/packages/asahi-audio/default.nix b/hosts/mac-nixos/apple-silicon-support/packages/asahi-audio/default.nix index 4ccbcc5d..144ab00 100644 --- a/hosts/mac-nixos/apple-silicon-support/packages/asahi-audio/default.nix +++ b/hosts/mac-nixos/apple-silicon-support/packages/asahi-audio/default.nix @@ -1,6 +1,7 @@ -{ stdenv -, lib -, fetchFromGitHub +{ + stdenv, + lib, + fetchFromGitHub, }: stdenv.mkDerivation rec { diff --git a/hosts/mac-nixos/apple-silicon-support/packages/asahi-fwextract/default.nix b/hosts/mac-nixos/apple-silicon-support/packages/asahi-fwextract/default.nix index 556beb5..8dc687f 100755 --- a/hosts/mac-nixos/apple-silicon-support/packages/asahi-fwextract/default.nix +++ b/hosts/mac-nixos/apple-silicon-support/packages/asahi-fwextract/default.nix @@ -1,9 +1,10 @@ -{ lib -, python3 -, fetchFromGitHub -, gzip -, gnutar -, lzfse +{ + lib, + python3, + fetchFromGitHub, + gzip, + gnutar, + lzfse, }: python3.pkgs.buildPythonApplication rec { diff --git a/hosts/mac-nixos/apple-silicon-support/packages/bankstown-lv2/default.nix b/hosts/mac-nixos/apple-silicon-support/packages/bankstown-lv2/default.nix index 58c7bf9..7f98839 100644 --- a/hosts/mac-nixos/apple-silicon-support/packages/bankstown-lv2/default.nix +++ b/hosts/mac-nixos/apple-silicon-support/packages/bankstown-lv2/default.nix @@ -1,9 +1,10 @@ -{ lib -, lv2 -, pkg-config -, rustPlatform -, fetchFromGitHub -, fetchpatch +{ + lib, + lv2, + pkg-config, + rustPlatform, + fetchFromGitHub, + fetchpatch, }: rustPlatform.buildRustPackage rec { @@ -28,11 +29,7 @@ rustPlatform.buildRustPackage rec { make install ''; - nativeBuildInputs = [ - pkg-config - ]; + nativeBuildInputs = [ pkg-config ]; - buildInputs = [ - lv2 - ]; + buildInputs = [ lv2 ]; } diff --git a/hosts/mac-nixos/apple-silicon-support/packages/linux-asahi/default.nix b/hosts/mac-nixos/apple-silicon-support/packages/linux-asahi/default.nix index bb9a054..a2e0c71 100644 --- a/hosts/mac-nixos/apple-silicon-support/packages/linux-asahi/default.nix +++ b/hosts/mac-nixos/apple-silicon-support/packages/linux-asahi/default.nix @@ -1,12 +1,13 @@ -{ lib -, pkgs -, callPackage -, writeShellScriptBin -, writeText -, removeReferencesTo -, linuxPackagesFor -, withRust ? false -, _kernelPatches ? [ ] +{ + lib, + pkgs, + callPackage, + writeShellScriptBin, + writeText, + removeReferencesTo, + linuxPackagesFor, + withRust ? false, + _kernelPatches ? [ ], }: let @@ -14,67 +15,107 @@ let # parse [ymn]|foo style configuration as found in a patch's extraConfig # into a list of k, v tuples - parseExtraConfig = config: + parseExtraConfig = + config: let - lines = - builtins.filter (s: s != "") (lib.strings.splitString "\n" config); - parseLine = line: let - t = lib.strings.splitString " " line; - join = l: builtins.foldl' (a: b: "${a} ${b}") - (builtins.head l) (builtins.tail l); - v = if (builtins.length t) > 2 then join (builtins.tail t) else (i t 1); - in [ "CONFIG_${i t 0}" v ]; - in map parseLine lines; + lines = builtins.filter (s: s != "") (lib.strings.splitString "\n" config); + parseLine = + line: + let + t = lib.strings.splitString " " line; + join = l: builtins.foldl' (a: b: "${a} ${b}") (builtins.head l) (builtins.tail l); + v = if (builtins.length t) > 2 then join (builtins.tail t) else (i t 1); + in + [ + "CONFIG_${i t 0}" + v + ]; + in + map parseLine lines; # parse =lib.kernel.(yes|module|no)|lib.kernel.freeform "foo" # style configuration as found in a patch's extraStructuredConfig into # a list of k, v tuples - parseExtraStructuredConfig = config: lib.attrsets.mapAttrsToList - (k: v: [ "CONFIG_${k}" (v.tristate or v.freeform) ] ) config; + parseExtraStructuredConfig = + config: + lib.attrsets.mapAttrsToList (k: v: [ + "CONFIG_${k}" + (v.tristate or v.freeform) + ]) config; - parsePatchConfig = { extraConfig ? "", extraStructuredConfig ? {}, ... }: - (parseExtraConfig extraConfig) ++ - (parseExtraStructuredConfig extraStructuredConfig); + parsePatchConfig = + { + extraConfig ? "", + extraStructuredConfig ? { }, + ... + }: + (parseExtraConfig extraConfig) ++ (parseExtraStructuredConfig extraStructuredConfig); # parse CONFIG_=[ymn]|"foo" style configuration as found in a config file # into a list of k, v tuples - parseConfig = config: + parseConfig = + config: let parseLine = builtins.match ''(CONFIG_[[:upper:][:digit:]_]+)=(([ymn])|"([^"]*)")''; # get either the [ymn] option or the "foo" option; whichever matched - t = l: let v = (i l 2); in [ (i l 0) (if v != null then v else (i l 3)) ]; + t = + l: + let + v = (i l 2); + in + [ + (i l 0) + (if v != null then v else (i l 3)) + ]; lines = lib.strings.splitString "\n" config; - in map t (builtins.filter (l: l != null) (map parseLine lines)); + in + map t (builtins.filter (l: l != null) (map parseLine lines)); origConfigfile = ./config; - linux-asahi-pkg = { stdenv, lib, fetchFromGitHub, fetchpatch, linuxKernel, - rustPlatform, rustc, rustfmt, rust-bindgen, ... } @ args: + linux-asahi-pkg = + { + stdenv, + lib, + fetchFromGitHub, + fetchpatch, + linuxKernel, + rustPlatform, + rustc, + rustfmt, + rust-bindgen, + ... + }@args: let origConfigText = builtins.readFile origConfigfile; # extraConfig from all patches in order - extraConfig = - lib.fold (patch: ex: ex ++ (parsePatchConfig patch)) [] _kernelPatches; + extraConfig = lib.fold (patch: ex: ex ++ (parsePatchConfig patch)) [ ] _kernelPatches; # config file text for above - extraConfigText = let - text = k: v: if (v == "y") || (v == "m") || (v == "n") - then "${k}=${v}" else ''${k}="${v}"''; - in (map (t: text (i t 0) (i t 1)) extraConfig); + extraConfigText = + let + text = k: v: if (v == "y") || (v == "m") || (v == "n") then "${k}=${v}" else ''${k}="${v}"''; + in + (map (t: text (i t 0) (i t 1)) extraConfig); # final config as a text file path - configfile = if extraConfig == [] then origConfigfile else - writeText "config" '' - ${origConfigText} + configfile = + if extraConfig == [ ] then + origConfigfile + else + writeText "config" '' + ${origConfigText} - # Patches - ${lib.strings.concatStringsSep "\n" extraConfigText} - ''; + # Patches + ${lib.strings.concatStringsSep "\n" extraConfigText} + ''; # final config as an attrset - configAttrs = let - makePair = t: lib.nameValuePair (i t 0) (i t 1); - configList = (parseConfig origConfigText) ++ extraConfig; - in builtins.listToAttrs (map makePair (lib.lists.reverseList configList)); + configAttrs = + let + makePair = t: lib.nameValuePair (i t 0) (i t 1); + configList = (parseConfig origConfigText) ++ extraConfig; + in + builtins.listToAttrs (map makePair (lib.lists.reverseList configList)); # used to (ostensibly) keep compatibility for those running stable versions of nixos rustOlder = version: withRust && (lib.versionOlder rustc.version version); @@ -84,71 +125,94 @@ let rustAtLeast = version: withRust && (lib.versionAtLeast rustc.version version); bindgenAtLeast = version: withRust && (lib.versionAtLeast rust-bindgen.unwrapped.version version); in - (linuxKernel.manualConfig rec { - inherit stdenv lib; + ( + linuxKernel.manualConfig rec { + inherit stdenv lib; - version = "6.6.0-asahi"; - modDirVersion = version; - extraMeta.branch = "6.6"; + version = "6.6.0-asahi"; + modDirVersion = version; + extraMeta.branch = "6.6"; - src = fetchFromGitHub { - # tracking: https://github.com/AsahiLinux/linux/tree/asahi-wip (w/ fedora verification) - owner = "AsahiLinux"; - repo = "linux"; - rev = "asahi-6.6-15"; - hash = "sha256-Jm7wTKWuwd/6ZN0g5F4CNNETiOyGQL31hfSyTDYH85k="; - }; + src = fetchFromGitHub { + # tracking: https://github.com/AsahiLinux/linux/tree/asahi-wip (w/ fedora verification) + owner = "AsahiLinux"; + repo = "linux"; + rev = "asahi-6.6-15"; + hash = "sha256-Jm7wTKWuwd/6ZN0g5F4CNNETiOyGQL31hfSyTDYH85k="; + }; - kernelPatches = [ - { name = "coreutils-fix"; - patch = ./0001-fs-fcntl-accept-more-values-as-F_DUPFD_CLOEXEC-args.patch; - } - # speaker enablement; we assert on the relevant lsp-plugins patch - # before installing speakersafetyd to let the speakers work - { name = "speakers-1"; - patch = fetchpatch { - url = "https://github.com/AsahiLinux/linux/commit/385ea7b5023486aba7919cec8b6b3f6a843a1013.patch"; - hash = "sha256-u7IzhJbUgBPfhJXAcpHw1I6OPzPHc1UKYjH91Ep3QHQ="; - }; - } - { name = "speakers-2"; - patch = fetchpatch { - url = "https://github.com/AsahiLinux/linux/commit/6a24102c06c95951ab992e2d41336cc6d4bfdf23.patch"; - hash = "sha256-wn5x2hN42/kCp/XHBvLWeNLfwlOBB+T6UeeMt2tSg3o="; - }; - } - ] ++ lib.optionals (rustAtLeast "1.75.0") [ - { name = "rustc-1.75.0"; - patch = ./0001-check-in-new-alloc-for-1.75.0.patch; - } - ] ++ lib.optionals (rustAtLeast "1.76.0") [ - { name = "rustc-1.76.0"; - patch = ./rust_1_76_0.patch; - } - ] ++ _kernelPatches; + kernelPatches = + [ + { + name = "coreutils-fix"; + patch = ./0001-fs-fcntl-accept-more-values-as-F_DUPFD_CLOEXEC-args.patch; + } + # speaker enablement; we assert on the relevant lsp-plugins patch + # before installing speakersafetyd to let the speakers work + { + name = "speakers-1"; + patch = fetchpatch { + url = "https://github.com/AsahiLinux/linux/commit/385ea7b5023486aba7919cec8b6b3f6a843a1013.patch"; + hash = "sha256-u7IzhJbUgBPfhJXAcpHw1I6OPzPHc1UKYjH91Ep3QHQ="; + }; + } + { + name = "speakers-2"; + patch = fetchpatch { + url = "https://github.com/AsahiLinux/linux/commit/6a24102c06c95951ab992e2d41336cc6d4bfdf23.patch"; + hash = "sha256-wn5x2hN42/kCp/XHBvLWeNLfwlOBB+T6UeeMt2tSg3o="; + }; + } + ] + ++ lib.optionals (rustAtLeast "1.75.0") [ + { + name = "rustc-1.75.0"; + patch = ./0001-check-in-new-alloc-for-1.75.0.patch; + } + ] + ++ lib.optionals (rustAtLeast "1.76.0") [ + { + name = "rustc-1.76.0"; + patch = ./rust_1_76_0.patch; + } + ] + ++ _kernelPatches; - inherit configfile; - # hide Rust support from the nixpkgs infra to avoid it re-adding the rust packages. - # we can't use it until it's in stable and until we've evaluated the cross-compilation impact. - config = configAttrs // { "CONFIG_RUST" = "n"; }; - } // (args.argsOverride or {})).overrideAttrs (old: if withRust then { - nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ - rust-bindgen - rustfmt - rustc - removeReferencesTo - ]; - # HACK: references shouldn't have been there in the first place - # TODO: remove once 23.05 is obsolete - postFixup = (old.postFixup or "") + '' - if [ -f $dev/lib/modules/${old.version}/build/vmlinux ]; then - remove-references-to -t $out $dev/lib/modules/${old.version}/build/vmlinux - fi - remove-references-to -t $dev $out/Image - ''; - RUST_LIB_SRC = rustPlatform.rustLibSrc; - } else {}); + inherit configfile; + # hide Rust support from the nixpkgs infra to avoid it re-adding the rust packages. + # we can't use it until it's in stable and until we've evaluated the cross-compilation impact. + config = configAttrs // { + "CONFIG_RUST" = "n"; + }; + } + // (args.argsOverride or { }) + ).overrideAttrs + ( + old: + if withRust then + { + nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ + rust-bindgen + rustfmt + rustc + removeReferencesTo + ]; + # HACK: references shouldn't have been there in the first place + # TODO: remove once 23.05 is obsolete + postFixup = + (old.postFixup or "") + + '' + if [ -f $dev/lib/modules/${old.version}/build/vmlinux ]; then + remove-references-to -t $out $dev/lib/modules/${old.version}/build/vmlinux + fi + remove-references-to -t $dev $out/Image + ''; + RUST_LIB_SRC = rustPlatform.rustLibSrc; + } + else + { } + ); linux-asahi = (callPackage linux-asahi-pkg { }); -in lib.recurseIntoAttrs (linuxPackagesFor linux-asahi) - +in +lib.recurseIntoAttrs (linuxPackagesFor linux-asahi) diff --git a/hosts/mac-nixos/apple-silicon-support/packages/m1n1/default.nix b/hosts/mac-nixos/apple-silicon-support/packages/m1n1/default.nix index 86a8bcd..41312d3 100644 --- a/hosts/mac-nixos/apple-silicon-support/packages/m1n1/default.nix +++ b/hosts/mac-nixos/apple-silicon-support/packages/m1n1/default.nix @@ -1,29 +1,33 @@ -{ stdenv -, buildPackages -, lib -, fetchFromGitHub -, python3 -, dtc -, imagemagick -, isRelease ? false -, withTools ? true -, withChainloading ? false -, rust-bin ? null -, customLogo ? null +{ + stdenv, + buildPackages, + lib, + fetchFromGitHub, + python3, + dtc, + imagemagick, + isRelease ? false, + withTools ? true, + withChainloading ? false, + rust-bin ? null, + customLogo ? null, }: assert withChainloading -> rust-bin != null; let - pyenv = python3.withPackages (p: with p; [ - construct - pyserial - ]); + pyenv = python3.withPackages ( + p: with p; [ + construct + pyserial + ] + ); - rustenv = rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal.override { - targets = [ "aarch64-unknown-none-softfloat" ]; - }); -in stdenv.mkDerivation rec { + rustenv = rust-bin.selectLatestNightlyWith ( + toolchain: toolchain.minimal.override { targets = [ "aarch64-unknown-none-softfloat" ]; } + ); +in +stdenv.mkDerivation rec { pname = "m1n1"; version = "1.4.11"; @@ -36,15 +40,14 @@ in stdenv.mkDerivation rec { fetchSubmodules = true; }; - makeFlags = [ "ARCH=${stdenv.cc.targetPrefix}" ] - ++ lib.optional isRelease "RELEASE=1" - ++ lib.optional withChainloading "CHAINLOADING=1"; + makeFlags = [ + "ARCH=${stdenv.cc.targetPrefix}" + ] ++ lib.optional isRelease "RELEASE=1" ++ lib.optional withChainloading "CHAINLOADING=1"; nativeBuildInputs = [ dtc buildPackages.gcc - ] ++ lib.optional withChainloading rustenv - ++ lib.optional (customLogo != null) imagemagick; + ] ++ lib.optional withChainloading rustenv ++ lib.optional (customLogo != null) imagemagick; postPatch = '' substituteInPlace proxyclient/m1n1/asm.py \ @@ -67,35 +70,38 @@ in stdenv.mkDerivation rec { popd &>/dev/null ''; - installPhase = '' - runHook preInstall + installPhase = + '' + runHook preInstall - mkdir -p $out/build - cp build/m1n1.bin $out/build - '' + (lib.optionalString withTools '' - mkdir -p $out/{bin,script,toolchain-bin} - cp -r proxyclient $out/script - cp -r tools $out/script + mkdir -p $out/build + cp build/m1n1.bin $out/build + '' + + (lib.optionalString withTools '' + mkdir -p $out/{bin,script,toolchain-bin} + cp -r proxyclient $out/script + cp -r tools $out/script - for toolpath in $out/script/proxyclient/tools/*.py; do - tool=$(basename $toolpath .py) - script=$out/bin/m1n1-$tool - cat > $script < $script < @@ -204,7 +221,7 @@ in { apcupsd = { enable = true; }; - + grafana = { enable = true; settings.server = { @@ -222,7 +239,10 @@ in { exporters = { node = { enable = true; - enabledCollectors = [ "diskstats" "systemd" ]; + enabledCollectors = [ + "diskstats" + "systemd" + ]; port = 9002; }; smartctl = { @@ -244,23 +264,28 @@ in { }; }; - scrapeConfigs = [{ - job_name = hostname; - static_configs = [{ - targets = [ - "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" - "127.0.0.1:${ - toString config.services.prometheus.exporters.smartctl.port - }" + scrapeConfigs = [ + { + job_name = hostname; + static_configs = [ + { + targets = [ + "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" + "127.0.0.1:${toString config.services.prometheus.exporters.smartctl.port}" + ]; + } ]; - }]; - }]; + } + ]; }; }; systemd.services = { nas-mounts = { - path = [ pkgs.zfs pkgs.bash ]; + path = [ + pkgs.zfs + pkgs.bash + ]; script = '' if test -d /mnt/ssd/ssd_app_data; then echo "NAS ZFS Pools Mounted." @@ -277,7 +302,10 @@ in { }; glances-server = { - path = [ pkgs.bash pkgs.glances ]; + path = [ + pkgs.bash + pkgs.glances + ]; script = '' #!/user/bin/env bash glances -w @@ -298,8 +326,7 @@ in { firewall = { enable = true; allowPing = true; - extraCommands = - "iptables -t raw -A OUTPUT -p udp -m udp --dport 137 -j CT --helper netbios-ns"; # TODO is this needed? + extraCommands = "iptables -t raw -A OUTPUT -p udp -m udp --dport 137 -j CT --helper netbios-ns"; # TODO is this needed? allowedTCPPorts = allowedPorts; allowedUDPPorts = allowedPorts; }; @@ -307,9 +334,9 @@ in { # Configure environment environment = { -# etc."nut/upsd.conf".source = ./upsd.conf; -# etc."nut/upsd.users".source = ./upsd.users; -# etc."nut/upsmon.conf".source = ./upsmon.conf; + # etc."nut/upsd.conf".source = ./upsd.conf; + # etc."nut/upsd.users".source = ./upsd.users; + # etc."nut/upsmon.conf".source = ./upsmon.conf; # List packages installed in system profile. To search, run: # $ nix search wget @@ -355,7 +382,7 @@ in { virt-manager.enable = true; nix-ld.enable = true; }; - + power.ups.ups = { enable = enableUps; mode = "netserver"; @@ -370,7 +397,7 @@ in { upsd = { enable = true; listen = { - address = 0.0.0.0; + address = 0.0 0.0 0.0; port = 3493; }; }; @@ -383,27 +410,25 @@ in { }; # Add UPS monitoring service -# power.upsmon = { -# enable = true; -# # Configure UPS device -# device = "/dev/usb/hiddev1"; # Change this to your UPS device -# driver = "usbhid-ups"; # Change this if your UPS uses a different driver -# # Set UPS monitoring options -# options = { -# # NOTIFYCMD = "/path/to/notify-script.sh"; # Path to your notification script -# POLLFREQ = 5; -# POLLFREQALERT = 5; -# HOSTSYNC = "on"; -# DEADTIME = 15; -# FINALDELAY = 5; -# }; -# }; + # power.upsmon = { + # enable = true; + # # Configure UPS device + # device = "/dev/usb/hiddev1"; # Change this to your UPS device + # driver = "usbhid-ups"; # Change this if your UPS uses a different driver + # # Set UPS monitoring options + # options = { + # # NOTIFYCMD = "/path/to/notify-script.sh"; # Path to your notification script + # POLLFREQ = 5; + # POLLFREQALERT = 5; + # HOSTSYNC = "on"; + # DEADTIME = 15; + # FINALDELAY = 5; + # }; + # }; # Configure nixpkgs nixpkgs = { - overlays = [ - outputs.overlays.nixpkgs-unstable - ]; + overlays = [ outputs.overlays.nixpkgs-unstable ]; config = { # Enable non free @@ -462,11 +487,11 @@ in { isSystemUser = true; uid = 911; group = "jallen-nas"; - extraGroups = [ + extraGroups = [ "jallen-nas" "docker" "podman" - ]; # Enable ‘sudo’ for the user. + ]; # Enable ‘sudo’ for the user. hashedPassword = password; }; @@ -508,5 +533,4 @@ in { # # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . system.stateVersion = "23.11"; # Did you read the comment? - } diff --git a/hosts/nas/hardware-configuration.nix b/hosts/nas/hardware-configuration.nix index 79045c1..7300c4b 100644 --- a/hosts/nas/hardware-configuration.nix +++ b/hosts/nas/hardware-configuration.nix @@ -1,13 +1,25 @@ # 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, ... }: +{ + config, + lib, + pkgs, + modulesPath, + ... +}: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = - [ "nvme" "mpt3sas" "xhci_pci" "ahci" "uas" "sd_mod" ]; + boot.initrd.availableKernelModules = [ + "nvme" + "mpt3sas" + "xhci_pci" + "ahci" + "uas" + "sd_mod" + ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; @@ -15,7 +27,11 @@ fileSystems."/" = { device = "none"; fsType = "tmpfs"; - options = [ "defaults" "size=32G" "mode=755" ]; + options = [ + "defaults" + "size=32G" + "mode=755" + ]; }; fileSystems."/boot" = { @@ -26,35 +42,53 @@ fileSystems."/nix" = { device = "/dev/disk/by-uuid/85e2fa30-816f-4457-80a1-9f88b9ab77b3"; fsType = "btrfs"; - options = [ "subvol=nix" "compress-force=zstd" "noatime" ]; + options = [ + "subvol=nix" + "compress-force=zstd" + "noatime" + ]; }; fileSystems."/etc" = { device = "/dev/disk/by-uuid/85e2fa30-816f-4457-80a1-9f88b9ab77b3"; fsType = "btrfs"; - options = [ "subvol=etc" "compress-force=zstd" "noatime" ]; + options = [ + "subvol=etc" + "compress-force=zstd" + "noatime" + ]; }; fileSystems."/root" = { device = "/dev/disk/by-uuid/85e2fa30-816f-4457-80a1-9f88b9ab77b3"; fsType = "btrfs"; - options = [ "subvol=root" "compress-force=zstd" "noatime" ]; + options = [ + "subvol=root" + "compress-force=zstd" + "noatime" + ]; }; fileSystems."/var/log" = { device = "/dev/disk/by-uuid/85e2fa30-816f-4457-80a1-9f88b9ab77b3"; fsType = "btrfs"; - options = [ "subvol=log" "compress-force=zstd" "noatime" ]; + options = [ + "subvol=log" + "compress-force=zstd" + "noatime" + ]; }; fileSystems."/home" = { device = "/dev/disk/by-uuid/85e2fa30-816f-4457-80a1-9f88b9ab77b3"; fsType = "btrfs"; - options = [ "subvol=home" "compress-force=zstd" ]; + options = [ + "subvol=home" + "compress-force=zstd" + ]; }; - swapDevices = - [{ device = "/dev/disk/by-uuid/c08ba901-a8a9-4006-9688-002bb24da1b6"; }]; + swapDevices = [ { device = "/dev/disk/by-uuid/c08ba901-a8a9-4006-9688-002bb24da1b6"; } ]; # 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 @@ -76,6 +110,5 @@ # networking.interfaces.wlp6s0.useDHCP = lib.mkDefault true; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = - lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; } diff --git a/hosts/pi4/configuration.nix b/hosts/pi4/configuration.nix index c864414..04f6695 100644 --- a/hosts/pi4/configuration.nix +++ b/hosts/pi4/configuration.nix @@ -2,29 +2,42 @@ # 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, ... }: +{ + config, + lib, + pkgs, + ... +}: let user = "matt"; - password = - "$y$j9T$EkPXmsmIMFFZ.WRrBYCxS1$P0kwo6e4.WM5DsqUcEqWC3MrZp5KfCjxffraMFZWu06"; + password = "$y$j9T$EkPXmsmIMFFZ.WRrBYCxS1$P0kwo6e4.WM5DsqUcEqWC3MrZp5KfCjxffraMFZWu06"; SSID = "Joey’s Jungle"; SSIDpassword = "kR8v&3Qd"; interface = "wlan0"; timezone = "America/Chicago"; hostname = "nixos-pi4"; -in { - imports = [ # Include the results of the hardware scan. +in +{ + imports = [ + # Include the results of the hardware scan. ./hardware-configuration.nix ./docker-pi4.nix ]; # Enable nix flakes and nix-command tools - nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; boot = { kernelPackages = pkgs.linuxKernel.packages.linux_rpi4; - initrd.availableKernelModules = [ "xhci_pci" "usbhid" "usb_storage" ]; + initrd.availableKernelModules = [ + "xhci_pci" + "usbhid" + "usb_storage" + ]; loader = { grub.enable = false; generic-extlinux-compatible.enable = true; @@ -43,7 +56,12 @@ in { }; }; - environment.systemPackages = with pkgs; [ vim raspberrypi-eeprom htop git ]; + environment.systemPackages = with pkgs; [ + vim + raspberrypi-eeprom + htop + git + ]; services.openssh.enable = true; @@ -52,7 +70,10 @@ in { users."${user}" = { isNormalUser = true; initialHashedPassword = password; - extraGroups = [ "wheel" "docker" ]; + extraGroups = [ + "wheel" + "docker" + ]; }; }; @@ -76,6 +97,4 @@ in { # # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . system.stateVersion = "24.05"; # Did you read the comment? - } - diff --git a/hosts/pi4/docker-pi4.nix b/hosts/pi4/docker-pi4.nix index 876e91a..090e371 100644 --- a/hosts/pi4/docker-pi4.nix +++ b/hosts/pi4/docker-pi4.nix @@ -6,7 +6,10 @@ virtualisation.oci-containers.containers."portainer" = { autoStart = true; image = "portainer/portainer-ce"; - ports = [ "8000:8000" "9443:9443" ]; + ports = [ + "8000:8000" + "9443:9443" + ]; volumes = [ "/var/run/docker.sock:/var/run/docker.sock" "/media/T5/docker/config/portainer:/data" @@ -25,7 +28,8 @@ "/media/T5/tv:/tv" ]; ports = [ "8096:8096" ]; - environment = { JELLYFIN_LOG_DIR = "/log"; }; + environment = { + JELLYFIN_LOG_DIR = "/log"; + }; }; - } diff --git a/hosts/pi4/hardware-configuration.nix b/hosts/pi4/hardware-configuration.nix index 7623de6..a6f807e 100644 --- a/hosts/pi4/hardware-configuration.nix +++ b/hosts/pi4/hardware-configuration.nix @@ -1,7 +1,13 @@ # 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, ... }: +{ + config, + lib, + pkgs, + modulesPath, + ... +}: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; @@ -26,8 +32,7 @@ fsType = "vfat"; }; - swapDevices = - [{ device = "/dev/disk/by-uuid/d9909ef7-c345-48f7-b210-ad7cbe72224b"; }]; + swapDevices = [ { device = "/dev/disk/by-uuid/d9909ef7-c345-48f7-b210-ad7cbe72224b"; } ]; # 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 diff --git a/modules/apps/collabora/default.nix b/modules/apps/collabora/default.nix index abf989f..33b15c7 100644 --- a/modules/apps/collabora/default.nix +++ b/modules/apps/collabora/default.nix @@ -1,7 +1,14 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.collabora; -in { +let + cfg = config.nas-apps.collabora; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { diff --git a/modules/apps/collabora/options.nix b/modules/apps/collabora/options.nix index 46fe94e..f14fcc0 100644 --- a/modules/apps/collabora/options.nix +++ b/modules/apps/collabora/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.collabora = { enable = mkEnableOption "collabora docker service"; @@ -37,6 +38,5 @@ with lib; { type = types.str; default = "America/Chicago"; }; - }; } diff --git a/modules/apps/deluge/default.nix b/modules/apps/deluge/default.nix index 03b1b6f..e7edc37 100644 --- a/modules/apps/deluge/default.nix +++ b/modules/apps/deluge/default.nix @@ -1,13 +1,23 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.deluge; -in { +let + cfg = config.nas-apps.deluge; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { systemd.services.deluge-docker = { - path = [ pkgs.bash pkgs.docker ]; + path = [ + pkgs.bash + pkgs.docker + ]; script = '' set -e exec docker run \ diff --git a/modules/apps/deluge/options.nix b/modules/apps/deluge/options.nix index 609f29d..2231fd2 100644 --- a/modules/apps/deluge/options.nix +++ b/modules/apps/deluge/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.deluge = { enable = mkEnableOption "deluge docker service"; @@ -47,6 +48,5 @@ with lib; { type = types.str; default = "America/Chicago"; }; - }; } diff --git a/modules/apps/discover-wrapped/default.nix b/modules/apps/discover-wrapped/default.nix index 82e1ce5..1e99803 100644 --- a/modules/apps/discover-wrapped/default.nix +++ b/modules/apps/discover-wrapped/default.nix @@ -1,8 +1,13 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: with lib; -let +let cfg = config.apps.discover-wrapped; - + # discover-wrapper is needed as of 1/24/24 since PackageKit does not work correctly so this removes error messages. discover-wrapped = pkgs.symlinkJoin { name = "discover-flatpak-backend"; @@ -15,7 +20,7 @@ let in { imports = [ ./options.nix ]; - + config = mkIf cfg.enable { # Configure environment environment.systemPackages = [ discover-wrapped ]; diff --git a/modules/apps/discover-wrapped/options.nix b/modules/apps/discover-wrapped/options.nix index 7688a3a..335781c 100644 --- a/modules/apps/discover-wrapped/options.nix +++ b/modules/apps/discover-wrapped/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.apps.discover-wrapped = { enable = mkEnableOption "enable discover with flatpak"; }; diff --git a/modules/apps/homarr/default.nix b/modules/apps/homarr/default.nix index 9643033..5a3decc 100644 --- a/modules/apps/homarr/default.nix +++ b/modules/apps/homarr/default.nix @@ -1,7 +1,14 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.homarr; -in { +let + cfg = config.nas-apps.homarr; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { @@ -15,7 +22,7 @@ in { "${cfg.configPath}/data:/data" "/var/run/docker.sock:/var/run/docker.sock" "/var/run/podman/podman.sock:/var/run/podman.sock" - ]; + ]; environment = { # PUID = cfg.puid; # PGID = cfg.pgid; diff --git a/modules/apps/homarr/options.nix b/modules/apps/homarr/options.nix index ab2ce17..3ef36a5 100644 --- a/modules/apps/homarr/options.nix +++ b/modules/apps/homarr/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.homarr = { enable = mkEnableOption "homarr docker service"; diff --git a/modules/apps/homepage/default.nix b/modules/apps/homepage/default.nix index 35f5e56..798954d 100644 --- a/modules/apps/homepage/default.nix +++ b/modules/apps/homepage/default.nix @@ -1,7 +1,14 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.homepage; -in { +let + cfg = config.nas-apps.homepage; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { @@ -13,7 +20,7 @@ in { "${cfg.configPath}:/app/config" "/var/run/docker.sock:/var/run/docker.sock" "/var/run/podman/podman.sock:/var/run/podman.sock" - ]; + ]; environment = { # PUID = cfg.puid; # PGID = cfg.pgid; diff --git a/modules/apps/homepage/options.nix b/modules/apps/homepage/options.nix index 063993e..893b651 100644 --- a/modules/apps/homepage/options.nix +++ b/modules/apps/homepage/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.homepage = { enable = mkEnableOption "homepage docker service"; diff --git a/modules/apps/jackett/default.nix b/modules/apps/jackett/default.nix index 3c40209..0b56aac 100644 --- a/modules/apps/jackett/default.nix +++ b/modules/apps/jackett/default.nix @@ -1,7 +1,14 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.jackett; -in { +let + cfg = config.nas-apps.jackett; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { diff --git a/modules/apps/jackett/options.nix b/modules/apps/jackett/options.nix index 09c3ae9..f9fd42e 100644 --- a/modules/apps/jackett/options.nix +++ b/modules/apps/jackett/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.jackett = { enable = mkEnableOption "jackett docker service"; diff --git a/modules/apps/jellyfin/default.nix b/modules/apps/jellyfin/default.nix index 27206d3..614591f 100644 --- a/modules/apps/jellyfin/default.nix +++ b/modules/apps/jellyfin/default.nix @@ -1,54 +1,35 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.jellyfin; -in { +let + cfg = config.nas-apps.jellyfin; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { -# systemd.services.jellyfin-nvidia-docker = { -# path = [ pkgs.bash pkgs.docker ]; -# script = '' -# set -e -# exec sudo docker run \ -# --rm \ -# --gpus all \ -# --runtime=nvidia \ -# --name=${cfg.name} \ -# -e PUID=${cfg.puid} \ -# -e PGID=${cfg.pgid} \ -# -e TZ=${cfg.timeZone} \ -# -e 'NVIDIA_DRIVER_CAPABILITIES'='all' \ -# -e 'NVIDIA_VISIBLE_DEVICES'='all' \ -# -p ${cfg.port}:8096 \ -# -v '${cfg.configPath}:/config' \ -# -v '${cfg.moviesPath}:/data/movies' \ -# -v '${cfg.tvPath}:/data/tv' \ -# ${cfg.image}:latest -# ''; -# wantedBy = [ "multi-user.target" ]; -# }; -# }; -# } - - # nix-docker - virtualisation.oci-containers.containers.${cfg.name} = { - autoStart = true; - image = cfg.image; - extraOptions = [ "--device=nvidia.com/gpu=0" ]; - volumes = [ - "${cfg.configPath}:/config" - "${cfg.moviesPath}:/data/movies" - "${cfg.tvPath}:/data/tv" - ]; - ports = [ "${cfg.port}:8096" ]; - environment = { - NVIDIA_VISIBLE_DEVICES = "all"; - NVIDIA_DRIVER_CAPABILITIES = "all"; - PUID = cfg.puid; - PGID = cfg.pgid; - TZ = cfg.timeZone; - }; + virtualisation.oci-containers.containers.${cfg.name} = { + autoStart = true; + image = cfg.image; + extraOptions = [ "--device=nvidia.com/gpu=0" ]; + volumes = [ + "${cfg.configPath}:/config" + "${cfg.moviesPath}:/data/movies" + "${cfg.tvPath}:/data/tv" + ]; + ports = [ "${cfg.port}:8096" ]; + environment = { + NVIDIA_VISIBLE_DEVICES = "all"; + NVIDIA_DRIVER_CAPABILITIES = "all"; + PUID = cfg.puid; + PGID = cfg.pgid; + TZ = cfg.timeZone; + }; + }; }; -}; } diff --git a/modules/apps/jellyfin/options.nix b/modules/apps/jellyfin/options.nix index 33d573f..68972aa 100644 --- a/modules/apps/jellyfin/options.nix +++ b/modules/apps/jellyfin/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.jellyfin = { enable = mkEnableOption "jellyfin docker service"; @@ -52,6 +53,5 @@ with lib; { type = types.str; default = "America/Chicago"; }; - }; } diff --git a/modules/apps/jellyseerr/default.nix b/modules/apps/jellyseerr/default.nix index 4a9461a..9139832 100644 --- a/modules/apps/jellyseerr/default.nix +++ b/modules/apps/jellyseerr/default.nix @@ -1,7 +1,14 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.jellyseerr; -in { +let + cfg = config.nas-apps.jellyseerr; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { diff --git a/modules/apps/jellyseerr/options.nix b/modules/apps/jellyseerr/options.nix index 6115e9a..9157d0d 100644 --- a/modules/apps/jellyseerr/options.nix +++ b/modules/apps/jellyseerr/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.jellyseerr = { enable = mkEnableOption "jellyseerr docker service"; @@ -42,6 +43,5 @@ with lib; { type = types.str; default = "America/Chicago"; }; - }; } diff --git a/modules/apps/mariadb/default.nix b/modules/apps/mariadb/default.nix index 0e4be10..7a69ed1 100644 --- a/modules/apps/mariadb/default.nix +++ b/modules/apps/mariadb/default.nix @@ -1,7 +1,14 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.mariadb; -in { +let + cfg = config.nas-apps.mariadb; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { diff --git a/modules/apps/mariadb/options.nix b/modules/apps/mariadb/options.nix index cbaf1e0..10260d6 100644 --- a/modules/apps/mariadb/options.nix +++ b/modules/apps/mariadb/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.mariadb = { enable = mkEnableOption "mariadb docker service"; diff --git a/modules/apps/nextcloud/default.nix b/modules/apps/nextcloud/default.nix index 7300b30..a4e9946 100644 --- a/modules/apps/nextcloud/default.nix +++ b/modules/apps/nextcloud/default.nix @@ -1,15 +1,28 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.nextcloud; -in { +let + cfg = config.nas-apps.nextcloud; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { virtualisation.oci-containers.containers."${cfg.name}" = { autoStart = cfg.autoStart; image = cfg.image; - ports = [ "${cfg.httpPort}:80" "${cfg.httpsPort}:443" ]; - volumes = [ "${cfg.configPath}:/config" "${cfg.dataPath}:/data" ]; + ports = [ + "${cfg.httpPort}:80" + "${cfg.httpsPort}:443" + ]; + volumes = [ + "${cfg.configPath}:/config" + "${cfg.dataPath}:/data" + ]; environment = { PUID = cfg.puid; PGID = cfg.pgid; diff --git a/modules/apps/nextcloud/options.nix b/modules/apps/nextcloud/options.nix index 4dad213..198e0a0 100644 --- a/modules/apps/nextcloud/options.nix +++ b/modules/apps/nextcloud/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.nextcloud = { enable = mkEnableOption "nextcloud docker service"; diff --git a/modules/apps/ollama/default.nix b/modules/apps/ollama/default.nix index f9a9906..c9bca76 100644 --- a/modules/apps/ollama/default.nix +++ b/modules/apps/ollama/default.nix @@ -1,13 +1,23 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.ollama; -in { +let + cfg = config.nas-apps.ollama; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { systemd.services.ollama-docker = { - path = [ pkgs.bash pkgs.docker ]; + path = [ + pkgs.bash + pkgs.docker + ]; script = '' set -e exec docker run \ diff --git a/modules/apps/ollama/options.nix b/modules/apps/ollama/options.nix index b36de92..f85715f 100644 --- a/modules/apps/ollama/options.nix +++ b/modules/apps/ollama/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.ollama = { enable = mkEnableOption "ollama docker service"; @@ -42,6 +43,5 @@ with lib; { type = types.str; default = "America/Chicago"; }; - }; } diff --git a/modules/apps/open-webui/default.nix b/modules/apps/open-webui/default.nix index 191542a..192a374 100644 --- a/modules/apps/open-webui/default.nix +++ b/modules/apps/open-webui/default.nix @@ -1,33 +1,34 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.open-webui; -in { +let + cfg = config.nas-apps.open-webui; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { - systemd.services.open-webui-docker = { - path = [ pkgs.bash pkgs.docker ]; - script = '' - set -e - exec docker run \ - --rm \ - --gpus all \ - --runtime=nvidia \ - --name=${cfg.name} \ - -e PUID=${cfg.puid} \ - -e PGID=${cfg.pgid} \ - -e TZ=${cfg.timeZone} \ - -e 'NVIDIA_DRIVER_CAPABILITIES'='all' \ - -e 'NVIDIA_VISIBLE_DEVICES'='all' \ - -p ${cfg.port}:8080 \ - -v '${cfg.configPath}:/app/backend/data' \ - -v '/mnt/ssd/nix-app-data/ollama:/root/.ollama' \ - ${cfg.image} - ''; - wantedBy = [ "multi-user.target" ]; + virtualisation.oci-containers.containers.${cfg.name} = { + autoStart = true; + image = cfg.image; + extraOptions = [ "--device=nvidia.com/gpu=0" ]; + volumes = [ + "${cfg.configPath}:/app/backend/data" + "${cfg.ollamaPath}:/root/.ollama" + ]; + ports = [ "${cfg.port}:8080" ]; + environment = { + NVIDIA_VISIBLE_DEVICES = "all"; + NVIDIA_DRIVER_CAPABILITIES = "all"; + PUID = cfg.puid; + PGID = cfg.pgid; + TZ = cfg.timeZone; + }; }; }; } -# --add-host=host.docker.internal:host-gateway \ -# -e 'OLLAMA_BASE_URL'='http://10.0.1.18:11434' \ diff --git a/modules/apps/open-webui/options.nix b/modules/apps/open-webui/options.nix index 8d5e095..f00d6cc 100644 --- a/modules/apps/open-webui/options.nix +++ b/modules/apps/open-webui/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.open-webui = { enable = mkEnableOption "open-webui docker service"; @@ -42,6 +43,5 @@ with lib; { type = types.str; default = "America/Chicago"; }; - }; } diff --git a/modules/apps/orca-slicer/default.nix b/modules/apps/orca-slicer/default.nix index 6e2321a..e6fc881 100644 --- a/modules/apps/orca-slicer/default.nix +++ b/modules/apps/orca-slicer/default.nix @@ -1,14 +1,24 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.orca-slicer; -in { +let + cfg = config.nas-apps.orca-slicer; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { virtualisation.oci-containers.containers."${cfg.name}" = { autoStart = cfg.autoStart; image = cfg.image; - ports = [ "${cfg.httpPort}:3000" "${cfg.httpsPort}:3001" ]; + ports = [ + "${cfg.httpPort}:3000" + "${cfg.httpsPort}:3001" + ]; volumes = [ "${cfg.configPath}:/config" ]; environment = { PUID = cfg.puid; diff --git a/modules/apps/orca-slicer/options.nix b/modules/apps/orca-slicer/options.nix index 45ef551..e73830d 100644 --- a/modules/apps/orca-slicer/options.nix +++ b/modules/apps/orca-slicer/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.orca-slicer = { enable = mkEnableOption "orca slicer docker service"; diff --git a/modules/apps/radarr/default.nix b/modules/apps/radarr/default.nix index b893091..f2f0a97 100644 --- a/modules/apps/radarr/default.nix +++ b/modules/apps/radarr/default.nix @@ -1,7 +1,14 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.radarr; -in { +let + cfg = config.nas-apps.radarr; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { diff --git a/modules/apps/radarr/options.nix b/modules/apps/radarr/options.nix index 857a9f0..bbba18b 100644 --- a/modules/apps/radarr/options.nix +++ b/modules/apps/radarr/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.radarr = { enable = mkEnableOption "radarr docker service"; diff --git a/modules/apps/sabnzbd/default.nix b/modules/apps/sabnzbd/default.nix index 652c8a9..8bec8a9 100644 --- a/modules/apps/sabnzbd/default.nix +++ b/modules/apps/sabnzbd/default.nix @@ -1,7 +1,14 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.sabnzbd; -in { +let + cfg = config.nas-apps.sabnzbd; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { diff --git a/modules/apps/sabnzbd/options.nix b/modules/apps/sabnzbd/options.nix index 832731b..f88a3cb 100644 --- a/modules/apps/sabnzbd/options.nix +++ b/modules/apps/sabnzbd/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.sabnzbd = { enable = mkEnableOption "sabnzbd docker service"; @@ -62,6 +63,5 @@ with lib; { type = types.str; default = "America/Chicago"; }; - }; } diff --git a/modules/apps/sonarr/default.nix b/modules/apps/sonarr/default.nix index e40f70e..ae9802c 100644 --- a/modules/apps/sonarr/default.nix +++ b/modules/apps/sonarr/default.nix @@ -1,7 +1,14 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.sonarr; -in { +let + cfg = config.nas-apps.sonarr; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { diff --git a/modules/apps/sonarr/options.nix b/modules/apps/sonarr/options.nix index 8ea515d..77c8d1c 100644 --- a/modules/apps/sonarr/options.nix +++ b/modules/apps/sonarr/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.sonarr = { enable = mkEnableOption "sonarr docker service"; diff --git a/modules/apps/swag/default.nix b/modules/apps/swag/default.nix index d524082..6ba9c77 100644 --- a/modules/apps/swag/default.nix +++ b/modules/apps/swag/default.nix @@ -1,20 +1,39 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.swag; -in { +let + cfg = config.nas-apps.swag; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { networking.firewall = { - allowedTCPPorts = [ cfg.httpPort cfg.httpsPort 81 ]; - allowedUDPPorts = [ cfg.httpPort cfg.httpsPort 81 ]; + allowedTCPPorts = [ + cfg.httpPort + cfg.httpsPort + 81 + ]; + allowedUDPPorts = [ + cfg.httpPort + cfg.httpsPort + 81 + ]; }; virtualisation.oci-containers.containers."${cfg.name}" = { autoStart = cfg.autoStart; image = cfg.image; - ports = [ "${toString cfg.httpPort}:80" "${toString cfg.httpsPort}:443" "81:81" ]; + ports = [ + "${toString cfg.httpPort}:80" + "${toString cfg.httpsPort}:443" + "81:81" + ]; volumes = [ "${cfg.configPath}:/config" ]; environment = { PUID = cfg.puid; @@ -24,7 +43,7 @@ in { URL = cfg.url; VALIDATION = cfg.validation; SUBDOMAINS = cfg.subdomains; - DOCKER_MODS="linuxserver/mods:swag-dashboard"; + DOCKER_MODS = "linuxserver/mods:swag-dashboard"; }; }; }; diff --git a/modules/apps/swag/options.nix b/modules/apps/swag/options.nix index c62e93f..d152850 100644 --- a/modules/apps/swag/options.nix +++ b/modules/apps/swag/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.swag = { enable = mkEnableOption "swag docker service"; diff --git a/modules/apps/vscode/default.nix b/modules/apps/vscode/default.nix index a504d80..10bd8a1 100644 --- a/modules/apps/vscode/default.nix +++ b/modules/apps/vscode/default.nix @@ -1,7 +1,14 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-apps.vscode; -in { +let + cfg = config.nas-apps.vscode; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { @@ -9,11 +16,11 @@ in { autoStart = cfg.autoStart; image = cfg.image; ports = [ "${cfg.port}:8443" ]; - volumes = [ + volumes = [ "${cfg.configPath}:/config" "/mnt/ssd/ssd_app_data:/ssd_app_data" "/home/admin/nix-config:/nix-config" - ]; + ]; environment = { PUID = cfg.puid; PGID = cfg.pgid; diff --git a/modules/apps/vscode/options.nix b/modules/apps/vscode/options.nix index ba26064..5f70894 100644 --- a/modules/apps/vscode/options.nix +++ b/modules/apps/vscode/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-apps.vscode = { enable = mkEnableOption "vscode docker service"; diff --git a/modules/default.nix b/modules/default.nix index 9e1b4c9..6325b06 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,4 +1,5 @@ -{ ... }: { +{ ... }: +{ imports = [ ./samba ./apps/collabora diff --git a/modules/samba/default.nix b/modules/samba/default.nix index 61ccc04..a7f4681 100644 --- a/modules/samba/default.nix +++ b/modules/samba/default.nix @@ -1,7 +1,14 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.nas-samba; -in { +let + cfg = config.nas-samba; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { @@ -39,24 +46,27 @@ in { guest account = nobody map to guest = bad user ''; - shares = let - make = name: share: - nameValuePair "${name}" { - path = share.sharePath; - public = if share.enableTimeMachine then "no" else "yes"; - private = if !share.public || share.enableTimeMachine then "yes" else "no"; - browseable = if share.browseable then "yes" else "no"; - writable = "yes"; - "read only" = if share.readOnly then "yes" else "no"; - "guest ok" = if share.guestOk then "yes" else "no"; - "create mask" = share.createMask; - "directory mask" = share.directoryMask; - "fruit:aapl" = if share.enableTimeMachine then "yes" else "no"; - "fruit:time machine" = if share.enableTimeMachine then "yes" else "no"; - "vfs objects" = "catia fruit streams_xattr"; - "fruit:time machine max size" = share.timeMachineMaxSize; - }; - in mapAttrs' make cfg.shares; + shares = + let + make = + name: share: + nameValuePair "${name}" { + path = share.sharePath; + public = if share.enableTimeMachine then "no" else "yes"; + private = if !share.public || share.enableTimeMachine then "yes" else "no"; + browseable = if share.browseable then "yes" else "no"; + writable = "yes"; + "read only" = if share.readOnly then "yes" else "no"; + "guest ok" = if share.guestOk then "yes" else "no"; + "create mask" = share.createMask; + "directory mask" = share.directoryMask; + "fruit:aapl" = if share.enableTimeMachine then "yes" else "no"; + "fruit:time machine" = if share.enableTimeMachine then "yes" else "no"; + "vfs objects" = "catia fruit streams_xattr"; + "fruit:time machine max size" = share.timeMachineMaxSize; + }; + in + mapAttrs' make cfg.shares; }; }; } diff --git a/modules/samba/options.nix b/modules/samba/options.nix index 282bd60..c5784c0 100644 --- a/modules/samba/options.nix +++ b/modules/samba/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.nas-samba = { enable = mkEnableOption "nas samba service"; @@ -21,46 +22,48 @@ with lib; { }; shares = mkOption { - type = types.attrsOf (types.submodule { - options = { - public = mkOption { - type = types.bool; - default = false; + type = types.attrsOf ( + types.submodule { + options = { + public = mkOption { + type = types.bool; + default = false; + }; + sharePath = mkOption { + type = types.str; + default = ""; + }; + readOnly = mkOption { + type = types.bool; + default = false; + }; + browseable = mkOption { + type = types.bool; + default = true; + }; + guestOk = mkOption { + type = types.bool; + default = true; + }; + createMask = mkOption { + type = types.str; + default = "0774"; + }; + directoryMask = mkOption { + type = types.str; + default = "0775"; + }; + enableTimeMachine = mkOption { + type = types.bool; + default = false; + }; + timeMachineMaxSize = mkOption { + type = types.str; + default = "0K"; + }; }; - sharePath = mkOption { - type = types.str; - default = ""; - }; - readOnly = mkOption { - type = types.bool; - default = false; - }; - browseable = mkOption { - type = types.bool; - default = true; - }; - guestOk = mkOption { - type = types.bool; - default = true; - }; - createMask = mkOption { - type = types.str; - default = "0774"; - }; - directoryMask = mkOption { - type = types.str; - default = "0775"; - }; - enableTimeMachine = mkOption { - type = types.bool; - default = false; - }; - timeMachineMaxSize = mkOption { - type = types.str; - default = "0K"; - }; - }; - }); + } + ); default = { }; }; }; diff --git a/overlays/default.nix b/overlays/default.nix index 17e1a8d..0942b13 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,4 +1,5 @@ -{inputs, ...}: { +{ inputs, ... }: +{ nixpkgs-unstable = final: _prev: { unstable = import inputs.nixpkgs-unstable { @@ -7,4 +8,3 @@ }; }; } - diff --git a/share/amd/default.nix b/share/amd/default.nix index 2737a52..57d2f51 100644 --- a/share/amd/default.nix +++ b/share/amd/default.nix @@ -1,13 +1,18 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.share.hardware.amd; -in { +let + cfg = config.share.hardware.amd; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { - boot.kernelParams = [ - (if cfg.enable then "amdgpu.ppfeaturemask=0xffffffff" else null) - ]; + boot.kernelParams = [ (if cfg.enable then "amdgpu.ppfeaturemask=0xffffffff" else null) ]; # Configure programs programs.corectrl.enable = cfg.corectrl.enable; @@ -47,7 +52,10 @@ in { # nixpkg is broken so need to manually define systemd.services.lactd = mkIf cfg.lact.enable { description = "AMDGPU Control Daemon"; - path = [ pkgs.bash pkgs.lact ]; + path = [ + pkgs.bash + pkgs.lact + ]; script = '' lact daemon ''; diff --git a/share/amd/options.nix b/share/amd/options.nix index 09cea98..7fa24bf 100644 --- a/share/amd/options.nix +++ b/share/amd/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.share.hardware.amd = { enable = mkEnableOption "amd hardware config"; diff --git a/share/default.nix b/share/default.nix index 3c6aa9d..7fd2a9c 100644 --- a/share/default.nix +++ b/share/default.nix @@ -1 +1,8 @@ -{ ... }: { imports = [ ./amd ./nvidia ./gaming ]; } +{ ... }: +{ + imports = [ + ./amd + ./nvidia + ./gaming + ]; +} diff --git a/share/gaming/default.nix b/share/gaming/default.nix index d3114cb..af22b32 100644 --- a/share/gaming/default.nix +++ b/share/gaming/default.nix @@ -1,19 +1,26 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.share.gaming; -in { +let + cfg = config.share.gaming; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { # Network option required using sysctl to let Ubisoft Connect work as of 7-12-2023 boot.kernel.sysctl."net.ipv4.tcp_mtu_probing" = 1; - + # Configure programs programs.steam = { enable = true; # Open ports in the firewall for Steam Remote Play remotePlay.openFirewall = true; - # Open ports in the firewall for Source Dedicated Server + # Open ports in the firewall for Source Dedicated Server dedicatedServer.openFirewall = true; }; @@ -29,18 +36,18 @@ in { # Configure nixpkgs nixpkgs.config.packageOverrides = pkgs: { steam = pkgs.steam.override { - extraPkgs = pkgs: - with pkgs; [ - xorg.libXcursor - xorg.libXi - xorg.libXinerama - xorg.libXScrnSaver - libpng - libpulseaudio - libvorbis - stdenv.cc.cc.lib - libkrb5 - keyutils + extraPkgs = + pkgs: with pkgs; [ + xorg.libXcursor + xorg.libXi + xorg.libXinerama + xorg.libXScrnSaver + libpng + libpulseaudio + libvorbis + stdenv.cc.cc.lib + libkrb5 + keyutils ]; }; }; diff --git a/share/gaming/options.nix b/share/gaming/options.nix index f9407fa..7cadef1 100644 --- a/share/gaming/options.nix +++ b/share/gaming/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.share.gaming = { enable = mkEnableOption "enable gaming stuffs"; }; diff --git a/share/impermanence/default.nix b/share/impermanence/default.nix index d4f3aaa..f56bf20 100644 --- a/share/impermanence/default.nix +++ b/share/impermanence/default.nix @@ -1,4 +1,13 @@ -{ pkgs, lib, LT, config, utils, inputs, ... }@args: { +{ + pkgs, + lib, + LT, + config, + utils, + inputs, + ... +}@args: +{ # Set up impernance configuration for things like bluetooth # In this configuration with /etc and /var/log being persistent, only directories outside of that need to be done here. See hardware configuration for all mountpoints. @@ -17,9 +26,13 @@ mode = "u=rwx,g=rx,o="; } ]; - files = [{ - file = "/etc/nix/id_rsa"; - parentDirectory = { mode = "u=rwx,g=,o="; }; - }]; + files = [ + { + file = "/etc/nix/id_rsa"; + parentDirectory = { + mode = "u=rwx,g=,o="; + }; + } + ]; }; } diff --git a/share/nvidia/default.nix b/share/nvidia/default.nix index b761c78..fbd24f9 100644 --- a/share/nvidia/default.nix +++ b/share/nvidia/default.nix @@ -1,17 +1,25 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: with lib; -let cfg = config.share.hardware.nvidia; -in { +let + cfg = config.share.hardware.nvidia; +in +{ imports = [ ./options.nix ]; config = mkIf cfg.enable { hardware = { # Nvidia nvidia = { - package = if cfg.enableBeta then - config.boot.kernelPackages.nvidiaPackages.beta - else - config.boot.kernelPackages.nvidiaPackages.latest; + package = + if cfg.enableBeta then + config.boot.kernelPackages.nvidiaPackages.beta + else + config.boot.kernelPackages.nvidiaPackages.latest; # Modesetting is required. modesetting.enable = true; diff --git a/share/nvidia/options.nix b/share/nvidia/options.nix index 5b1befd..6abcb98 100644 --- a/share/nvidia/options.nix +++ b/share/nvidia/options.nix @@ -1,5 +1,6 @@ { lib, ... }: -with lib; { +with lib; +{ options.share.hardware.nvidia = { enable = mkEnableOption "nvidia hardware config";