Compare commits
	
		
			No commits in common. "24eb83266a8368b10719ed305e293a782744cb14" and "ce0fcb23a48302962f7a5e591fde2b468b63bf3e" have entirely different histories.
		
	
	
		
			24eb83266a
			...
			ce0fcb23a4
		
	
		
					 13 changed files with 12 additions and 228 deletions
				
			
		| 
						 | 
					@ -22,16 +22,16 @@
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "nixpkgs": {
 | 
					    "nixpkgs": {
 | 
				
			||||||
      "locked": {
 | 
					      "locked": {
 | 
				
			||||||
        "lastModified": 1734536697,
 | 
					        "lastModified": 1734119587,
 | 
				
			||||||
        "narHash": "sha256-G/HnRTtU+ob8x967kjzMRqjNFbAdllrcjYc+IcaR15Y=",
 | 
					        "narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=",
 | 
				
			||||||
        "owner": "NixOS",
 | 
					        "owner": "NixOS",
 | 
				
			||||||
        "repo": "nixpkgs",
 | 
					        "repo": "nixpkgs",
 | 
				
			||||||
        "rev": "9c40bef08a5bdc0ccc3207f4282a1ded83e77a7a",
 | 
					        "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5",
 | 
				
			||||||
        "type": "github"
 | 
					        "type": "github"
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "original": {
 | 
					      "original": {
 | 
				
			||||||
        "owner": "NixOS",
 | 
					        "owner": "NixOS",
 | 
				
			||||||
        "ref": "nixos-unstable-small",
 | 
					        "ref": "nixos-unstable",
 | 
				
			||||||
        "repo": "nixpkgs",
 | 
					        "repo": "nixpkgs",
 | 
				
			||||||
        "type": "github"
 | 
					        "type": "github"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,14 +13,11 @@
 | 
				
			||||||
  outputs =
 | 
					  outputs =
 | 
				
			||||||
    inputs@{ self, nixpkgs, ... }:
 | 
					    inputs@{ self, nixpkgs, ... }:
 | 
				
			||||||
    let
 | 
					    let
 | 
				
			||||||
      kclib = import ./lib.nix {
 | 
					      kclib = (import ./lib.nix);
 | 
				
			||||||
        nixpkgs = inputs.nixpkgs;
 | 
					 | 
				
			||||||
        inputs = inputs;
 | 
					 | 
				
			||||||
      };
 | 
					 | 
				
			||||||
    in
 | 
					    in
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      nixosConfigurations = {
 | 
					      nixosConfigurations = {
 | 
				
			||||||
        tailscale-proxy = kclib.mkHost "tailscale-proxy" "x86_64-linux";
 | 
					        gateway = kclib.mkHost "gateway" "x86_64-linux";
 | 
				
			||||||
        entrypoint = kclib.mkHost "entrypoint" "x86_64-linux";
 | 
					        entrypoint = kclib.mkHost "entrypoint" "x86_64-linux";
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
      formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
 | 
					      formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,23 +0,0 @@
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  ...
 | 
					 | 
				
			||||||
}:
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  nixpkgs.config.allowUnfree = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  kropcloud = {
 | 
					 | 
				
			||||||
    admin = {
 | 
					 | 
				
			||||||
      user = "krop";
 | 
					 | 
				
			||||||
      sshKeys = [
 | 
					 | 
				
			||||||
        "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJl0Rdo2kHliBeIiPuiO4kYO5M0VZFNXw4siepV1p6Pj krop@wenar-nix"
 | 
					 | 
				
			||||||
        "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOUnlAjPnMwJYgZb7YuholdTxifOEFnAyXVqI+xFlHw6 krop@lenar"
 | 
					 | 
				
			||||||
      ];
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
    services = {
 | 
					 | 
				
			||||||
      ssh = {
 | 
					 | 
				
			||||||
        enable = true;
 | 
					 | 
				
			||||||
      };
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  system.stateVersion = "24.11";
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										1
									
								
								hosts/gateway.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								hosts/gateway.nix
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					{ }: { }
 | 
				
			||||||
| 
						 | 
					@ -1,11 +0,0 @@
 | 
				
			||||||
{ ... }:
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  kropcloud = {
 | 
					 | 
				
			||||||
    services = {
 | 
					 | 
				
			||||||
      tailscale = {
 | 
					 | 
				
			||||||
        enable = true;
 | 
					 | 
				
			||||||
        asRouter.enable = true;
 | 
					 | 
				
			||||||
      };
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										16
									
								
								lib.nix
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								lib.nix
									
									
									
									
									
								
							| 
						 | 
					@ -1,27 +1,19 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  nixpkgs,
 | 
					  nixpkgs,
 | 
				
			||||||
 | 
					  lib,
 | 
				
			||||||
  inputs,
 | 
					  inputs,
 | 
				
			||||||
}:
 | 
					}:
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  mkHost =
 | 
					  mkHost = name: arch: {
 | 
				
			||||||
    name: arch:
 | 
					    nixpkgs.lib.nixosSystem = {
 | 
				
			||||||
    nixpkgs.lib.nixosSystem {
 | 
					 | 
				
			||||||
      system = arch;
 | 
					      system = arch;
 | 
				
			||||||
      modules = [
 | 
					      modules = [
 | 
				
			||||||
        ./hosts/base.nix
 | 
					 | 
				
			||||||
        ./hosts/${name}.nix
 | 
					        ./hosts/${name}.nix
 | 
				
			||||||
        ./nixosModules
 | 
					        ./nixosModules
 | 
				
			||||||
        (
 | 
					 | 
				
			||||||
          { ... }:
 | 
					 | 
				
			||||||
          {
 | 
					 | 
				
			||||||
            config = {
 | 
					 | 
				
			||||||
              networking.hostName = name;
 | 
					 | 
				
			||||||
            };
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
      ];
 | 
					      ];
 | 
				
			||||||
      specialArgs = {
 | 
					      specialArgs = {
 | 
				
			||||||
        inherit inputs;
 | 
					        inherit inputs;
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1 @@
 | 
				
			||||||
{ ... }:
 | 
					{ }: { }
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  imports = [
 | 
					 | 
				
			||||||
    ./services
 | 
					 | 
				
			||||||
    ./networking
 | 
					 | 
				
			||||||
    ./users
 | 
					 | 
				
			||||||
    ./locale
 | 
					 | 
				
			||||||
  ];
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,52 +0,0 @@
 | 
				
			||||||
{ config, lib, ... }:
 | 
					 | 
				
			||||||
let
 | 
					 | 
				
			||||||
  cfg = config.kropcloud.locale;
 | 
					 | 
				
			||||||
in
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  options.kropcloud.locale = {
 | 
					 | 
				
			||||||
    timeZone = lib.mkOption {
 | 
					 | 
				
			||||||
      type = lib.types.str;
 | 
					 | 
				
			||||||
      default = "Europe/Prague";
 | 
					 | 
				
			||||||
      description = "The timezone for the system.";
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
    keyMap = lib.mkOption {
 | 
					 | 
				
			||||||
      type = lib.types.str;
 | 
					 | 
				
			||||||
      default = "cz-lat2";
 | 
					 | 
				
			||||||
      description = "The keymap to use for console input.";
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
    defaultLocale = lib.mkOption {
 | 
					 | 
				
			||||||
      type = lib.types.str;
 | 
					 | 
				
			||||||
      default = "en_GB.UTF-8";
 | 
					 | 
				
			||||||
      description = "The default locale for the system.";
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
    extraLocale = lib.mkOption {
 | 
					 | 
				
			||||||
      type = lib.types.str;
 | 
					 | 
				
			||||||
      default = "cs_CZ.UTF-8";
 | 
					 | 
				
			||||||
      description = "The locale to apply uniformly to all LC_* categories.";
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  config = {
 | 
					 | 
				
			||||||
    # Set the system timezone.
 | 
					 | 
				
			||||||
    time.timeZone = cfg.timeZone;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Set the default locale.
 | 
					 | 
				
			||||||
    i18n.defaultLocale = cfg.defaultLocale;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Apply the same locale to all LC_* categories.
 | 
					 | 
				
			||||||
    i18n.extraLocaleSettings = lib.genAttrs [
 | 
					 | 
				
			||||||
      "LC_ADDRESS"
 | 
					 | 
				
			||||||
      "LC_IDENTIFICATION"
 | 
					 | 
				
			||||||
      "LC_MEASUREMENT"
 | 
					 | 
				
			||||||
      "LC_MONETARY"
 | 
					 | 
				
			||||||
      "LC_NAME"
 | 
					 | 
				
			||||||
      "LC_NUMERIC"
 | 
					 | 
				
			||||||
      "LC_PAPER"
 | 
					 | 
				
			||||||
      "LC_TELEPHONE"
 | 
					 | 
				
			||||||
      "LC_TIME"
 | 
					 | 
				
			||||||
    ] (_: cfg.extraLocale);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Set the console keymap.
 | 
					 | 
				
			||||||
    console.keyMap = cfg.keyMap;
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,26 +0,0 @@
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  config,
 | 
					 | 
				
			||||||
  lib,
 | 
					 | 
				
			||||||
  ...
 | 
					 | 
				
			||||||
}:
 | 
					 | 
				
			||||||
let
 | 
					 | 
				
			||||||
  cfg = config.kropcloud.networking;
 | 
					 | 
				
			||||||
in
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  options.kropcloud.networking = {
 | 
					 | 
				
			||||||
    enable = lib.mkOption {
 | 
					 | 
				
			||||||
      type = lib.types.bool;
 | 
					 | 
				
			||||||
      description = "Whence to configure networking";
 | 
					 | 
				
			||||||
      default = true;
 | 
					 | 
				
			||||||
      example = false;
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
  config = lib.mkIf cfg.enable {
 | 
					 | 
				
			||||||
    networking = {
 | 
					 | 
				
			||||||
      nftables.enable = true;
 | 
					 | 
				
			||||||
      firewall = {
 | 
					 | 
				
			||||||
        checkReversePath = "loose";
 | 
					 | 
				
			||||||
      };
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,7 +0,0 @@
 | 
				
			||||||
{ ... }:
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  imports = [
 | 
					 | 
				
			||||||
    ./ssh
 | 
					 | 
				
			||||||
    ./tailscale
 | 
					 | 
				
			||||||
  ];
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,22 +0,0 @@
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  config,
 | 
					 | 
				
			||||||
  lib,
 | 
					 | 
				
			||||||
  ...
 | 
					 | 
				
			||||||
}:
 | 
					 | 
				
			||||||
let
 | 
					 | 
				
			||||||
  cfg = config.kropcloud.services.ssh;
 | 
					 | 
				
			||||||
in
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  options.kropcloud.services.ssh = {
 | 
					 | 
				
			||||||
    enable = lib.mkEnableOption "Whence to enable sshd service.";
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
  config = lib.mkIf cfg.enable {
 | 
					 | 
				
			||||||
    services.openssh = {
 | 
					 | 
				
			||||||
      enable = true;
 | 
					 | 
				
			||||||
      settings = {
 | 
					 | 
				
			||||||
        PermitRootLogin = "no";
 | 
					 | 
				
			||||||
        PasswordAuthentication = false;
 | 
					 | 
				
			||||||
      };
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,30 +0,0 @@
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  config,
 | 
					 | 
				
			||||||
  lib,
 | 
					 | 
				
			||||||
  ...
 | 
					 | 
				
			||||||
}:
 | 
					 | 
				
			||||||
let
 | 
					 | 
				
			||||||
  cfg = config.kropcloud.services.tailscale;
 | 
					 | 
				
			||||||
in
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  options.kropcloud.services.tailscale = {
 | 
					 | 
				
			||||||
    enable = lib.mkEnableOption "Whence to enable tailscale service.";
 | 
					 | 
				
			||||||
    asRouter = {
 | 
					 | 
				
			||||||
      enable = lib.mkEnableOption "Whence to configure tailscale as router.";
 | 
					 | 
				
			||||||
      subnet = lib.mkOption {
 | 
					 | 
				
			||||||
        type = lib.types.str;
 | 
					 | 
				
			||||||
        default = "192.168.1.0/24";
 | 
					 | 
				
			||||||
        example = "192.168.1.0/24";
 | 
					 | 
				
			||||||
        description = "The subnet to expose";
 | 
					 | 
				
			||||||
      };
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
  config = lib.mkIf cfg.enable {
 | 
					 | 
				
			||||||
    services.tailscale = {
 | 
					 | 
				
			||||||
      enable = true;
 | 
					 | 
				
			||||||
      openFirewall = true;
 | 
					 | 
				
			||||||
      useRoutingFeatures = lib.mkIf cfg.asRouter.enable "server";
 | 
					 | 
				
			||||||
      extraSetFlags = lib.mkIf cfg.asRouter.enable [ "--advertise-routes=${cfg.asRouter.subnet}" ];
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,27 +0,0 @@
 | 
				
			||||||
{ config, lib, ... }:
 | 
					 | 
				
			||||||
let
 | 
					 | 
				
			||||||
  cfg = config.kropcloud.admin;
 | 
					 | 
				
			||||||
in
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  options.kropcloud.admin = {
 | 
					 | 
				
			||||||
    user = lib.mkOption {
 | 
					 | 
				
			||||||
      type = lib.types.str;
 | 
					 | 
				
			||||||
      default = "krop";
 | 
					 | 
				
			||||||
      description = "Name of the admin user to be created.";
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
    sshKeys = lib.mkOption {
 | 
					 | 
				
			||||||
      type = lib.types.listOf lib.types.str;
 | 
					 | 
				
			||||||
      default = [ ];
 | 
					 | 
				
			||||||
      description = "List of SSH public keys to authorize for the admin user.";
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  config = {
 | 
					 | 
				
			||||||
    # Define the admin user
 | 
					 | 
				
			||||||
    users.users.${cfg.user} = {
 | 
					 | 
				
			||||||
      isNormalUser = true;
 | 
					 | 
				
			||||||
      extraGroups = [ "wheel" ];
 | 
					 | 
				
			||||||
      openssh.authorizedKeys.keys = cfg.sshKeys;
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Loading…
	
		Reference in a new issue