Correctly running cloned flake

Hi!
I am trying to use this configuration GitHub - bfpimentel/nixos: My NixOS machines configurations. Still in progress. for use on different systems.
But since I am not very familiar with Nix, I can’t figure out how it should be run.

In previous versions of my configuration I used simple commands like darwin-rebuild and home-manager switch, and in flake.nix I had darwinConfigurations and homeConfigurations. But in this case, there is no homeConfigurations.

I didn’t change the configuration core, I just changed the user, tools and configs for them which I use.

I would be very grateful for your help!

I tried to use darwin-rebuild switch --flake . for it and all configuration is setup anf brew apps is installed, but home-manager isn’t working, for example, zsh not installed, or another configs from home-manager not setup

Could you run the below command and show us the output? If you do that, we might have better answers as to why things aren’t working as you suspect.

darwin-rebuild switch --flake . --verbose

This the output of darwin-rebuild switch --flake . --verbose

qmpwwsd@qmpwwsd:~/dotfiles/ > nix build .#darwinConfigurations.qmpwwsd.system
warning: Git tree '/Users/qmpwwsd/dotfiles' is dirty
qmpwwsd@qmpwwsd:~/dotfiles/ > darwin-rebuild switch --flake . --verbose
building the system configuration...
warning: Git tree '/Users/qmpwwsd/dotfiles' is dirty
setting up Homebrew (/opt/homebrew)...
setting up Homebrew (/usr/local)...
user defaults...
restarting Dock...
setting up user launchd services...
Homebrew bundle...
Using mas
Using imagemagick
Using 1password
Using nordpass
Using discord
Using telegram
Using microsoft-teams
Using docker
Using figma
Using utm
Using miro
Using godot
Using firefox
Using google-chrome
Using obsidian
Using notion
Using raycast
Using deepl
Using aldente
Using appcleaner
Using shottr
Using keka
Using cursorcerer
Using transmission
Using plover
Using spotify
Using binance
Using meetingbar
Using eul
Using wireshark
Using keycastr
Using sf-symbols
Homebrew Bundle complete! 32 Brewfile dependencies now installed.
Error: Refusing to untap homebrew/cask because it contains the following installed formulae or casks:
1password
aldente
appcleaner
binance
cursorcerer
deepl
discord
docker
eul
figma
firefox
godot
google-chrome
keka
keycastr
meetingbar
microsoft-teams
miro
nordpass
notion
obsidian
plover
raycast
sf-symbols
shottr
spotify
telegram
transmission
utm
wireshark
setting up groups...
setting up users...
setting up /Applications/Nix Apps...
warning: /Applications/Nix Apps is not owned by nix-darwin, skipping App linking...
setting up pam...
applying patches...
setting up /etc...
system defaults...
2024-11-13 14:41:46.440 defaults[12389:356930] Could not parse: <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<string>qmpwwsd <code></string>
</plist>.  Try single-quoting it

It looks like the home manager is working, because I can use some tools that are configured in the home manager configuration, but their configurations don’t work. I don’t know, maybe there is some problem with the paths. I spend all day for it but can’t find it.

For example, zsh is working but its config - no

Can it doesn’t work because I stored all configuration in ~/dotfiles/?
For example, check kitty and aerospace icons

I don’t think that’s likely to be an issue. Nix commands that deal with flakes generally don’t care about where the files are stored. You can even switch to a strictly remote flake with a command like darwin-rebuild switch --flake github:linnnus/nix-monorepo#muhammed!

That’s curious. When I run an equivalent command on my own configuration, I get a lot more output:

linus@muhammed$ darwin-rebuild switch --flake .#muhammed
building the system configuration...
user defaults...
setting up user launchd services...
setting up /Applications/Nix Apps...
setting up pam...
applying patches...
setting up /etc...
system defaults...
setting up launchd services...
configuring networking...
setting nvram variables...
Activating home-manager configuration for linus
Starting Home Manager activation
Activating checkFilesChanged
Activating checkLaunchAgents
Activating checkLinkTargets
Activating writeBoundary
Activating installPackages
replacing old 'home-manager-path'
installing 'home-manager-path'
Activating linkGeneration
Cleaning up orphan links from /Users/linus
No change so reusing latest profile generation 716
Creating home file links in /Users/linus
Activating onFilesChange
Activating setupLaunchAgents

As you can see, there are a lot of steps after the system defaults... step. It seems like darwin-rebuild fails at the system defaults... step when you run it. This makes sense, as the XML it complains about is invalid (the <code> tag is never closed).

I’ll take a closer looks at your configuration tomorrow. I can see from the logs you posted that the dotfiles repo is dirty. Let me know if you have made substantial local changes (i.e changes that aren’t pushed to GitHub).

You can check my changed configuration there: GitHub - art1es23/nixos
I very grateful for your help!

Hm, this is weird. I can use your configuration just fine:

Running darwin-rebuild on my machine
linus@muhammed$ darwin-rebuild activate --flake .#qmpwwsd
warning: Git tree '/Users/linus/Source/art1es23-nixos-config' is dirty
user defaults...
setting up user launchd services...
setting up /Applications/Nix Apps...
setting up pam...
applying patches...
setting up /etc...
system defaults...
setting up launchd services...
configuring networking...
setting nvram variables...
Activating home-manager configuration for linus
Starting Home Manager activation
Activating checkFilesChanged
Activating checkLaunchAgents
Activating checkLinkTargets
Activating writeBoundary
Activating installPackages
replacing old 'home-manager-path'
installing 'home-manager-path'
Activating linkGeneration
Cleaning up orphan links from /Users/linus
No change so reusing latest profile generation 716
Creating home file links in /Users/linus
Activating onFilesChange
Activating setupLaunchAgents

