diff --git a/flake.nix b/flake.nix index b32ff86..c8dd573 100755 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,9 @@ inputs.nixpkgs.follows = "nixpkgs"; }; nix-colors.url = "github:misterio77/nix-colors"; + nixos-wsl.url = "github:nix-community/nixos-wsl"; + vscode-server.url = "github:nix-community/nixos-vscode-server"; + }; outputs = inputs: diff --git a/generator.nix b/generator.nix index 7428017..649ff63 100755 --- a/generator.nix +++ b/generator.nix @@ -5,7 +5,7 @@ nameValuePair = name: value: { inherit name value; }; in ({ "nixos" = inputs.nixpkgs.lib.nixosSystem { - system = syscfg.syscfg.system; + system = "x86_64-linux"; specialArgs = { inherit inputs; }; modules = [ ./modules/shared/syscfg @@ -15,6 +15,10 @@ ./systems/${host} inputs.sops-nix.nixosModules.sops inputs.home-manager.nixosModules.home-manager + + (if (syscfg.syscfg.extra.wsl) then inputs.nixos-wsl.nixosModules.wsl else "") + (if (syscfg.syscfg.extra.wsl) then inputs.vscode-server.nixosModules.default else "") + { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; @@ -28,7 +32,6 @@ syscfg { usercfg = userConfig; } inputs.nix-colors.homeManagerModule - # inputs.hyprland.homeManagerModules.default inputs.sops-nix.homeManagerModules.sops ]; }) syscfg.syscfg.users); @@ -37,7 +40,7 @@ }; "macos" = inputs.darwin.lib.darwinSystem { - system = syscfg.system; + system = "x86_64-darwin"; modules = [ ./modules/shared/syscfg ./modules/shared/sops diff --git a/modules/nixos/system/hw/default.nix b/modules/nixos/system/hw/default.nix index e3954a6..6c6ea74 100644 --- a/modules/nixos/system/hw/default.nix +++ b/modules/nixos/system/hw/default.nix @@ -1 +1 @@ -{ ... }: { imports = [ ./base ./boot ./fs ./graphics ./power ./udev ./virt ]; } +{ ... }: { imports = [ ./base ./boot ./fs ./graphics ./power ./udev ./virt ./wsl ]; } diff --git a/modules/nixos/system/hw/wsl/default.nix b/modules/nixos/system/hw/wsl/default.nix new file mode 100644 index 0000000..b312407 --- /dev/null +++ b/modules/nixos/system/hw/wsl/default.nix @@ -0,0 +1,13 @@ +{ lib, config, pkgs, ... }: { + config = lib.mkIf (config.syscfg.extra.wsl) { + wsl.enable = true; + wsl.defaultUser = config.syscfg.defaultUser; + wsl.extraBin = with pkgs; [ + { src = "${coreutils}/bin/uname"; } + { src = "${coreutils}/bin/dirname"; } + { src = "${coreutils}/bin/readlink"; } + ]; + + wsl.wslConf.network.generateHosts = false; + }; +} \ No newline at end of file diff --git a/modules/nixos/system/network/base/default.nix b/modules/nixos/system/network/base/default.nix index f336d4e..06a2b22 100644 --- a/modules/nixos/system/network/base/default.nix +++ b/modules/nixos/system/network/base/default.nix @@ -1,9 +1,19 @@ -{ config, ... }: { +{ lib, config, ... }: { networking = { hostName = config.syscfg.hostname; useDHCP = true; nameservers = [ "1.1.1.1" "9.9.9.9" ]; + extraHosts = '' + ${lib.concatStringsSep "\n" config.syscfg.extra.hosts} + ''; + + proxy = lib.mkIf (config.syscfg.extra.proxy.domain != "") { + default = "http://${config.syscfg.extra.proxy.domain}:${config.syscfg.extra.proxy.port or "8080"}"; + noProxy = "${config.syscfg.extra.proxy.noProxy}"; + }; + + firewall = { enable = true; allowedUDPPorts = diff --git a/modules/nixos/system/nix/default.nix b/modules/nixos/system/nix/default.nix index 35fd7aa..023676f 100644 --- a/modules/nixos/system/nix/default.nix +++ b/modules/nixos/system/nix/default.nix @@ -37,5 +37,40 @@ ]; }; }; + programs.nix-ld = { + enable = true; + libraries = with pkgs; [ + # Correctly namespaced X11 dependencies + xorg.libX11 xorg.libxcb xorg.libXi xorg.libXext xorg.libxkbfile xorg.xcbutilcursor + libpng libdrm libpulseaudio nss nspr expat libbsd + + # Core system requirements + # stdenv.cc.cc + # zlib + # fuse3 + # alsa-lib + # openssl + + + # + # xorg.libXdamage + # xorg.libXfixes + # xorg.libXcomposite + # xorg.libXcursor + # xorg.libXrandr + # + # xorg.libXtst + + # # Graphics and system audio/menus + # libGL + # dbus + # fontconfig + # freetype + # glib + # + # + # + ]; + }; system.stateVersion = "24.11"; } diff --git a/modules/nixos/tools/develop/default.nix b/modules/nixos/tools/develop/default.nix index d19efe5..80123ca 100644 --- a/modules/nixos/tools/develop/default.nix +++ b/modules/nixos/tools/develop/default.nix @@ -9,6 +9,13 @@ in { imports = [ ./ollama ]; config = lib.mkIf (config.syscfg.make.develop) { + + services.vscode-server = lib.mkIf (config.syscfg.extra.wsl) { + enable = true; + enableFHS = true; + }; + + environment.systemPackages = with pkgs; [ # android-tools diff --git a/modules/server/containers/apps/.template.nix b/modules/server/containers/apps/.template.nix index 9f08138..a896981 100644 --- a/modules/server/containers/apps/.template.nix +++ b/modules/server/containers/apps/.template.nix @@ -1,5 +1,6 @@ { config, containerCfg, pkgs, lib, builder, name,... }: -let +let + version = "latest"; serverCfg = config.syscfg.server; image = pkgs.dockerTools.streamLayeredImage { name = "EXAMPLE"; @@ -9,7 +10,8 @@ let Entrypoint = [ "echo 1" ]; ExposedPorts = { }; }; - }; + }; + settings = pkgs.writeText "settings.yaml" ...; templateData = builder.mkData { name = "template"; dir = "template"; vars = { _ARGUMENT = "template"; }; @@ -25,7 +27,8 @@ in { containers = { server = builder.mkContainer { subdomain = containerCfg.subdomain; - imageStream = image; + # imageStream = image; + image = "....:${version}"; port = 8080; secret = name; extraEnv = { }; diff --git a/modules/server/containers/apps/homepage.nix b/modules/server/containers/apps/homepage.nix new file mode 100644 index 0000000..2414685 --- /dev/null +++ b/modules/server/containers/apps/homepage.nix @@ -0,0 +1,40 @@ +{ config, containerCfg, pkgs, lib, builder, name,... }: +let + version = "latest"; + serverCfg = config.syscfg.server; + + settings = pkgs.writers.writeYAML "settings.yaml" { + title = "My Self-Hosted Dashboard"; + base = ""; + theme = "dark"; + + # Nested structures transfer natively to YAML blocks + # layout = { + # Infrastructure = { + # style = "grid"; + # columns = 3; + # }; + # }; + }; +in { + sops = false; + db = false; + + containers = { + server = builder.mkContainer { + subdomain = containerCfg.subdomain; + image = "ghcr.io/gethomepage/homepage:${version}"; + port = 3000; + # extraEnv = { }; + extraLabels = { + "traefik.http.routers.${containerCfg.subdomain}.service" = "${containerCfg.subdomain}"; + }; + overrides = { + volumes = [ + "${settings}:/app/config/settings.yaml:ro" + ]; + }; + }; + }; + +} \ No newline at end of file diff --git a/modules/shared/syscfg/default.nix b/modules/shared/syscfg/default.nix index 756a5c0..865486a 100644 --- a/modules/shared/syscfg/default.nix +++ b/modules/shared/syscfg/default.nix @@ -14,10 +14,6 @@ in with lib; { type = types.enum [ "nixos" "macos" "home" ]; default = "nixos"; }; - system = mkOption { - type = types.enum [ "x86_64-linux" "x86_64-darwin" "-" ]; - default = "x86_64-linux"; - }; defaultUser = mkOption { type = types.str; }; make = import ./make.nix {inherit lib;}; net = import ./net.nix {inherit lib;}; @@ -32,5 +28,6 @@ in with lib; { type = types.oneOf [ types.bool (types.submodule { options = import ./server.nix {inherit lib;}; }) ]; default = false; }; + extra = import ./extra.nix {inherit lib;}; }; } diff --git a/modules/shared/syscfg/extra.nix b/modules/shared/syscfg/extra.nix new file mode 100644 index 0000000..9e70b2d --- /dev/null +++ b/modules/shared/syscfg/extra.nix @@ -0,0 +1,11 @@ +{ lib,... }: +with lib; { + wsl = mkOption { type = types.bool; default = false; }; + hosts = mkOption { type = types.listOf (types.str); default = []; }; + proxy = { + domain = mkOption { type = types.str; default = ""; }; + port = mkOption { type = types.str; default = ""; }; + noProxy = mkOption { type = types.str; default = ""; }; + cert = mkOption { type = types.path; default = null; }; + }; +} \ No newline at end of file diff --git a/systems/asguard/cfg.nix b/systems/asguard/cfg.nix index 1848cca..d78e0b1 100644 --- a/systems/asguard/cfg.nix +++ b/systems/asguard/cfg.nix @@ -3,6 +3,5 @@ hostname = "asgard"; defaultUser = "sora"; type = "macos"; - system = "x86_64-darwin"; }; } diff --git a/systems/avalon/cfg.nix b/systems/avalon/cfg.nix index 4b98bb5..ce06e0b 100644 --- a/systems/avalon/cfg.nix +++ b/systems/avalon/cfg.nix @@ -1,7 +1,6 @@ { syscfg = { hostname = "avalon"; - system = "x86_64-linux"; type = "nixos"; defaultUser = "sora"; users = [ diff --git a/systems/ci/cfg.nix b/systems/ci/cfg.nix index cb5eca5..f1cefd4 100644 --- a/systems/ci/cfg.nix +++ b/systems/ci/cfg.nix @@ -2,7 +2,6 @@ syscfg = { hostname = "ci"; type = "nixos"; - system = "x86_64-linux"; defaultUser = "ci"; users = [{ username = "ci"; diff --git a/systems/gateway/cfg.nix b/systems/gateway/cfg.nix index e3107b2..21eedbb 100644 --- a/systems/gateway/cfg.nix +++ b/systems/gateway/cfg.nix @@ -2,7 +2,6 @@ syscfg = { hostname = "gateway"; type = "nixos"; - system = "x86_64-linux"; defaultUser = "sora"; users = [{ username = "sora"; diff --git a/systems/iriy/cfg.nix b/systems/iriy/cfg.nix index fd55149..b4ebfb9 100644 --- a/systems/iriy/cfg.nix +++ b/systems/iriy/cfg.nix @@ -2,7 +2,6 @@ syscfg = { hostname = "iriy"; type = "nixos"; - system = "x86_64-linux"; defaultUser = "sora"; users = [{ username = "sora"; diff --git a/systems/sandbox/cfg.nix b/systems/sandbox/cfg.nix index aef9c32..6de05b2 100644 --- a/systems/sandbox/cfg.nix +++ b/systems/sandbox/cfg.nix @@ -2,7 +2,6 @@ syscfg = { hostname = "sandbox"; type = "nixos"; - system = "x86_64-linux"; defaultUser = "sora"; users = [{ username = "sora"; @@ -38,6 +37,7 @@ umami.subdomain = "umami"; authentik.subdomain = "sso"; searxng.subdomain = "searx"; + homepage.subdomain = "home"; # ===== CLOUD ===== # nextcloud.subdomain = "cloud"; # collabora.subdomain = "office"; @@ -53,7 +53,7 @@ # ===== DEV ===== gitea.subdomain = "git"; # ===== HOME ===== - openhab.subdomain = "hab"; + # openhab.subdomain = "hab"; # trmnl = { subdomain = "hass"; subpath = "trmnl"; }; influx.subdomain = "metrum"; }; diff --git a/systems/valinor/cfg.nix b/systems/valinor/cfg.nix index 9b0e456..41b066b 100644 --- a/systems/valinor/cfg.nix +++ b/systems/valinor/cfg.nix @@ -2,7 +2,6 @@ syscfg = { hostname = "valinor"; type = "nixos"; - system = "x86_64-linux"; defaultUser = "sora"; users = [{ username = "sora";