dustinlyons / nixos-config

General purpose Nix configuration for macOS / NixOS with starter templates + step-by-step guides ✨
BSD 3-Clause "New" or "Revised" License
1.79k stars 113 forks source link

Fresh install issues #26

Closed multivac61 closed 1 year ago

multivac61 commented 1 year ago

When calling bin/build I get the following error

~/dev via  v21.1.0 via 🐦
❯ mkdir -p nixos-config

~/dev via  v21.1.0 via 🐦
❯ cd nixos-config && nix flake init -t github:dustinlyons/nixos-config#starte
error: experimental Nix feature 'nix-command' is disabled; use '--extra-experimental-features nix-command' to override

~/dev/nixos-config
❯ nix flake --extra-experimental-features nix-command --extra-experimental-features flakes init -t github:dustinlyons/nixos-config#starter
wrote: /Users/olafur/dev/nixos-config/bin/apply
wrote: /Users/olafur/dev/nixos-config/bin/nixos-build
wrote: /Users/olafur/dev/nixos-config/bin/darwin-build
wrote: /Users/olafur/dev/nixos-config/bin/build
wrote: /Users/olafur/dev/nixos-config/bin
wrote: /Users/olafur/dev/nixos-config/overlays/README.md
wrote: /Users/olafur/dev/nixos-config/overlays
wrote: /Users/olafur/dev/nixos-config/shared/home-manager.nix
wrote: /Users/olafur/dev/nixos-config/shared/files.nix
wrote: /Users/olafur/dev/nixos-config/shared/config/p10k.zsh
wrote: /Users/olafur/dev/nixos-config/shared/config/emacs/config.org
wrote: /Users/olafur/dev/nixos-config/shared/config/emacs/init.el
wrote: /Users/olafur/dev/nixos-config/shared/config/emacs/.gitignore
wrote: /Users/olafur/dev/nixos-config/shared/config/emacs
wrote: /Users/olafur/dev/nixos-config/shared/config
wrote: /Users/olafur/dev/nixos-config/shared/README.md
wrote: /Users/olafur/dev/nixos-config/shared/default.nix
wrote: /Users/olafur/dev/nixos-config/shared/packages.nix
wrote: /Users/olafur/dev/nixos-config/shared/cachix/default.nix
wrote: /Users/olafur/dev/nixos-config/shared/cachix
wrote: /Users/olafur/dev/nixos-config/shared
wrote: /Users/olafur/dev/nixos-config/flake.nix
wrote: /Users/olafur/dev/nixos-config/nixos/home-manager.nix
wrote: /Users/olafur/dev/nixos-config/nixos/disk-config.nix
wrote: /Users/olafur/dev/nixos-config/nixos/files.nix
wrote: /Users/olafur/dev/nixos-config/nixos/config/login-wallpaper.png
wrote: /Users/olafur/dev/nixos-config/nixos/config/rofi/launcher.rasi
wrote: /Users/olafur/dev/nixos-config/nixos/config/rofi/colors.rasi
wrote: /Users/olafur/dev/nixos-config/nixos/config/rofi/confirm.rasi
wrote: /Users/olafur/dev/nixos-config/nixos/config/rofi/message.rasi
wrote: /Users/olafur/dev/nixos-config/nixos/config/rofi/powermenu.rasi
wrote: /Users/olafur/dev/nixos-config/nixos/config/rofi/styles.rasi
wrote: /Users/olafur/dev/nixos-config/nixos/config/rofi/networkmenu.rasi
wrote: /Users/olafur/dev/nixos-config/nixos/config/rofi
wrote: /Users/olafur/dev/nixos-config/nixos/config/polybar/modules.ini
wrote: /Users/olafur/dev/nixos-config/nixos/config/polybar/bars.ini
wrote: /Users/olafur/dev/nixos-config/nixos/config/polybar/config.ini
wrote: /Users/olafur/dev/nixos-config/nixos/config/polybar/colors.ini
wrote: /Users/olafur/dev/nixos-config/nixos/config/polybar/user_modules.ini
wrote: /Users/olafur/dev/nixos-config/nixos/config/polybar
wrote: /Users/olafur/dev/nixos-config/nixos/config
wrote: /Users/olafur/dev/nixos-config/nixos/README.md
wrote: /Users/olafur/dev/nixos-config/nixos/default.nix
wrote: /Users/olafur/dev/nixos-config/nixos/packages.nix
wrote: /Users/olafur/dev/nixos-config/nixos
wrote: /Users/olafur/dev/nixos-config/darwin/home-manager.nix
wrote: /Users/olafur/dev/nixos-config/darwin/files.nix
wrote: /Users/olafur/dev/nixos-config/darwin/casks.nix
wrote: /Users/olafur/dev/nixos-config/darwin/README.md
wrote: /Users/olafur/dev/nixos-config/darwin/default.nix
wrote: /Users/olafur/dev/nixos-config/darwin/packages.nix
wrote: /Users/olafur/dev/nixos-config/darwin/dock/default.nix
wrote: /Users/olafur/dev/nixos-config/darwin/dock
wrote: /Users/olafur/dev/nixos-config/darwin

