From e5e365a1e0be6fd2a637df4bcc1dbb56f30ae483 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 14 Jul 2025 08:42:34 +0800 Subject: [PATCH 1/9] feat(homes): Add darwin support for user shells configuration --- nix/modules/cli/shell.nix | 41 +++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/nix/modules/cli/shell.nix b/nix/modules/cli/shell.nix index c28f00b..1b9aba6 100644 --- a/nix/modules/cli/shell.nix +++ b/nix/modules/cli/shell.nix @@ -5,19 +5,30 @@ 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}; }); + }; + homeManager.default = + { config, ... }: + { + programs.${cfg.manifest.users.${config.home.username}.shell}.enable = true; + home.shell.enableShellIntegration = true; + }; + }; } From 7866bc5bc7ae8ade0471ce42885eb3bd379c5289 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 14 Jul 2025 08:48:38 +0800 Subject: [PATCH 2/9] feat(darwin): Add machine platform config for darwin hosts --- nix/manifest.nix | 5 ++++- nix/modules/machine/platform.nix | 13 +++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/nix/manifest.nix b/nix/manifest.nix index 6d4698d..a4574b3 100644 --- a/nix/manifest.nix +++ b/nix/manifest.nix @@ -7,7 +7,10 @@ shell = "fish"; pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILdsZyY3gu8IGB8MzMnLdh+ClDxQQ2RYG9rkeetIKq8n rafiq"; }; - hosts.darwin.venus.graphical = true; + hosts.darwin.venus = { + graphical = true; + machine.platform = "intel"; + }; hosts.nixos = { nemesis = { graphical = true; diff --git a/nix/modules/machine/platform.nix b/nix/modules/machine/platform.nix index e60d4bf..08e60d4 100644 --- a/nix/modules/machine/platform.nix +++ b/nix/modules/machine/platform.nix @@ -12,9 +12,14 @@ 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"; + }; } From 25cb9a6ff8328fa744584356422c213ce106dd18 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 14 Jul 2025 12:23:47 +0800 Subject: [PATCH 3/9] feat(manifest): add hephaestus --- nix/manifest.nix | 152 ++++++++++++++++--------------- nix/modules/machine/platform.nix | 1 - 2 files changed, 80 insertions(+), 73 deletions(-) diff --git a/nix/manifest.nix b/nix/manifest.nix index a4574b3..18d9474 100644 --- a/nix/manifest.nix +++ b/nix/manifest.nix @@ -7,87 +7,95 @@ shell = "fish"; pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILdsZyY3gu8IGB8MzMnLdh+ClDxQQ2RYG9rkeetIKq8n rafiq"; }; - hosts.darwin.venus = { - graphical = true; - machine.platform = "intel"; - }; - 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/machine/platform.nix b/nix/modules/machine/platform.nix index 08e60d4..19b2fdf 100644 --- a/nix/modules/machine/platform.nix +++ b/nix/modules/machine/platform.nix @@ -21,5 +21,4 @@ { nixpkgs.hostPlatform = "${arch}-darwin"; }; - } From 16d4a9e9d18c1ae521726a1678768d08cef40f77 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 14 Jul 2025 13:26:44 +0800 Subject: [PATCH 4/9] feat(configs): Pass flake to nixosSystem and darwinSystem --- nix/configurations.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 From 42ef2d6c01db3d047144ddf3a668236f3974bad0 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 14 Jul 2025 13:30:56 +0800 Subject: [PATCH 5/9] fix(nvf): Disable csharp language server on darwin WARN: This commit message assumes the reason for disabling is darwin. --- nix/homes/rafiq/_nvf/languages.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; From 74dcb8fed0080f9848b18cbce77449b3ac1f3c0f Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 14 Jul 2025 13:53:49 +0800 Subject: [PATCH 6/9] feat(tailscale): Enable tailscale on darwin and skip some tests --- nix/modules/networking/tailscale.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/nix/modules/networking/tailscale.nix b/nix/modules/networking/tailscale.nix index 8f2a000..e50534c 100644 --- a/nix/modules/networking/tailscale.nix +++ b/nix/modules/networking/tailscale.nix @@ -14,7 +14,17 @@ 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 { + checkFlags = [ + "-skip" + "TestProtocolQEMU|TestProtocolUnixDgram" + ]; + }; + }; + }; } From 80c63d155d7591ce2522ae4e12afa2ff37565724 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 14 Jul 2025 13:56:56 +0800 Subject: [PATCH 7/9] fix(tailscale): Disable tailscale checks to allow build on darwin --- nix/modules/networking/tailscale.nix | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/nix/modules/networking/tailscale.nix b/nix/modules/networking/tailscale.nix index e50534c..e1ad04c 100644 --- a/nix/modules/networking/tailscale.nix +++ b/nix/modules/networking/tailscale.nix @@ -19,12 +19,7 @@ in { services.tailscale = { enable = true; - package = pkgs.tailscale.overrideAttrs { - checkFlags = [ - "-skip" - "TestProtocolQEMU|TestProtocolUnixDgram" - ]; - }; + package = pkgs.tailscale.overrideAttrs { doCheck = false; }; }; }; } From 346ad74c5dc15314a1422aa94890faa6bc8ddaf7 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 14 Jul 2025 14:20:57 +0800 Subject: [PATCH 8/9] feat(darwin): add user ids --- nix/modules/system/users.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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; From 750f2efaa73b510d9f0bfc45d844bfb11dd59377 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 14 Jul 2025 14:32:59 +0800 Subject: [PATCH 9/9] fix(darwin): set user shell --- nix/modules/cli/shell.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nix/modules/cli/shell.nix b/nix/modules/cli/shell.nix index 1b9aba6..0e081a1 100644 --- a/nix/modules/cli/shell.nix +++ b/nix/modules/cli/shell.nix @@ -23,6 +23,7 @@ in value.enable = true; }) cfg.manifest.users; users.users = forAllUsers' (_: value: { shell = pkgs.${value.shell}; }); + environment.shells = [ pkgs.fish ]; }; homeManager.default = { config, ... }: