TrudeEH
October 10, 2024, 12:29am
1
I am attempting to configure nix-darwin using this flake .
However, when executing nix --extra-experimental-features "nix-command flakes" run nix-darwin -- switch --flake ~/.config/nix-darwin#default
, I get the following error:
I can’t find any information about this, and as a Nix beginner, I find the error hard to understand.
Any help will be greatly appreciated.
Thank you.
Note: The home.nix file works perfectly when in standalone mode, but I still need nix-darwin to configure macOS settings.
mark
October 10, 2024, 12:02pm
2
Please provide text as text and not screenshots - it is much easier to copy bits.
In this case I suspect the error is due to the error message about systemd. systemd is not on macOS (macOS uses launchd) so you have in your config a Linux only option.
1 Like
TrudeEH
October 10, 2024, 12:16pm
3
Sorry about that, I couldn’t copy text as I’m accessing the macOS machine remotely.
I see, could you tell me which option that is, please? I don’t think I configured anything related to systemd…
I shared a link to the flake I’m using, but I’ll paste it here as well, in case someone has the same issue in the future:
{
description = "Darwin system flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-darwin = {
url = "github:LnL7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ self, nix-darwin, nixpkgs, home-manager }:
let
configuration = { pkgs, config, ... }: {
services.nix-daemon.enable = true;
nix.settings.experimental-features = "nix-command flakes";
nixpkgs.config.allowUnfree = true;
system.configurationRevision = self.rev or self.dirtyRev or null;
system.stateVersion = 5;
# Home-manager module.
home-manager = {
extraSpecialArgs = {inherit inputs;};
backupFileExtension = "backup";
users = {
"trude" = import ./home.nix;
};
};
# Configs
environment.systemPackages = [
pkgs.mkalias
];
system.activationScripts.applications.text =
let
env = pkgs.buildEnv {
name = "system-applications";
paths = config.environment.systemPackages;
pathsToLink = "/Applications";
};
in
pkgs.lib.mkForce ''
# Set up applications.
echo "setting up /Applications..." >&2
rm -rf /Applications/Nix\ Apps
mkdir -p /Applications/Nix\ Apps
find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
while read src; do
app_name=$(basename "$src")
echo "copying $src" >&2
${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name"
done
'';
# Configure macOS
system.defaults = {
# man 5 configuration.nix
dock.autohide = true;
loginwindow.GuestEnabled = false;
NSGlobalDomain.AppleInterfaceStyle = "Dark";
NSGlobalDomain.KeyRepeat = 2;
};
# nixpkgs.hostPlatform = "x86_64-darwin"; # aarch64-darwin for ARM
};
in
{
# Build darwin flake using:
# $ nix run nix-darwin -- switch --flake ~/.config/nix-darwin
darwinConfigurations.default = nix-darwin.lib.darwinSystem {
modules = [
configuration
inputs.home-manager.nixosModules.default
];
};
darwinPackages = self.darwinConfigurations.default.pkgs;
};
}
Thank you.
Replace nixosModules
with darwinModules
1 Like
Thank you very much! It seems I still have a few errors, but this brings me one step closer!