diff --git a/.gitignore b/.gitignore index b2be92b..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +0,0 @@ -result diff --git a/flake.nix b/flake.nix index 568e458..eeb4bd0 100644 --- a/flake.nix +++ b/flake.nix @@ -1,79 +1,94 @@ { - outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } { - imports = with inputs; [ - easy-hosts.flakeModule - # home-manager.flakeModules.home-manager - ]; + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; - systems = [ "x86-64-linux" ]; - easy-hosts = { - autoConstruct = true; - path = ./hosts; - easy-hosts.onlySystem = "x86-64-linux"; + home-manager.url = "github:nix-community/home-manager"; - shared = { - modules = [ - inputs.lix-module.nixosModules.default - ./nixModules - ]; - }; - }; + lix-module.url = "https://git.lix.systems/lix-project/nixos-module/archive/2.91.1-2.tar.gz"; - # flake = { - # homeConfigurations = {}; - # homeModules = { my-modules = ./hmModules; }; - # }; + hyprland.url = "git+https://github.com/hyprwm/Hyprland"; + hyprland-contrib.url = "github:hyprwm/contrib"; + + niri.url = "github:sodiboo/niri-flake"; + + sops-nix.url = "github:Mic92/sops-nix"; + ags.url = "github:Aylur/ags"; + aagl.url = "github:ezKEa/aagl-gtk-on-nix"; }; - inputs = { - # Save data with this url. Source: - # at://did:plc:mojgntlezho4qt7uvcfkdndg/app.bsky.feed.post/3loogwsoqok2w - # cid: bafyreidhuuxs3cuabneygtxir65hnd7hvy4hwj5rwrylpwmp7jhxciasve - nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"; + outputs = { self, home-manager, nixpkgs, lix-module, ... }@inputs: let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + fs = pkgs.lib.fileset; + st = pkgs.lib.strings; + as = pkgs.lib.attrsets; - home-manager = { - type = "github"; - owner = "nix-community"; - repo = "home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; + hosts = let + hostFilter = { name, ...}: name == "host.nix"; + hostPaths = fs.toList (fs.fileFilter hostFilter ./hosts); + # Assumes dir structure is start_of_path/hosts/hostname/host.nix + extractHostName = path: builtins.unsafeDiscardStringContext ( + st.removeSuffix "/host.nix" ( + builtins.elemAt (st.splitString "/hosts/" path) 1 + ) + ); + in builtins.listToAttrs (map (path: { + value = path; + name = extractHostName path; + }) hostPaths); + + users = let + userFilter = { name, ...}: name == "user.nix"; + userPaths = fs.toList (fs.fileFilter userFilter ./hosts); + in builtins.listToAttrs (map (path: let + dirsAndFiles = st.splitString "/" path; + dAFLength = builtins.length dirsAndFiles; + # Assumes dir structure is start_of_path/hosts/hostname/users/username/user.nix + hostname = builtins.unsafeDiscardStringContext ( + builtins.elemAt dirsAndFiles (dAFLength - 4)); + username = builtins.unsafeDiscardStringContext ( + builtins.elemAt dirsAndFiles (dAFLength - 2)); + in { + name = username + "@" + hostname; + value = path; + } + ) userPaths); + + userConfig = usernameAtHostname: userpath: home-manager.lib.homeManagerConfiguration { + inherit pkgs; + extraSpecialArgs = { + inherit inputs; + inherit usernameAtHostname; + }; + modules = [ + ./hmModules + userpath + ]; }; - flake-parts = { - type = "github"; - owner = "hercules-ci"; - repo = "flake-parts"; - inputs.nixpkgs-lib.follows = "nixpkgs"; - }; + hostConfig = hostname: hostpath: nixpkgs.lib.nixosSystem { + specialArgs = let + hostFilteredUsers = as.filterAttrs ( + name: value: let + userHostname = builtins.elemAt (st.splitString "@" name) 1; + in userHostname == hostname + ) users; - easy-hosts = { - type = "github"; - owner = "tgirlcloud"; - repo = "easy-hosts"; - }; - - lix = { - url = "https://git.lix.systems/lix-project/lix/archive/main.tar.gz"; - flake = false; - }; - - lix-module = { - url = "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.lix.follows = "lix"; - }; - - niri = { - type = "github"; - owner = "sodiboo"; - repo = "niri-flake"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - sops-nix = { - type = "github"; - owner = "Mic92"; - repo = "sops-nix"; - inputs.nixpkgs.follows = "nixpkgs"; + hostUsers = as.mapAttrsToList ( + name: value: builtins.elemAt (st.splitString "@" name) 0 + ) hostFilteredUsers; + in { + inherit inputs; + inherit hostname; + "usernameList" = hostUsers; + }; + modules = [ + ./nixosModules + hostpath + ]; }; + in { + nixosConfigurations = builtins.mapAttrs (name: path: hostConfig name path) hosts; + homeConfigurations = builtins.mapAttrs (name: path: userConfig name path) users; }; } diff --git a/hosts/jibril/default.nix b/hosts/jibril/host.nix similarity index 100% rename from hosts/jibril/default.nix rename to hosts/jibril/host.nix diff --git a/users/pan@jibril/user.nix b/hosts/jibril/users/pan/user.nix similarity index 100% rename from users/pan@jibril/user.nix rename to hosts/jibril/users/pan/user.nix diff --git a/hosts/juri/default.nix b/hosts/juri/host.nix similarity index 87% rename from hosts/juri/default.nix rename to hosts/juri/host.nix index 9f908bf..57c9a47 100644 --- a/hosts/juri/default.nix +++ b/hosts/juri/host.nix @@ -17,14 +17,12 @@ in { forgejoPassword = { owner = "forgejo"; }; - caddyApi = {}; }; }; caddy = { enable = true; adminEmail = email; - environmentFile = config.sops.secrets.caddyApi.path; vhosts = { "juri.woach.me" = { extraConfig = '' @@ -41,12 +39,6 @@ in { extraConfig = '' reverse_proxy :${builtins.toString config.headscale.server.port} ''; - serverAliases = [ "*.dns.ginko.woach.me" ]; - }; - "juri.${config.services.headscale.settings.dns.base_domain}" = { - extraConfig = '' - reverse_proxy :${builtins.toString config.fava.port} - ''; }; }; }; diff --git a/hosts/juri/secrets.yaml b/hosts/juri/secrets.yaml index 145fe69..6800ced 100644 --- a/hosts/juri/secrets.yaml +++ b/hosts/juri/secrets.yaml @@ -1,7 +1,10 @@ pdsEnv: ENC[AES256_GCM,data:W1kKvcntrBOSgo7gLxwO8A9ZkWjkRWfUDZUMy5YNvhzqYS5xBPGL4QEcknWtQaVfaZklnO/+Gr5JEq/qgU2nIEY3xazfjYl4MNkZBhuwI20RwZB9voVubzHbPwjLtZbNTXRMa7BzO6a3ieSudKWAMP0dumG3/+wHtTYOM6lxUBfpw51+lNikc7kLqI+lzys0jC37ajP0/cm/U644BD0ozSSF289CLtXSkLt8sgHvA1ci8M+wEEq4aJ0JTVs98m0E7Udaride4tjLelESx3hPdoVzBIEa,iv:sQiYE//UGGA2qPfbM9//FcKEued6t8ORiKW8kfzLtz0=,tag:Fj+CzBgL8MH/6FLnUadIPQ==,type:str] forgejoPassword: ENC[AES256_GCM,data:cQJJbf07v4HngeSYE2TwTcAx8WY=,iv:533TO2MfJVop93U4T7yIIiu6i4swDtduFuu79ZzFYFU=,tag:Pz5u/NqOSTKz2zFNzNLY5w==,type:str] -caddyApi: ENC[AES256_GCM,data:mWb/pMr1cxbz6K2ZQkV3AF93/GtIPZyYrJfDDbisK3GhMlWOVZNWDzw7cC/e+1w5aSxeGmOAE13eETVpV9q8W2Bjg8IADn/4j8Su90LxAr+U77pVoF0gUvv1CagEXM8myx+GgaAG80xIeSUNUMOMsgUhJTBoaMrVpHDEPREsa9XyRzEB4X3uQnKx4tUNcUqGSUu5wvMfXDF7rNzJhkVEfE6i,iv:h5QLei1PcZUc4djaqbId9VFv8Rr2dTa7CNowxZVlRUA=,tag:nBfyFVU/fBboswcVsGKL4A==,type:str] sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] age: - recipient: age1ey3wr2wnkgny3dfgvnyrf0cptwzr7s5x464p2y9ya58lpay8lfrsds3y68 enc: | @@ -30,7 +33,8 @@ sops: N3NhMHp3V1ppclQvWTIxNkM5RjhRV0EKl8goB9tCl0BGi4jN7Fzuh0Ajm146x2Hu vesj+ENu2E9II3OeYuBndD+Y4x2zugIpzNOPg1V8zkarJOf7R/sXEw== -----END AGE ENCRYPTED FILE----- - lastmodified: "2025-09-17T01:49:06Z" - mac: ENC[AES256_GCM,data:THEyH3KP9VVFiP7NAPn693dolWIWByb3wSjwC9QLSTe3cgdJbFqa5GvVzFa6xM1ue/GYStMwYIZt0+3LP5Wz5B2KWNy2ljvgFXjzlDHxSOzkWi3/yP9fnuRyf0vujW2Q0ltkXMleyKSisZCD87FjuUz1J9LBYQP64e0mhyB5jL4=,iv:WUDt4AusjrQVhDFk/XSohBlmxjp6Dp6EoMe08yQ0RYg=,tag:LC2j1Bvgo7h29O9mmgIFCw==,type:str] + lastmodified: "2025-03-24T19:31:53Z" + mac: ENC[AES256_GCM,data:5FVSw5wMXRl4qZQmD4yS7g/9qztaveDiU7mgifiOhOBqQrtvv5I/V7rkb5nKew+N3vKmg4vpWBL4kFxsQvWekAPT+ToNED4XhB5H5wZ/RyXga0CU0PMKWtGdEKdyjs4cIZjfScclW0ONgaSkv6XtCLj1V+ukPY3WBI3/2jnf6dA=,iv:7p1qEG1+E7SNLv64/aqjm1ppF4jQ/5h+Z5iHzd8sGDA=,tag:hG59vDcqha1MQf+kN1jguw==,type:str] + pgp: [] unencrypted_suffix: _unencrypted - version: 3.10.2 + version: 3.9.4 diff --git a/users/badtz@juri/user.nix b/hosts/juri/users/badtz/user.nix similarity index 100% rename from users/badtz@juri/user.nix rename to hosts/juri/users/badtz/user.nix diff --git a/users/pan@juri/user.nix b/hosts/juri/users/pan/user.nix similarity index 100% rename from users/pan@juri/user.nix rename to hosts/juri/users/pan/user.nix diff --git a/hosts/onizuka/default.nix b/hosts/onizuka/host.nix similarity index 100% rename from hosts/onizuka/default.nix rename to hosts/onizuka/host.nix diff --git a/users/pan@onizuka/user.nix b/hosts/onizuka/users/pan/user.nix similarity index 100% rename from users/pan@onizuka/user.nix rename to hosts/onizuka/users/pan/user.nix diff --git a/nixosModules/services/caddy/service.nix b/nixosModules/services/caddy/service.nix index e24f701..b07fa3c 100644 --- a/nixosModules/services/caddy/service.nix +++ b/nixosModules/services/caddy/service.nix @@ -5,28 +5,14 @@ enable = lib.mkEnableOption "Enables caddy webserver"; vhosts = lib.mkOption {}; adminEmail = lib.mkOption { type = lib.types.str; }; - environmentFile = lib.mkOption {}; }; config = lib.mkIf config.caddy.enable { networking.firewall.allowedTCPPorts = [ 80 443 ]; services.caddy = { enable = true; - globalConfig = '' - acme_dns porkbun { - api_key {$APIKEY} - api_secret_key {$APISECRETKEY} - } - ''; - package = pkgs.caddy.withPlugins { - plugins = [ "github.com/caddy-dns/porkbun@v0.3.1" ]; - hash = "sha256-g/Nmi4X/qlqqjY/zoG90iyP5Y5fse6Akr8exG5Spf08="; - }; virtualHosts = config.caddy.vhosts; email = config.caddy.adminEmail; }; - systemd.services.caddy.serviceConfig.EnvironmentFile = [ - config.caddy.environmentFile - ]; }; } diff --git a/nixosModules/services/headscale/service.nix b/nixosModules/services/headscale/service.nix index 4f692f1..12fbad7 100644 --- a/nixosModules/services/headscale/service.nix +++ b/nixosModules/services/headscale/service.nix @@ -17,7 +17,7 @@ settings = { server_url = "https://${config.headscale.server.domain}"; dns = { - base_domain = "dns.${config.headscale.server.domain}"; + base_domain = "connect.claris"; override_local_dns = false; }; };