diff --git a/nix/configurations.nix b/nix/configurations.nix index 9164647..ecc9c2f 100644 --- a/nix/configurations.nix +++ b/nix/configurations.nix @@ -28,7 +28,10 @@ let name: value: if class == "nixos" then nixosSystem { - specialArgs.hostName = name; + specialArgs = { + inherit (config.flake) self; + hostName = name; + }; modules = [ cfg.modules.nixos.default inputs.home-manager.nixosModules.home-manager @@ -38,11 +41,15 @@ let } else if class == "darwin" then darwinSystem { - specialArgs = { inherit (config.flake) self; }; + specialArgs = { + inherit (config.flake) self; + hostName = name; + }; modules = [ cfg.modules.darwin.default inputs.home-manager.darwinModules.home-manager { home-manager = globalCfg name value; } + (value.extraCfg or { }) ] ++ optional value.graphical cfg.modules.darwin.graphical; } else diff --git a/nix/homes/rafiq/_nvf/languages.nix b/nix/homes/rafiq/_nvf/languages.nix index cc3dd8c..6378a42 100644 --- a/nix/homes/rafiq/_nvf/languages.nix +++ b/nix/homes/rafiq/_nvf/languages.nix @@ -4,7 +4,8 @@ enableTreesitter = true; bash.enable = true; clang.enable = true; - csharp.enable = true; + # broken on macos + # csharp.enable = true; css.enable = true; go.enable = true; html.enable = true; diff --git a/nix/manifest.nix b/nix/manifest.nix index 6d4698d..18d9474 100644 --- a/nix/manifest.nix +++ b/nix/manifest.nix @@ -7,84 +7,95 @@ shell = "fish"; pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILdsZyY3gu8IGB8MzMnLdh+ClDxQQ2RYG9rkeetIKq8n rafiq"; }; - hosts.darwin.venus.graphical = true; - hosts.nixos = { - nemesis = { - graphical = true; - machine = { - platform = "amd"; - gpu = "nvidia"; - root.drive = "/dev/disk/by-id/nvme-CT2000P3SSD8_2325E6E77434"; - monitors.main = { - id = "desc:OOO AN-270W04K"; - resolution = "3840x2160"; - refresh-rate = "60"; - scale = "2"; - }; + hosts = { + darwin = { + venus = { + graphical = true; + machine.platform = "intel"; }; - extraCfg = { - services.fwupd.enable = true; # FIXME: remove - machine = { - bluetooth.enable = true; - usb.automount = true; - virtualisation = { - podman.enable = true; - podman.distrobox.enable = true; - }; - }; - server.web-apps = { - comfy-ui.enable = true; - sd-webui-forge.enable = true; - }; + hephaestus = { + graphical = true; + machine.platform = "apple-silicon"; }; }; - apollo = { - graphical = false; - machine = { - platform = "intel"; - root.drive = "/dev/disk/by-id/nvme-eui.002538d221b47b01"; - }; - extraCfg.server = { - ddns = { - enable = true; - domains = [ - "aenyrathia.wiki" - "slayment.com" - ]; + nixos = { + nemesis = { + graphical = true; + machine = { + platform = "amd"; + gpu = "nvidia"; + root.drive = "/dev/disk/by-id/nvme-CT2000P3SSD8_2325E6E77434"; + monitors.main = { + id = "desc:OOO AN-270W04K"; + resolution = "3840x2160"; + refresh-rate = "60"; + scale = "2"; + }; }; - web-servers = { - enableSSL = true; - nginx = { + extraCfg = { + services.fwupd.enable = true; # FIXME: remove + machine = { + bluetooth.enable = true; + usb.automount = true; + virtualisation = { + podman.enable = true; + podman.distrobox.enable = true; + }; + }; + server.web-apps = { + comfy-ui.enable = true; + sd-webui-forge.enable = true; + }; + }; + }; + apollo = { + graphical = false; + machine = { + platform = "intel"; + root.drive = "/dev/disk/by-id/nvme-eui.002538d221b47b01"; + }; + extraCfg.server = { + ddns = { enable = true; - proxies = [ - { - source = "aenyrathia.wiki"; - target = "http://helios:5896"; - } - { - source = "il.bwfiq.com"; - target = "http://helios:2283"; - } + domains = [ + "aenyrathia.wiki" + "slayment.com" ]; }; - }; - databases = { - mongodb.enable = true; - mysql.enable = true; - postgresql.enable = true; - }; - web-apps = { - librechat = { - enable = true; - domain = "chat.bwfiq.com"; + web-servers = { + enableSSL = true; + nginx = { + enable = true; + proxies = [ + { + source = "aenyrathia.wiki"; + target = "http://helios:5896"; + } + { + source = "il.bwfiq.com"; + target = "http://helios:2283"; + } + ]; + }; }; - forgejo = { - enable = true; - domain = "git.rrv.sh"; - openFirewall = true; + databases = { + mongodb.enable = true; + mysql.enable = true; + postgresql.enable = true; + }; + web-apps = { + librechat = { + enable = true; + domain = "chat.bwfiq.com"; + }; + forgejo = { + enable = true; + domain = "git.rrv.sh"; + openFirewall = true; + }; + rrv-sh.enable = true; + rrv-sh.domain = "rrv.sh"; }; - rrv-sh.enable = true; - rrv-sh.domain = "rrv.sh"; }; }; }; diff --git a/nix/modules/cli/shell.nix b/nix/modules/cli/shell.nix index c28f00b..0e081a1 100644 --- a/nix/modules/cli/shell.nix +++ b/nix/modules/cli/shell.nix @@ -5,19 +5,31 @@ let inherit (lib.attrsets) mapAttrs'; in { - flake.modules.nixos.default = - { pkgs, ... }: - { - programs = mapAttrs' (name: value: { - name = value.shell; - value.enable = true; - }) cfg.manifest.users; - users.users = forAllUsers' (_: value: { shell = pkgs.${value.shell}; }); - }; - flake.modules.homeManager.default = - { config, ... }: - { - programs.${cfg.manifest.users.${config.home.username}.shell}.enable = true; - home.shell.enableShellIntegration = true; - }; + flake.modules = { + nixos.default = + { pkgs, ... }: + { + programs = mapAttrs' (name: value: { + name = value.shell; + value.enable = true; + }) cfg.manifest.users; + users.users = forAllUsers' (_: value: { shell = pkgs.${value.shell}; }); + }; + darwin.default = + { pkgs, ... }: + { + programs = mapAttrs' (name: value: { + name = value.shell; + value.enable = true; + }) cfg.manifest.users; + users.users = forAllUsers' (_: value: { shell = pkgs.${value.shell}; }); + environment.shells = [ pkgs.fish ]; + }; + homeManager.default = + { config, ... }: + { + programs.${cfg.manifest.users.${config.home.username}.shell}.enable = true; + home.shell.enableShellIntegration = true; + }; + }; } diff --git a/nix/modules/machine/platform.nix b/nix/modules/machine/platform.nix index e60d4bf..19b2fdf 100644 --- a/nix/modules/machine/platform.nix +++ b/nix/modules/machine/platform.nix @@ -12,9 +12,13 @@ nixpkgs.hostPlatform = "${arch}-linux"; }; - flake.modules.darwin.default.nixpkgs = { - hostPlatform = "x86_64-darwin"; - # config.allowUnsupportedSystem = true; - }; - + flake.modules.darwin.default = + { hostName, ... }: + let + inherit (config.flake.manifest.hosts.darwin.${hostName}.machine) platform; + arch = if platform == "intel" then "x86_64" else "aarch64"; + in + { + nixpkgs.hostPlatform = "${arch}-darwin"; + }; } diff --git a/nix/modules/networking/tailscale.nix b/nix/modules/networking/tailscale.nix index 8f2a000..e1ad04c 100644 --- a/nix/modules/networking/tailscale.nix +++ b/nix/modules/networking/tailscale.nix @@ -14,7 +14,12 @@ in persistDirs = [ "/var/lib/tailscale" ]; sops.secrets."tailscale/client-secret".sopsFile = secrets + "/tailscale.yaml"; }; - flake.modules.darwin.default = { - services.tailscale.enable = true; - }; + flake.modules.darwin.default = + { pkgs, ... }: + { + services.tailscale = { + enable = true; + package = pkgs.tailscale.overrideAttrs { doCheck = false; }; + }; + }; } diff --git a/nix/modules/system/users.nix b/nix/modules/system/users.nix index 28c5f94..85fceb3 100644 --- a/nix/modules/system/users.nix +++ b/nix/modules/system/users.nix @@ -1,7 +1,9 @@ -{ config, ... }: +{ config, lib, ... }: let cfg = config.flake; inherit (cfg.lib.modules) userListToAttrs forAllUsers'; + inherit (lib.lists) findFirstIndex; + inherit (builtins) attrNames; in { flake.modules.nixos.default = @@ -34,7 +36,13 @@ in flake.modules.darwin.default = { config, ... }: { - users.users = forAllUsers' (name: _: { home = "/Users/${name}"; }); + users.knownUsers = attrNames cfg.manifest.users; + users.users = forAllUsers' ( + name: _: { + home = "/Users/${name}"; + uid = 501 + (findFirstIndex (x: x == name) null (attrNames cfg.manifest.users)); + } + ); home-manager.users = forAllUsers' ( name: _: { home.username = name;