Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flake.nix #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Flake.nix #1

wants to merge 2 commits into from

Conversation

SomeoneSerge
Copy link
Owner

flake.nix seems to be outdated

  • seemingly unneeded ${system}s sprinkled around (already taken care by flake-utils)?
  • old flake.lock seems to cause cache-misses (or maybe I'm doing smth wrong)
  • nix show fails trying to evaluate non-native system's attributes

Hoping that laziness would allow `nix show` to succeed

Didn't work out, still

> a 'aarch64-linux' with features {} is required to build '/nix/store/lfyv583109w95bl1nr8j33my2s4y7qvl-all-package-names.drv', but I am a 'x86_64-linux' with features {benchmark, big-parallel, kvm, nixos-test, recursive-nix}
@shadowrylander
Copy link

Quick question: how much would you happen to know about flake-utils itself?

@SomeoneSerge
Copy link
Owner Author

@shadowrylander not much at all! I used it a couple of times to reduce the boilerplate and seem to be making guesses that work for my small needs.

In particular, I'm still unsure about mechanics of flattenTree on the flake's interface, because with it we seem to need to evaluate the contained expressions

@shadowrylander
Copy link

Ah; was wondering if you could help me configure it for use with the nixosConfigurations set instead of packages! 😅

And regarding flattenTree, apparently packages needs to be passed a, well, flattened tree of packages, according to the flake-utils section on the function.

@SomeoneSerge
Copy link
Owner Author

apparently packages needs to be passed a, well, flattened tree of packages

Yeah, the idea is that outputs.${system}.packages must have a type "list of derivations". This is opposed to e.g. nixpkgs having attributes like texlive which aren't derivations but attrsets wrapping other derivations and functions (e.g. texlive has an attribute combine used to construct a texlive with a subset of LaTeX packages; it's attributes like texlive that flakes must have legacyPackages output). This is needed so that flakes can be efficiently and deterministically inspected without checking out the code and evaluating things. So that's what flattenTree apparently does: it traverses the tree at produces the list of those its leaves that are derivations.

By the way, since we seem to be both just trying to navigate in flakes, I'll leave some links I found useful (although you're likely already aware of those):

Ah; was wondering if you could help me configure it for use with the nixosConfigurations set instead of packages

I'd be glad if I could be of any help. If you're talking about the use-case you described in DavHau#153 though, I haven't read it thoroughly yet, it's quite an amount of information

@shadowrylander
Copy link

Thanks for the detailed explanation! I've found most of the links myself as well except for the video, but I'll go through them again anyway!

Regarding using flake-utils to build nixosConfigurations, here's an issue I created in their repo: numtide/flake-utils#10

@mkaito
Copy link

mkaito commented Nov 21, 2020

Hi!

I came across this by chance. I work as SRE for Serokell.

You might find some of our recent work switching all of our infrastructure code to flakes interesting. The documentation could use some work, and much is WIP, but perhaps it can serve as an example of how to do things with flakes.

Flakes are a very experimental feature, some things are broken in nix itself, and the only real documentation is the closed RFC. You'll almost certainly want a more recent build of nix than is available in nixpkgs at any given time. You'll notice we build nix from master in devShell to make this easier.

https://github.com/serokell/deploy-rs
https://github.com/serokell/serokell.nix
https://github.com/serokell/pegasus-infra

Some of us hang out on IRC in #nixos on Freenode, in case you have questions.

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