~/dev/nixos-config
❯ chmod +x bin/apply && bin/apply
\033[0;32mUsername: xxx
Email: myemail@xxx.com
Name: xxx\033[0m
\033[1;33mIs this correct? (Y/N): \033[0m
Y
\033[0;32mContinuing...\033[0m
\033[0;32mUser xxx information applied.\033[0m

~/dev/nixos-config took 2s
❯ sudo mv /etc/nix/nix.conf /etc/nix/nix.conf.before-nix-darwin
Password:
mv: rename /etc/nix/nix.conf to /etc/nix/nix.conf.before-nix-darwin: No such file or directory

~/dev/nixos-config took 2s
❯ chmod +x bin/darwin-build && chmod +x bin/build && bin/build
Starting build...
warning: creating lock file '/Users/olafur/dev/nixos-config/flake.lock'
error: flake 'path:/Users/olafur/dev/nixos-config' does not provide attribute 'packages.aarch64-darwin.darwinConfigurations.Dustins-MBP.system', 'legacyPackages.aarch64-darwin.darwinConfigurations.Dustins-MBP.system' or 'darwinConfigurations.Dustins-MBP.system'
multivac61 commented 1 year ago

Another issue is that username dustin is hardcoded inside darwin/files.nix and is not changes when calling bin/apply

Calling nix build .#darwinConfigurations.macos.system && ./result/sw/bin/darwin-rebuild switch --flake .#macos worked after changing dustin to my own username.

dustinlyons commented 1 year ago

Thanks for letting me know! I think I introduced a recent regression when making changes. I'll fix this in a few hours.

dustinlyons commented 1 year ago

These should all be fixed now. Let me know if that's not the case.

I also updated the commands in the docs for the errors you pointed out. Thanks again, this helps a ton!

multivac61 commented 1 year ago

Thank you for the update Dustin!

Unfortunately I had to break the experimental flags into two

nix flake --extra-experimental-features nix-command --extra-experimental-features flakes init -t github:dustinlyons/nixos-config#starter

Otherwise I get the following error:

dustinlyons-nixos-config/nixos-config on ξ‚  main
❯ nix flake '--extra-experimental-features nix-command flakes' init -t github:dustinlyons/nixos-config#starter
error: unrecognised flag '--extra-experimental-features nix-command flakes'
Try 'nix --help' for more information.
multivac61 commented 1 year ago

I am not able to build using ./bin/build

dustinlyons-nixos-config/nixos-config on ξ‚  main [?]
❯ pwd
/Users/olafur/dev/dustinlyons-nixos-config/nixos-config

dustinlyons-nixos-config/nixos-config on ξ‚  main [?]
❯ chmod +x bin/apply && bin/apply
Username: olafur
Email: olafur@genkiinstruments.com
Name: Γ“lafur Bjarki Bogason
Is this correct? (Y/N):
y
Continuing...
User olafur information applied.

dustinlyons-nixos-config/nixos-config on ξ‚  main [?]
❯ [ -f /etc/nix/nix.conf ] && sudo mv /etc/nix/nix.conf /etc/nix/nix.conf.before-nix-darwin

dustinlyons-nixos-config/nixos-config on ξ‚  main [?]
❯ ls /etc/nix/
builder_ed25519              netrc                        nix.conf.before-nix-darwin@  registry.json@
builder_ed25519.pub          nix.conf.before-nix-darwi    nix.conf.before-nix-darwin2@

dustinlyons-nixos-config/nixos-config on ξ‚  main [?]
❯ chmod +x bin/darwin-build && chmod +x bin/build && bin/build
Starting build...
error: getting status of '/nix/store/g6pf2fqf9pwnz0mz94k1qbp51hq30803-source/nixos-config': No such file or directory
dustinlyons commented 1 year ago

Can you try making your nixos-config a git repo, making an initial commit, then trying again?

multivac61 commented 1 year ago

Worked like a charm! Maybe include the git step in the tutorial too πŸ‘ Thank you again so much for this initiative, truly valuable!

Here is a GitHub repo I derived from your template.

Now however I am running into issues with Alacritty. For some reason it won't start up and the dock icon is a question mark... any thoughts?

I filed a report and they told me it had something to do with a broken shell config..

CleanShot 2023-11-12 at 16 14 30@2x

CleanShot 2023-11-12 at 16 15 17@2x

dustinlyons commented 1 year ago

Hey! Glad to hear it all worked. I will definitely add the Git step to the instructions.

In re: to the error, my configuration uses Zsh across NixOS and MacOS. I searched for the word 'fish' in my repo and yours, and can't find it. So something locally is conflicting and trying to load the fish shell and failing.

To temporarily get around this, you could try to add fish to the configuration and see if it loads. Then inspect what's in your home directory that could be causing the conflict. I actually don't know much about fish.

To add fish, you can look at shared/home-manager.nix and add fish.enable = true; to the top.

dustinlyons commented 1 year ago

Sometimes I see the ? in the dock icon before running alacritty or Emacs for the first time; then the icon is set. So that doesn't necessarily point to something broken; I think Zsh is starting, then fish is trying to start, and since fish can't be found it fails and doesn't start the fish shell.

multivac61 commented 1 year ago

Hmmm strange. I am able to launch alacritty just fine from the Terminal. But nothing happens when I click the dock icon.

multivac61 commented 1 year ago

CleanShot 2023-11-14 at 12 22 46

dustinlyons commented 1 year ago

And if you run it from the shell there, you get the fish error? Or something else?

In my dock I get alacritty, and doing the 'Show in Finder' option shows the app inside the Nix Store. But it seems not be installed there.

dustinlyons commented 1 year ago

I would try to get it working from the CLI (outside of the dock), maybe by trying to first simplify options in https://github.com/multivac61/dustinlyons-nixos-config/blob/main/shared/home-manager.nix#L195.

The font it uses comes from here: https://github.com/dustinlyons/nixos-config/blob/3fcc6bb4fc56d1b29991c55817f96a20f9e666d4/templates/starterWithSecrets/shared/packages.nix#L58

I recently tested this on a fresh M1 Macbook Air and was able to bootstrap it, and the fish error is strange given fish doesn't exist in the configuration. So it makes me feel like something else is going on.

dustinlyons commented 1 year ago

Could also be some of these options: https://github.com/multivac61/dustinlyons-nixos-config/blob/main/shared/home-manager.nix#L10C1-L10C41

Can you try to remove and simplify these options are much as possible? You could even remove powerlevel10k.

multivac61 commented 1 year ago

Hmm.. there isn't anything inside the Applications folder

CleanShot 2023-11-16 at 15 32 54

dustinlyons commented 1 year ago

Okay, interesting. Are you able to launch alacritty from the terminal and it launches, but just the placement of the dock icon is broken? Or are there errors launching alacritty from the terminal?

multivac61 commented 1 year ago

I am able to launch alacritty for the terminal just fine, no errors. It's just the dock that is broken.

dustinlyons commented 1 year ago

Here is what mine looks like:

Screenshot 2023-11-16 at 11 16 07β€―AM

Can you grab the latest and try to build everything again? Just want to make sure it happens on multiple builds.

multivac61 commented 1 year ago

I grabbed the latest and built everything again.. I even restarted the computer just in case!

CleanShot 2023-11-20 at 17 16 23

CleanShot 2023-11-20 at 17 15 54

Even tried one more time from scratch and then I got this..

CleanShot 2023-11-20 at 17 41 29

CleanShot 2023-11-20 at 17 46 51

multivac61 commented 1 year ago

I am 90% sure this has something to do with how I set up Alacritty. If I remove the config dir I am able to run Alacritty from the sidebar... need to investigate further on my end. Closing issue now.

ps thank you again for maintaining this template and continuing to work on it (love the new refactor!). I am learning a ton!

dustinlyons commented 12 months ago

@multivac61 Good to hear! Let me know if you have any questions and I'm happy to try and help.

tlindsay commented 12 months ago

I'm not sure if it's actually related to this issue or not, but after running bin/build, I'm also getting error: flake 'git+file:///my/nix/config' does not provide attribute 'packages.aarch64-darwin.default or 'defaultPackage.aarch64-darwin'`

I see that it did install brew, but it didn't install any brew packages, and I don't seem to have any nix packages installed either as far as I can tell.

It actually has kind of broken my whole machine, so any advice on how to fix OR rollback would be super appreciated πŸ˜…

dustinlyons commented 12 months ago

Hmmm, very strange. Can you paste your flake.nix here?

tlindsay commented 11 months ago

@dustinlyons I just spent like 30 minutes writing up a super detailed report on how I fixed everything, and then accidentally hit "back" and github lost it all 😭

The short version is:

Last recommendation I'll make is what I think would be the most impactful: encourage some form of initial dry-run for new installs. This could be accomplished by updating the README to explain how to run a build and test it with nix-shell or nix develop or whatever, OR it could be built into the custom scripts in bin/. The main thing is that I didn't realize that running bin/build the first time would be a destructive operation to my existing development environment. And when that first build went sideways, it left me with a lot of fires to put out.

I don't want to be a downer! I think this project is a really nice on-ramp, but it does have some pretty sharp edges and some extra guard rails would be welcome πŸ˜„

dustinlyons commented 11 months ago

Oh wow, this is such great feedback! I very much appreciate you taking the time to write this (and your first draft πŸ˜†).

Dry run is a great idea! I think for NixOS this is easy as I will have an option for a Live ISO soon. For nix-darwin, I'll have to think through this, as it wants to alter your running system, change directives, update launchd, etc. Maybe something like

nix run nix-darwin -- build --flake .#macos

first and then

darwin-rebuild switch --flake .#macos

All such good feedback I will incorporate soon. Thanks again @tlindsay!