Skip to content

flake: overhaul flake#329

Merged
flokli merged 4 commits into
mainfrom
unknown repository
Sep 22, 2025
Merged

flake: overhaul flake#329
flokli merged 4 commits into
mainfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Aug 5, 2025

Changes Summary

Outputs pattern

I noticed that the flake used self as a self-referential attribute but the more idiomatic way to use it is with inherit (self) outputs which allows for dropping rec and makes self-referring much easier.

Dropping treefmt-nix

In my research while looking at the CI for nixpkgs, I discovered the nixfmt-tree package which fills in all the messy details for us while also allowing for dropping the treefmt-nix input.

For more information see: https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/ni/nixfmt-tree/package.nix#L60

For the PR linting workflow: we can use nix flake check as always.

devShells/Direnv

In addition, I added direnv support and devshells which contains only treefmt in its environment to assist in contributions.

Default package attribute:

The next thing that the devshell also pointed out is that there wasn't a default package attribute for this flake, so I used the installer-boostrap for it. This allows for one-liners like this to be used:

$ nix build github:normalcea/nixos-apple-silicon/flake-rework
evaluating derivation 'github:normalcea/nixos-apple-silicon/flake-rework#packages.aarch64-linux.default'
[2/0/118 built, 0.0 MiB DL] building systemd-257.5 (patchPhase):

So we can simplify the cloning step for flakes users (which afaik is in the majority) and also have a one liner for building the ISO which can shorten the install documentation which has users build each package separately.

flatten nixpkgs.url

Just for consistency, I don't see any need for any additional flake inputs besides nixpkgs and flake compat.

Testing

For testing this PR, I ran nix flake check as well as nix flake show and nix flake metadata

@tpwrules
Copy link
Copy Markdown
Collaborator

Outputs pattern

This seems reasonable. Do you have info on the idiom? Does this increase evaluation time?

Dropping treefmt-nix

This also seems good, I like less inputs. What does this do to nix fmt? I assume this doesn't change which nixfmt executable is used.

flatten nixpkgs.url

Reasonable.

devShells/Direnv
Default package attribute:

I don't understand the advantages here, assuming nix fmt still works. A one-liner works today with nix build github:nix-community/nixos-apple-silicon#installer-bootstrap.

The docs were written long ago. Even back then though I think the majority of users should use the pre-built ISOs though that may change as we change the release model. The docs certainly need updating, I don't think that thought has ever been particularly clear.

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 10, 2025

This seems reasonable. Do you have info on the idiom? Does this increase evaluation time?

self is referring to the whole flake as a whole, since we only want to refer to flake outputs, it's more idiomatic to do it this way.

$ nix eval .#self.
.#self.checks            .#self.inputs            .#self.outPath           .#self.sourceInfo
.#self.devShells         .#self.lastModified      .#self.outputs           .#self.submodules
.#self.dirtyRev          .#self.lastModifiedDate  .#self.overlays          .#self._type
.#self.dirtyShortRev     .#self.narHash           .#self.packages          
.#self.formatter         .#self.nixosModules      .#self.self              

This also seems good, I like less inputs. What does this do to nix fmt? I assume this doesn't change which nixfmt executable is used.

It doesn't, nixfmt-tree is simply just a nixpkgs way of creating a treefmt.toml for use with treefmt running nix fmt has no changes.

I don't understand the advantages here

Many users (including me) use direnv to automatically enter a nix shell environment within their editors. nix-shell complains if there isn't a default package set and so setting the installer iso as the default package resolves that.

@flokli
Copy link
Copy Markdown
Member

flokli commented Aug 18, 2025

Many users (including me) use direnv to automatically enter a nix shell environment within their editors. nix-shell complains if there isn't a default package set and so setting the installer iso as the default package resolves that.

I'm not sure the installer iso is a reasonable default package setting. nixos-apple-silicon provides a bunch of individual packages, but its main output is mostly the module code, which is consumed from other NixOS code. Maybe it's fine to leave that warning for now. Can you rebase this PR (it needs rebasing) and drop 50b90e1?

@tpwrules
Copy link
Copy Markdown
Collaborator

Sorry, I thought I commented, but my concern with making the installer as the dev shell is that the user would have to build all the dependencies (kernel, etc.) just to start the environment.

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 20, 2025

Dropped the default package commit and rebased on current main.

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 31, 2025

Force pushed and rebased on current main

@flokli flokli merged commit 9eb8ad0 into nix-community:main Sep 22, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants