commit 30a084c793211338029a7a1553d9a7b25ba856a9 Author: Rachel Lambda Samuelsson Date: Thu May 23 10:59:42 2024 +0200 initial commit diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..02c9d81 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1716361217, + "narHash": "sha256-mzZDr00WUiUXVm1ujBVv6A0qRd8okaITyUp4ezYRgc4=", + "owner": "NixOs", + "repo": "nixpkgs", + "rev": "46397778ef1f73414b03ed553a3368f0e7e33c2f", + "type": "github" + }, + "original": { + "owner": "NixOs", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..0a4d4b0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,23 @@ +{ + description = "My various NixOs configurations"; + + inputs = { + nixpkgs.url = "github:NixOs/nixpkgs/nixos-23.11"; + }; + + outputs = { self, nixpkgs, ... }: + let nix-config-module = + { + nix.registry.nixpkgs.flake = nixpkgs; + system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; + }; + in { + nixosConfigurations.cafe = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + nix-config-module + ./host.nix + ]; + }; + }; +} diff --git a/guests/gitea.nix b/guests/gitea.nix new file mode 100644 index 0000000..c9b5101 --- /dev/null +++ b/guests/gitea.nix @@ -0,0 +1,28 @@ +{ config, pkgs, ... }: +{ + + services.gitea = { + enable = true; + appName = "My awesome Gitea server"; # Give the site a name + database = { + type = "sqlite3"; + }; + settings.server = { + DOMAIN = "localhost"; + ROOT_URL = "http://localhost/"; + HTTP_PORT = 3001; + }; + }; + + # [CONTAINER] + boot.isContainer = true; + + # [NETWORK] + networking.hostName = "gitea"; + networking.useDHCP = false; + networking.firewall.enable = true; + networking.firewall.allowedTCPPorts = [ 3001 ]; + networking.firewall.allowedUDPPorts = [ ]; + + system.stateVersion = "23.11"; +} diff --git a/host.nix b/host.nix new file mode 100644 index 0000000..95caa54 --- /dev/null +++ b/host.nix @@ -0,0 +1,62 @@ +{ pkgs, ... }: +let gitea = { + host = "10.10.0.1"; + local = "10.10.0.2"; + }; +in +{ + # [CONTAINERS] + containers.gitea = { + autoStart = true; + ephemeral = true; + privateNetwork = true; + hostAddress = gitea.host; + localAddress = gitea.local; + config = ./gitea.nix; + }; + + # [NGINX] + services.nginx = { + enable = true; + recommendedProxySettings = true; + virtualHosts = { + "localhost" = { + locations."/".proxyPass = "http://${gitea.local}:3001"; + }; + }; + }; + + # [NETWORK] + networking.firewall.allowedTCPPorts = [ 80 ]; + networking.firewall.allowedUDPPorts = [ ]; + + # VM test user + users.users.test.isSystemUser = true ; + users.users.test.initialPassword = "test"; + users.users.test.group = "test"; + users.groups.test = {}; + + console = { + useXkbConfig = true; + }; + + services.xserver = { + xkb = { + layout = "fox,sus"; + options = "ctrl:nocaps"; + extraLayouts.sus = { + description = "Swedish US"; + languages = [ "se" ]; + symbolsFile = ../shared/sus.xkb; + }; + extraLayouts.fox = { + description = "Layout suitable to be used by a fox"; + languages = [ "se" ]; + symbolsFile = ../shared/fox.xkb; + }; + }; + }; + + system.stateVersion = "23.11"; + +}