Skip to content

Commit 398d066

Browse files
committed
Add Darwin support to nixos-compose
NOTE: This requires you to enable a nix linux builder but this should work the same on mac as linux fixup: issues
1 parent 95fafed commit 398d066

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
];
4141
});
4242
runtimeDeps = [
43-
pkgs.iproute2
43+
(if pkgs.stdenv.isLinux then pkgs.iproute2 else pkgs.iproute2mac)
4444
pkgs.nix
4545
pkgs.openssh
4646
pkgs.vde2

src/NixVms.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Network.Socket.Free (getFreePort)
1414
import Options (VmName (..))
1515
import State
1616
import StdLib
17+
import System.Info (os)
1718
import System.Directory (createDirectoryIfMissing, listDirectory)
1819
import System.Environment (getEnvironment)
1920
import System.FilePath (takeDirectory)
@@ -52,6 +53,9 @@ listVmsImpl ctx = do
5253
Left err -> impossible ctx $ cs err
5354
Right (parsed :: [Text]) -> pure $ map VmName parsed
5455

56+
darwinBuilderArgs :: [Text]
57+
darwinBuilderArgs = if os == "darwin" then ["--builders", "/etc/nix/builder_ed25519"] else [""]
58+
5559
buildVmScriptImpl :: Context -> Maybe Handle -> VmName -> IPv4 -> IO (FilePath, Port)
5660
buildVmScriptImpl ctx handle vmName ip = do
5761
port <- getFreePort
@@ -84,6 +88,7 @@ buildVmScriptImpl ctx handle vmName ip = do
8488
"--no-link",
8589
drvPath <> "^*"
8690
]
91+
<> darwinBuilderArgs
8792
)
8893
& Cradle.setWorkingDir (workingDir ctx)
8994
& maybe id addStderrHandle handle

0 commit comments

Comments
 (0)