Looking at the nix-darwin source. It appears that the system defaults... step is implemented here. It seems pretty straight forward, but I can’t find anywhere in your configuration which actually sets any defaults with the string qmpwwsd (though maybe it’s happening indirectly through some other option).

I’d like to see exactly what the systems defaults... step is doing. Could you give me the output of running the following commands?

$ nix build .#darwinConfigurations.qmpwwsd.system
$ cat result/activate-user

Check there: nixos/cat-result-activate-user.log at 499b1c99e8811a088eecd71610502bb5f3f6a45b · art1es23/nixos · GitHub

My bad, that was a bit of a digression. The relevant setup code was in result/activate, not result/activate-user. Either way, I could’ve just looked it up myself.

Anyways, here’s the offending code on line 1411 of result/activate:

defaults write /Library/Preferences/com.apple.loginwindow 'LoginwindowText' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<string>qmpwwsd <code></string>
</plist>'

That’s exactly the code from the error message! I guess I just missed it, but it’s coming from line 59-61 of modules/darwin/system.nix in your configuration:

loginwindow = {
  LoginwindowText = "qmpwwsd <code>";
};

It seems that Home-Manager isn’t properly escaping the text, so "qmpwwsd <code>" is included verbatim in the XML passed to defaults write. It is obviously invalid XML, as the <code> tag is never closed.

Try replacing the text with something else that doesn’t clash with the XML, like "qmpwwsd (code)". If you try to switch after making that change, does that solve your issue?

1 Like

I removed the property with it. Could you check now?
I forgot copy log after rebuild but it’s the second run:

qmpwwsd@qmpwwsd:~/nixos/ > nix build .#darwinConfigurations.qmpwwsd.system
qmpwwsd@qmpwwsd:~/nixos/ > darwin-rebuild switch --flake .                
building the system configuration...
setting up Homebrew (/opt/homebrew)...
setting up Homebrew (/usr/local)...
user defaults...
restarting Dock...
setting up user launchd services...
Homebrew bundle...
Using mas
Using imagemagick
Using 1password
Using nordpass
Using discord
Using telegram
Using microsoft-teams
Using docker
Using figma
Using utm
Using miro
Using godot
Using firefox
Using google-chrome
Using obsidian
Using notion
Using raycast
Using deepl
Using aldente
Using appcleaner
Using shottr
Using keka
Using cursorcerer
Using transmission
Using plover
Using spotify
Using binance
Using meetingbar
Using eul
Using wireshark
Using keycastr
Using sf-symbols
Homebrew Bundle complete! 32 Brewfile dependencies now installed.
Error: Refusing to untap homebrew/cask because it contains the following installed formulae or casks:
1password
aldente
appcleaner
binance
cursorcerer
deepl
discord
docker
eul
figma
firefox
godot
google-chrome
keka
keycastr
meetingbar
microsoft-teams
miro
nordpass
notion
obsidian
plover
sf-symbols
shottr
spotify
telegram
transmission
utm
wireshark
setting up groups...
setting up users...
setting up /Applications/Nix Apps...
warning: /Applications/Nix Apps is not owned by nix-darwin, skipping App linking...
setting up pam...
applying patches...
setting up /etc...
system defaults...
setting up launchd services...
reloading nix-daemon...
waiting for nix-daemon
configuring networking...
configuring power...
setting up /Library/Fonts/Nix Fonts...
setting nvram variables...
Activating home-manager configuration for qmpwwsd
Starting Home Manager activation
Activating checkFilesChanged
Activating checkLaunchAgents
Activating checkLinkTargets
Activating writeBoundary
Activating installPackages
Activating linkGeneration
Cleaning up orphan links from /Users/qmpwwsd
No change so reusing latest profile generation 121
Creating home file links in /Users/qmpwwsd
Activating onFilesChange
Activating setupLaunchAgents

It looks that the symlinks was created (because I see them in .config) but don’t used

Well it definitely seems to work now! It makes it all the way to Activating setupLaunchAgents which is the last step when darwin-rebuild is switching to a new generation. Since we have solved the issue you posted about originally, I suggest you mark this thread as solved :^)

With regards to the changes you have made, they were probably a bit heavy-handed. You didn’t have to remove that much. You could just change the 3 lines to something like this:

loginwindow = {
  LoginwindowText = "qmpwwsd (code)";
};

It’s just important that you don’t use < as it will start a new XML tag.

But issue with unused configs is still((
Sorry about spending your time. What I can do check why it don’t work?

I hope it’s the last problem which I would have :melting_face:
My friend, you helped me a lot with this problem, if it wasn’t for you I think I would never have guessed what it was :handshake:
Will be great if you can help me with the last thing with this symlinks errors

What’s the issue? The directories look like they are symlinked to the correct location. Does the config not apply to your applications?

Yeah, exactly!
I checked the symlinks and they correct but the configs don’t use
Sorry, I’m newbee with it

Me too :slight_smile:
Does it happen only to the applications with the “symlink warning”? Or is the configuration not applied on any applications?

Not for all. All which I ‘symlinked’. For example, kitty, nvim, zsh, etc.