aboutsummaryrefslogtreecommitdiff
path: root/modules/teh-nix
diff options
context:
space:
mode:
authorDylan <boss@tehbox.org>2026-10-17 22:02:09 +1300
committerDylan <boss@tehbox.org>2026-10-17 22:04:40 +1300
commit008b591a0a5942ae42f4c07a5abbee4dbd2d0743 (patch)
tree0ae88a36bc00ede3b43b31489adae633dc54e8cd /modules/teh-nix
parent280e1bbe5e733128a451260685cc8ecd10a042a3 (diff)
downloadnixos-configuration-008b591a0a5942ae42f4c07a5abbee4dbd2d0743.tar.gz
nixos-configuration-008b591a0a5942ae42f4c07a5abbee4dbd2d0743.zip
feat: Formatting changes
Diffstat (limited to 'modules/teh-nix')
-rw-r--r--modules/teh-nix/cgit.nix304
-rw-r--r--modules/teh-nix/nix.nix75
-rw-r--r--modules/teh-nix/nvidia.nix71
-rw-r--r--modules/teh-nix/xorg.nix98
4 files changed, 284 insertions, 264 deletions
diff --git a/modules/teh-nix/cgit.nix b/modules/teh-nix/cgit.nix
index ff3aee0..0c2d8e5 100644
--- a/modules/teh-nix/cgit.nix
+++ b/modules/teh-nix/cgit.nix
@@ -1,161 +1,169 @@
{ ... }:
{
- flake.modules.nixos.teh-nix =
- { pkgs, lib, config, ... }:
- let
- cfg = config.teh-nix.services.cgit;
- cgitrc = pkgs.writeText "cgitrc" ''
-css=/static/cgit.css
-logo=/static/cgit.png
-favicon=/static/favicon.ico
-repository-sort=age
+ flake.modules.nixos.teh-nix =
+ {
+ pkgs,
+ lib,
+ config,
+ ...
+ }:
+ let
+ cfg = config.teh-nix.services.cgit;
+ cgitrc = pkgs.writeText "cgitrc" ''
+ css=/static/cgit.css
+ logo=/static/cgit.png
+ favicon=/static/favicon.ico
+ repository-sort=age
-root-title=${cfg.title}
-root-desc=${cfg.description}
+ root-title=${cfg.title}
+ root-desc=${cfg.description}
-enable-blame=1
-enable-commit-graph=1
-enable-log-filecount=1
-enable-log-linecount=1
-enable-index-links=1
+ enable-blame=1
+ enable-commit-graph=1
+ enable-log-filecount=1
+ enable-log-linecount=1
+ enable-index-links=1
-snapshots=tar.gz zip
-enable-http-clone=1
-clone-prefix=https://${cfg.domain}
+ snapshots=tar.gz zip
+ enable-http-clone=1
+ clone-prefix=https://${cfg.domain}
-readme=:README
-readme=:readme
-readme=:readme.txt
-readme=:README.txt
-readme=:readme.md
-readme=:README.md
+ readme=:README
+ readme=:readme
+ readme=:readme.txt
+ readme=:README.txt
+ readme=:readme.md
+ readme=:README.md
-${cfg.extraConfig}
+ ${cfg.extraConfig}
-about-filter=${cfg.package}/lib/cgit/filters/about-formatting.sh
-source-filter=${cfg.package}/lib/cgit/filters/syntax-highlighting.py
+ about-filter=${cfg.package}/lib/cgit/filters/about-formatting.sh
+ source-filter=${cfg.package}/lib/cgit/filters/syntax-highlighting.py
-enable-git-config=1
-scan-path=${cfg.directory}
-'';
- in
- {
- options.teh-nix.services.cgit = with lib;{
- enable = mkEnableOption "Enable cgit";
- user = mkOption {
- type = types.str;
- default = "cgit";
- description = "Username for the user that will run cgit";
- };
- authorizedKeys = lib.mkOption {
- type = types.listOf types.str;
- default = [ ];
- description = "List of ssh keys for the cgit user (cgit user should own all repos)";
- };
- authorizedUsers = lib.mkOption {
- type = types.listOf types.str;
- default = [ ];
- description = "List of users that should have access to the cgit directory";
- };
- directory = mkOption {
- type = types.str;
- default = "/srv/cgit/repos";
- description = "Directory for cgit (cgit user's home directory";
- };
- description = mkOption {
- type = types.str;
- default = "Cgit instance hosted with nixos";
- description = "Description of the cgit website";
- };
- title = mkOption {
- type = types.str;
- default = "Cgit + Nix";
- description = "Title of the cgit website";
- };
- domain = mkOption {
- type = types.str;
- default = "git.example.com";
- description = "Domain to host it on";
- };
- useACMEHost = mkOption {
- type = types.str;
- default = "";
- description = "SSL cert to use if already aquired using security.acme.certs";
- };
- enableACME = mkEnableOption "Enable ACME with nginx";
- onlySSL = mkOption {
- type = types.bool;
- default = false;
- description = "Only allow ssl connections";
- };
- forceSSL = mkOption {
- type = types.bool;
- default = true;
- description = "Force ssl connections";
- };
- package = mkPackageOption pkgs "cgit" { };
- extraConfig = mkOption {
- type = types.str;
- default = "";
- description = "Extra config to be appended to cgitrc";
- };
- };
+ enable-git-config=1
+ scan-path=${cfg.directory}
+ '';
+ in
+ {
+ options.teh-nix.services.cgit = with lib; {
+ enable = mkEnableOption "Enable cgit";
+ user = mkOption {
+ type = types.str;
+ default = "cgit";
+ description = "Username for the user that will run cgit";
+ };
+ authorizedKeys = lib.mkOption {
+ type = types.listOf types.str;
+ default = [ ];
+ description = "List of ssh keys for the cgit user (cgit user should own all repos)";
+ };
+ authorizedUsers = lib.mkOption {
+ type = types.listOf types.str;
+ default = [ ];
+ description = "List of users that should have access to the cgit directory";
+ };
+ directory = mkOption {
+ type = types.str;
+ default = "/srv/cgit/repos";
+ description = "Directory for cgit (cgit user's home directory";
+ };
+ description = mkOption {
+ type = types.str;
+ default = "Cgit instance hosted with nixos";
+ description = "Description of the cgit website";
+ };
+ title = mkOption {
+ type = types.str;
+ default = "Cgit + Nix";
+ description = "Title of the cgit website";
+ };
+ domain = mkOption {
+ type = types.str;
+ default = "git.example.com";
+ description = "Domain to host it on";
+ };
+ useACMEHost = mkOption {
+ type = types.str;
+ default = "";
+ description = "SSL cert to use if already aquired using security.acme.certs";
+ };
+ enableACME = mkEnableOption "Enable ACME with nginx";
+ onlySSL = mkOption {
+ type = types.bool;
+ default = false;
+ description = "Only allow ssl connections";
+ };
+ forceSSL = mkOption {
+ type = types.bool;
+ default = true;
+ description = "Force ssl connections";
+ };
+ package = mkPackageOption pkgs "cgit" { };
+ extraConfig = mkOption {
+ type = types.str;
+ default = "";
+ description = "Extra config to be appended to cgitrc";
+ };
+ };
- config = lib.mkIf cfg.enable {
- environment.systemPackages = [ pkgs.git cfg.package ];
- users = {
- groups.${cfg.user} = {
- members = cfg.authorizedUsers;
- };
- users.${cfg.user} = {
- createHome = true;
- homeMode = "770";
- home = cfg.directory;
- isSystemUser = true;
- shell = "${pkgs.git}/bin/git-shell";
- openssh.authorizedKeys.keys = cfg.authorizedKeys;
- group = cfg.user;
- };
- };
+ config = lib.mkIf cfg.enable {
+ environment.systemPackages = [
+ pkgs.git
+ cfg.package
+ ];
+ users = {
+ groups.${cfg.user} = {
+ members = cfg.authorizedUsers;
+ };
+ users.${cfg.user} = {
+ createHome = true;
+ homeMode = "770";
+ home = cfg.directory;
+ isSystemUser = true;
+ shell = "${pkgs.git}/bin/git-shell";
+ openssh.authorizedKeys.keys = cfg.authorizedKeys;
+ group = cfg.user;
+ };
+ };
+ services.fcgiwrap.instances.cgit = {
+ socket = {
+ user = cfg.user;
+ group = "nginx";
+ type = "unix";
+ mode = "0660";
+ };
+ process = {
+ user = cfg.user;
+ group = cfg.user;
+ };
+ };
- services.fcgiwrap.instances.cgit = {
- socket = {
- user = cfg.user;
- group = "nginx";
- type = "unix";
- mode = "0660";
- };
- process = {
- user = cfg.user;
- group = cfg.user;
- };
- };
-
- services.nginx.enable = true;
- services.nginx.virtualHosts.${cfg.domain} = {
- locations."~* ^/static/(.+.(ico|css|png))$" = {
- extraConfig = ''
-alias ${cfg.package}/cgit/$1;
-'';
- };
- locations."/" = {
- extraConfig = ''
-include ${pkgs.nginx}/conf/fastcgi_params;
-fastcgi_param CGIT_CONFIG ${cgitrc};
-fastcgi_param SCRIPT_FILENAME ${cfg.package}/cgit/cgit.cgi;
-fastcgi_split_path_info ^(/?)(.+)$;
-fastcgi_param PATH_INFO $fastcgi_path_info;
-fastcgi_param QUERY_STRING $args;
-fastcgi_param HTTP_HOST $server_name;
-fastcgi_pass unix:${config.services.fcgiwrap.instances.cgit.socket.address};
- '';
- };
- enableACME = cfg.enableACME;
- forceSSL = cfg.forceSSL;
- } // lib.optionalAttrs (cfg.useACMEHost != "") {
- useACMEHost = "${cfg.useACMEHost}";
- };
- };
- };
+ services.nginx.enable = true;
+ services.nginx.virtualHosts.${cfg.domain} = {
+ locations."~* ^/static/(.+.(ico|css|png))$" = {
+ extraConfig = ''
+ alias ${cfg.package}/cgit/$1;
+ '';
+ };
+ locations."/" = {
+ extraConfig = ''
+ include ${pkgs.nginx}/conf/fastcgi_params;
+ fastcgi_param CGIT_CONFIG ${cgitrc};
+ fastcgi_param SCRIPT_FILENAME ${cfg.package}/cgit/cgit.cgi;
+ fastcgi_split_path_info ^(/?)(.+)$;
+ fastcgi_param PATH_INFO $fastcgi_path_info;
+ fastcgi_param QUERY_STRING $args;
+ fastcgi_param HTTP_HOST $server_name;
+ fastcgi_pass unix:${config.services.fcgiwrap.instances.cgit.socket.address};
+ '';
+ };
+ enableACME = cfg.enableACME;
+ forceSSL = cfg.forceSSL;
+ }
+ // lib.optionalAttrs (cfg.useACMEHost != "") {
+ useACMEHost = "${cfg.useACMEHost}";
+ };
+ };
+ };
}
diff --git a/modules/teh-nix/nix.nix b/modules/teh-nix/nix.nix
index d0b6cb3..dc6d414 100644
--- a/modules/teh-nix/nix.nix
+++ b/modules/teh-nix/nix.nix
@@ -1,45 +1,48 @@
{ inputs, ... }:
{
- flake.modules.nixos.teh-nix =
- { config, lib, ... }:
- {
- options.teh-nix.nix = with lib; {
- enable = mkEnableOption "Use the TehNix nix settings";
- };
+ flake.modules.nixos.teh-nix =
+ { config, lib, ... }:
+ {
+ options.teh-nix.nix = with lib; {
+ enable = mkEnableOption "Use the TehNix nix settings";
+ };
- config = lib.mkIf config.teh-nix.nix.enable {
- nix.nixPath = [ "/etc/nix/path" ];
- nix.registry.nixpkgs.flake = inputs.nixpkgs;
- environment.etc."nix/path/nixpkgs".source = inputs.nixpkgs;
+ config = lib.mkIf config.teh-nix.nix.enable {
+ nix.nixPath = [ "/etc/nix/path" ];
+ nix.registry.nixpkgs.flake = inputs.nixpkgs;
+ environment.etc."nix/path/nixpkgs".source = inputs.nixpkgs;
- nix = {
- settings = {
- experimental-features = [ "nix-command" "flakes" ];
- auto-optimise-store = true;
+ nix = {
+ settings = {
+ experimental-features = [
+ "nix-command"
+ "flakes"
+ ];
+ auto-optimise-store = true;
- trusted-users = [ "boss" ];
+ trusted-users = [ "boss" ];
- substituters = [
- "https://cache.nixos.org"
- ];
+ substituters = [
+ "https://cache.nixos.org"
+ ];
- # trusted-public-keys = [
- # "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
- # ];
- };
- optimise.automatic = true;
- };
+ # trusted-public-keys = [
+ # "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
+ # ];
+ };
+ optimise.automatic = true;
+ };
- # nh's cleaner replaces nix.gc (the nh module asserts they aren't both on)
- programs.nh = {
- enable = true;
- clean = {
- enable = true;
- dates = "weekly";
- # --no-direnv keeps nix-direnv's gcroots so dev shells survive
- extraArgs = "--keep-since 7d --keep 5 --no-direnv";
- };
- };
- };
- };
+ # nh's cleaner replaces nix.gc (the nh module asserts they aren't both on)
+ programs.nh = {
+ enable = true;
+ clean = {
+ enable = true;
+ dates = "weekly";
+ # --no-direnv keeps nix-direnv's gcroots so dev shells survive
+ extraArgs = "--keep-since 7d --keep 5 --no-direnv";
+ };
+ };
+ };
+ };
}
diff --git a/modules/teh-nix/nvidia.nix b/modules/teh-nix/nvidia.nix
index f14d20c..816de89 100644
--- a/modules/teh-nix/nvidia.nix
+++ b/modules/teh-nix/nvidia.nix
@@ -1,40 +1,45 @@
{ ... }:
{
- flake.modules.nixos.teh-nix =
- { config, pkgs, lib, ... }:
- let
- nvidia-offload = pkgs.writeShellScriptBin "prime-run" ''
-export __NV_PRIME_RENDER_OFFLOAD=1
-export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
-export __GLX_VENDOR_LIBRARY_NAME=nvidia
-export __VK_LAYER_NV_optimus=NVIDIA_only
-exec "$@"
-'';
- in
- {
- options.teh-nix.nvidia = with lib; {
- enable = mkEnableOption "Enable nvidia";
- };
+ flake.modules.nixos.teh-nix =
+ {
+ config,
+ pkgs,
+ lib,
+ ...
+ }:
+ let
+ nvidia-offload = pkgs.writeShellScriptBin "prime-run" ''
+ export __NV_PRIME_RENDER_OFFLOAD=1
+ export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
+ export __GLX_VENDOR_LIBRARY_NAME=nvidia
+ export __VK_LAYER_NV_optimus=NVIDIA_only
+ exec "$@"
+ '';
+ in
+ {
+ options.teh-nix.nvidia = with lib; {
+ enable = mkEnableOption "Enable nvidia";
+ };
- config = lib.mkIf config.teh-nix.nvidia.enable {
- nixpkgs.config.allowUnfree = true;
- hardware.graphics.enable = true;
- hardware.nvidia.modesetting.enable = true;
- # hardware.nvidia.dynamicBoost.enable = true;
- hardware.nvidia.open = true;
- hardware.nvidia.prime = {
- # sync.enable = true;
- offload.enable = true;
- # offload.offloadCmdMainProgram = "prime-run";
+ config = lib.mkIf config.teh-nix.nvidia.enable {
+ nixpkgs.config.allowUnfree = true;
+ hardware.graphics.enable = true;
+ hardware.nvidia.modesetting.enable = true;
+ # hardware.nvidia.dynamicBoost.enable = true;
+ hardware.nvidia.open = true;
+ hardware.nvidia.prime = {
+ # sync.enable = true;
+ offload.enable = true;
+ # offload.offloadCmdMainProgram = "prime-run";
- nvidiaBusId = "PCI:1:0:0";
- intelBusId = "PCI:5:0:0";
- };
- hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;
+ nvidiaBusId = "PCI:1:0:0";
+ intelBusId = "PCI:5:0:0";
+ };
+ hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;
- services.xserver.videoDrivers = [ "nvidia" ];
+ services.xserver.videoDrivers = [ "nvidia" ];
- environment.systemPackages = [ nvidia-offload ];
- };
- };
+ environment.systemPackages = [ nvidia-offload ];
+ };
+ };
}
diff --git a/modules/teh-nix/xorg.nix b/modules/teh-nix/xorg.nix
index 17febd3..67b2c67 100644
--- a/modules/teh-nix/xorg.nix
+++ b/modules/teh-nix/xorg.nix
@@ -1,60 +1,64 @@
{ inputs, ... }:
{
- flake.modules.nixos.teh-nix =
- { config, lib, pkgs, ... }:
- {
- imports = [
- # inputs.YATwm.nixosModules.YATwm
- ];
+ flake.modules.nixos.teh-nix =
+ {
+ config,
+ lib,
+ pkgs,
+ ...
+ }:
+ {
+ imports = [
+ # inputs.YATwm.nixosModules.YATwm
+ ];
- options.teh-nix.xorg = with lib; {
- enable = mkEnableOption "Enable xorg";
- nvidia = mkOption {
- type = types.bool;
- default = true;
- description = "Enable nvidia with xorg";
- };
- };
+ options.teh-nix.xorg = with lib; {
+ enable = mkEnableOption "Enable xorg";
+ nvidia = mkOption {
+ type = types.bool;
+ default = true;
+ description = "Enable nvidia with xorg";
+ };
+ };
- config = lib.mkIf config.teh-nix.xorg.enable {
+ config = lib.mkIf config.teh-nix.xorg.enable {
- teh-nix.nvidia.enable = lib.mkIf config.teh-nix.xorg.nvidia (lib.mkDefault true);
+ teh-nix.nvidia.enable = lib.mkIf config.teh-nix.xorg.nvidia (lib.mkDefault true);
- services.xserver = {
- enable = true;
+ services.xserver = {
+ enable = true;
- desktopManager = {
- xterm.enable = false;
- #default = "none";
- };
+ desktopManager = {
+ xterm.enable = false;
+ #default = "none";
+ };
- deviceSection = ''
- Option "DRI" "2"
- Option "TearFree" "true"
- '';
+ deviceSection = ''
+ Option "DRI" "2"
+ Option "TearFree" "true"
+ '';
- windowManager.i3 = {
- enable = true;
- package = pkgs.i3;
- };
+ windowManager.i3 = {
+ enable = true;
+ package = pkgs.i3;
+ };
- # windowManager.YATwm = {
- # enable = true;
- # package = inputs.YATwm.packages.x86_64-linux.YATwm;
- # };
- };
- programs.i3lock.enable = true;
+ # windowManager.YATwm = {
+ # enable = true;
+ # package = inputs.YATwm.packages.x86_64-linux.YATwm;
+ # };
+ };
+ programs.i3lock.enable = true;
- services.displayManager = {
- #defaultSession = "none+i3";
- sddm.enable = true;
- #sddm.theme = "catppuccin-macchiato";
- # ly.enable = true;
- };
+ services.displayManager = {
+ #defaultSession = "none+i3";
+ sddm.enable = true;
+ #sddm.theme = "catppuccin-macchiato";
+ # ly.enable = true;
+ };
-
- services.xserver.xkb.layout = "us";
- services.xserver.xkb.options = "caps:super";
- };
- };
+ services.xserver.xkb.layout = "us";
+ services.xserver.xkb.options = "caps:super";
+ };
+ };
}