From 3c4e1430be5eb53812a71e64b99d94adf7da8fbb Mon Sep 17 00:00:00 2001 From: beeb5k Date: Wed, 2 Sep 2026 19:12:59 +0530 Subject: Cgit --- flake.lock | 21 +++++++++++++ hosts/oixos/cgit.nix | 67 +++++++++++++++++++++++++++++++++++++++++ hosts/oixos/default.nix | 79 +++++++++++++++++++++++++++++++++++++++---------- users/common.nix | 1 + 4 files changed, 153 insertions(+), 15 deletions(-) create mode 100644 hosts/oixos/cgit.nix diff --git a/flake.lock b/flake.lock index 283ccdb..7f565b5 100644 --- a/flake.lock +++ b/flake.lock @@ -25,6 +25,26 @@ "url": "https://codeberg.org/beeb5k/beeVim" } }, + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1781152676, + "narHash": "sha256-RxWs5ND31KzTG7wvMM+PMfUjyNpmIEr999lqNARaM5o=", + "owner": "nix-community", + "repo": "disko", + "rev": "ff8702b4de27f72b4c78573dfb89ec74e36abdf1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -161,6 +181,7 @@ "root": { "inputs": { "beevim": "beevim", + "disko": "disko", "flake-parts": "flake-parts", "home-manager": "home-manager", "nixpkgs": "nixpkgs", diff --git a/hosts/oixos/cgit.nix b/hosts/oixos/cgit.nix new file mode 100644 index 0000000..825f614 --- /dev/null +++ b/hosts/oixos/cgit.nix @@ -0,0 +1,67 @@ +{ pkgs, ... }: +let + cgitPkg = pkgs.cgit; +in +{ + users.groups.git = { }; + users.users.git = { + isSystemUser = true; + group = "git"; + home = "/var/lib/git"; + createHome = true; + shell = "${pkgs.git}/bin/git-shell"; + }; + + environment.etc."cgitrc".text = '' + root-title=beeb5k git repos + root-desc=Personal Code Repositories + scan-path=/var/lib/git + enable-http-clone=1 + clone-prefix=https://git.beeb5k.space + + css=/cgit-css/cgit.css + logo=/cgit-css/cgit.png + favicon=/favicon.ico + + readme=:README.md + readme=:README.txt + readme=:README + ''; + + services.fcgiwrap.instances.cgit = { + process = { + user = "git"; + group = "git"; + }; + socket = { + type = "unix"; + address = "/run/fcgiwrap-cgit.sock"; + user = "git"; + group = "caddy"; + mode = "0660"; + }; + }; + + services.caddy = { + enable = true; + + virtualHosts."git.beeb5k.space".extraConfig = '' + # Article: location /cgit-css/ { alias /usr/share/cgit/; } + handle_path /cgit-css/* { + root * ${pkgs.cgit}/cgit + file_server + } + + # Article: location / { fastcgi_pass ... fastcgi_param SCRIPT_FILENAME ... } + handle { + reverse_proxy unix//run/fcgiwrap-cgit.sock { + transport fastcgi { + env DOCUMENT_ROOT ${pkgs.cgit}/cgit + env SCRIPT_FILENAME ${pkgs.cgit}/cgit/cgit.cgi + env CGIT_CONFIG /etc/cgitrc + } + } + } + ''; + }; +} diff --git a/hosts/oixos/default.nix b/hosts/oixos/default.nix index 416e2f2..ba853e2 100644 --- a/hosts/oixos/default.nix +++ b/hosts/oixos/default.nix @@ -15,32 +15,61 @@ inputs.disko.nixosModules.disko ./disko.nix ./hardware-configuration.nix + ./cgit.nix ]; - boot.loader.grub = { - efiSupport = true; - efiInstallAsRemovable = true; + nix.settings = { + trusted-users = [ "@wheel" ]; + experimental-features = [ + "nix-command" + "flakes" + ]; + auto-optimise-store = true; }; + services.chrony.enable = true; + + time.timeZone = "UTC"; + i18n.defaultLocale = "en_US.UTF-8"; + + boot.loader.systemd-boot = { + enable = true; + editor = false; + }; + boot.loader.timeout = 0; + boot.loader.efi.canTouchEfiVariables = false; + + # boot.loader.grub = { + # efiSupport = true; + # efiInstallAsRemovable = true; + # }; + networking.hostName = hostname; + networking.firewall.enable = true; + networking.firewall.allowedTCPPorts = [ + 80 + 443 + ]; + networking.firewall.allowedUDPPorts = [ ]; + networking.useDHCP = true; services.openssh = { enable = true; - # settings = { - # PermitRootLogin = "prohibit-password"; - # PasswordAuthentication = false; - # }; + settings = { + PermitRootLogin = "prohibit-password"; + PasswordAuthentication = false; + }; }; - # users.users.beeb5k = { - # isNormalUser = true; - # extraGroups = [ "wheel" ]; - # - # openssh.authorizedKeys.keys = [ - # "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGTMc0gNGM6vI8s9CrW+fYlW4ppRTKRCELOve3Izj1VD beeb5k" - # ]; - # }; + users.users.beeb5k = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGTMc0gNGM6vI8s9CrW+fYlW4ppRTKRCELOve3Izj1VD beeb5k" + ]; + }; services.cloud-init.enable = true; @@ -50,11 +79,31 @@ environment.systemPackages = with pkgs; [ git + fastfetch ]; # security.sudo.wheelNeedsPassword = false; + programs.bash.promptInit = '' + if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then + # Removed the '1;' prefix to disable bold + PROMPT_COLOR="31m" + ((UID)) && PROMPT_COLOR="32m" + + if [ -n "$INSIDE_EMACS" ]; then + PS1="\[\033[$PROMPT_COLOR\]\u@\h:\w\\$\[\033[0m\] " + else + PS1="\[\e[94m\]\u@\h \[\e[32m\]\w \[\e[39m\]\$ \[\e[0m\]" + fi + + if test "$TERM" = "xterm"; then + PS1="\[\033]2;\h:\u:\w\007\]$PS1" + fi + fi + ''; + nixpkgs.hostPlatform = "aarch64-linux"; system.stateVersion = systemState; + } diff --git a/users/common.nix b/users/common.nix index fa614c4..899687d 100644 --- a/users/common.nix +++ b/users/common.nix @@ -159,5 +159,6 @@ in papers nautilus proton-vpn + dig ]; } -- cgit v1.3.1