Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Firstly - thanks for contributing this!

I've been meaning to learn about this "nix" thing everybody keeps raving on for a while =), and I figured it might be a good way to make my Mac machines easier to bringup/tear down, and less "pet-like".

I'm still very new, so it's possible I'm missing something obvious:

However, I've started following the steps in the README, and at steps 6 and 7., it has a long list of packages:

and also configurations for many packages:

A lot of the packages are undoubtedly very cool, and I would love to discover them all - but it's also quite opinionated, and overwhelming for somebody new to all of this.

Question 1 - Is there some way to easily get a barebones configuration from your config, and then you add/enable the packages you want later on?

(It would be cool if it was just a flag or something, you could enable/disable, but don't know how easy/hard that is in nix).

Also - there aren't comments on the packages - so I'm not sure if removing them will have some unwanted side-effects.

For example, I see here it refers specifically to installing python39 - I assume there's a specific reason we want Python 3.9 as opposed to the current stable (3.12) right? So I'm unsure if I should remove it or not.

Question 2 - Is the rationale behind certain packages (e.g. Python 3.9) documented or captured somewhere? Or if you just point me in the rough direction, happy to file a PR with comments (if that's acceptable).

Also, I did do a rough pass through the casks.nix and packages.nix files, and uncomment the stuff that seemed optional - however, it seems the configuration (home-manager.nix x 2) must override those somehow. For example, if I uncomment a package - Nix still seemed to install it anyway - I assume due to dependencies, or possible because the configuration was in one of the home-manager.nix files?

Question 3 - Is simply uncommenting the package from casks.nix/``packages.nix`, or is there something else?

And even things like google-chrome, I was hoping to install chrome Canary, using homebrew-cask-versions, but it was unclear how to tap that via nix/home-manager...?

Question 4 - (Would homebrew-cask-versions make sense to be available in the base config? It's pretty useful if you want to have a bit more choice on which versions of casks you install).

You must be logged in to vote

Replies: 1 comment · 4 replies

Comment options

Hi,

Yes the backstory on this repository is that I was using it as my main configuration for some time, then decided to create templates for others to try. So it's heavily based on what I started with.

The vision is that the installer will ask you questions to include the main stuff (what editor, common CLI tools, etc.), then give you resources to add the rest of the packages you want.

Haven't had the time to build that yet. Now, on to your questions.

Question 1 - Is there some way to easily get a barebones configuration from your config, and then you add/enable the packages you want later on?

For the most part, you can remove any line in packages.nix in both darwin and shared and add whatever you want. You won't break anything, as Nix is managing dependencies under the hood for you anyway.

If you don't want emacs, you can remove the code here and here.

Question 2 - Is the rationale behind certain packages (e.g. Python 3.9) documented or captured somewhere? Or if you just point me in the rough direction, happy to file a PR with comments (if that's acceptable).

Contribution to the README or other documentation would be greatly appreciated. No specific reason for python 3.9; it's just what I was using at that time. You can swap out anything you like and it should work (the beauty of Nix).

Question 3 - Is simply uncommenting the package from casks.nix/``packages.nix`, or is there something else?

Yep, any line in those files gets imported/installed in the Nix Store. Then Nix creates a symlink to it from where the Mac expects it to be installed on your machine. So it's very easy to add/remove packages, think of like npm or something else.

I haven't used the homebrew-cask-versions package, unfortunately, but my experience is I can do most things with this configuration after a little digging.

Question 4 - (Would homebrew-cask-versions make sense to be available in the base config? It's pretty useful if you want to have a bit more choice on which versions of casks you install)

I'm hesitant to add more dependencies, as that requires more maintenance overall. However, if you get it working for you, it's simple and provides a lot of value, I'd love to consider it.

Good luck!

You must be logged in to vote
4 replies
@victorhooi
Comment options

I'm still trying to get this setup without pulling in emacs, and still hitting some brick walls =(.

It seems there's actually many different places that emacs, or emacs plugins, or emacs configuration is referenced, and it's quite hard to separate them out.

I thought I'd got most of them - but it seems the Nix store has somehow cached something? Or do you know why the first error below is still happening, even though myEmacsLauncher doesn't occur in ~/nixos-config?

$ nix run .#build

Running build for aarch64-darwin
Starting build...
error:
       … while evaluating the attribute 'config.system.build.toplevel'
         at /nix/store/0aavdx9m5ms1cj5pb1dx0brbrbigy8ij-source/lib/modules.nix:322:9:
          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          323|         _module = checked (config._module);

       … while calling the 'seq' builtin
         at /nix/store/0aavdx9m5ms1cj5pb1dx0brbrbigy8ij-source/lib/modules.nix:322:18:
          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: undefined variable 'myEmacsLauncher'
       at /nix/store/v6yndhv2yzyw0aq8p02jasyak0zkyzq0-source/modules/darwin/home-manager.nix:74:23:
           73|     {
           74|       path = toString myEmacsLauncher;
             |                       ^
           75|       section = "others";
$ nix run .#build
Running build for aarch64-darwin
Starting build...
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'darwin-system-24.05.20240517.4a6b83b+darwin4.ffc0118'
         whose name attribute is located at /nix/store/0aavdx9m5ms1cj5pb1dx0brbrbigy8ij-source/pkgs/stdenv/generic/make-derivation.nix:331:7

       … while evaluating attribute 'activationScript' of derivation 'darwin-system-24.05.20240517.4a6b83b+darwin4.ffc0118'
         at /nix/store/6pkv7rry8qarxnaxrwdssivf294m72gk-source/modules/system/default.nix:95:7:
           94|
           95|       activationScript = cfg.activationScripts.script.text;
             |       ^
           96|       activationUserScript = cfg.activationScripts.userScript.text;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: opening file '/nix/store/k0xlrf4agh9wxnjg6j9f6qkvm05b4qky-source/modules/shared/config/emacs/init.el': No such file or directory
$ nix run .#build
Running build for aarch64-darwin
Starting build...
error:
       … while evaluating the attribute 'config.system.build.toplevel'
         at /nix/store/0aavdx9m5ms1cj5pb1dx0brbrbigy8ij-source/lib/modules.nix:322:9:
          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          323|         _module = checked (config._module);

       … while calling the 'seq' builtin
         at /nix/store/0aavdx9m5ms1cj5pb1dx0brbrbigy8ij-source/lib/modules.nix:322:18:
          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: undefined variable 'myEmacsLauncher'
       at /nix/store/kiqnhac0n9x3z36y84z2rgk2r55vg5sq-source/modules/darwin/home-manager.nix:49:47:
           48|           additionalFiles
           49|           { "emacs-launcher.command".source = myEmacsLauncher; }
             |                                               ^
           50|         ];
$ nix run .#build
Running build for aarch64-darwin
Starting build...
error:
       … while evaluating the attribute 'config.system.build.toplevel'
         at /nix/store/0aavdx9m5ms1cj5pb1dx0brbrbigy8ij-source/lib/modules.nix:322:9:
          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          323|         _module = checked (config._module);

       … while calling the 'seq' builtin
         at /nix/store/0aavdx9m5ms1cj5pb1dx0brbrbigy8ij-source/lib/modules.nix:322:18:
          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: undefined variable 'myEmacsLauncher'
       at /nix/store/v6yndhv2yzyw0aq8p02jasyak0zkyzq0-source/modules/darwin/home-manager.nix:74:23:
           73|     {
           74|       path = toString myEmacsLauncher;
             |                       ^
           75|       section = "others";
@victorhooi
Comment options

Oh, and running nix store repair doesn't work for me (although I just blindly tried this based on a Google):

$ nix store repair
error: flake 'path:/Users/foobar/nixos-config' does not provide attribute 'packages.aarch64-darwin.default' or 'defaultPackage.aarch64-darwin'
@dustinlyons
Comment options

Can you search the files and remove the block of Nix that referencesmyEmacsLauncher? Should be in home-manager.nix.

@victorhooi
Comment options

Got i t- yes, I was able to edit ~/nixos-config/modules/darwin/home-manager.nix, and comment out these lines:

https://github.com/dustinlyons/nixos-config/blob/d003068a91486e11b45c18ec2cf0e2534c4d0020/modules/darwin/home-manager.nix#L92C1-L95C8

I was then able to finally run nix run .#build-switch. Yes!

(One slight hiccup with the Mac App Store apps - #83 - but I was able to comment those out, although would still like to figure out the root cause there).

I'm really keen to get this whole Nix setup working well, and learn more about Nix to boot - and see if others at work want to learn about it as well =).

Still definitely a lot to learn.

Also, I suspect I've really hacked/kludged my way around commenting out things I didn't want/need or that conflicted from the default config.

It would be amazing if there was a minimal version of this repo, just to get a baseline Nix on Mac setup working. (Even if it didn't have all the questions - at least having a basic template, you can add the additional Homebrew formulas, casks or other apps you need). But yeah, I appreciate that could be a fair bit of work on your side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.