4 ms·
Is there good explanation anywhere of the syntax of those files? I tried getting into nix multiple times and was always put off by the lack of understandability
by zeisss 9y ago
Is there good explanation anywhere of the syntax of those files? I tried getting into nix multiple times and was always put off by the lack of understandability of this.
- lallysingh 9y agoThe syntax is, by far, the most painful part. Change the drop-down to Nix then click on the manual. The website is hard to navigate in that way.
- k__ 9y agohttps://medium.com/@MrJamesFisher/nix-by-example-a0063a1a4c55 https://medium.com/@MrJamesFisher/nix-by-example-a0063a1a4c5...
- zimbatm 9y agoNix is a bit like JSON + functions. An object (called attrset in nix): { a = 3; b = 4; } A list: [ 1 2 3 4 ]; A string: "hello" A multi-line string: '' multine string '' This defines a lambda with two arguments: a: b: a + b; It's possible to pattern-match arguments. This accepts an attrset with keys a and b, and maps them to local variables: { a, b }: a + b; There are some variations around that like `{ a ? 3 }:` `{ a }@attrs:` and `{ a, ... }` One special type is the path, which has it's own literal that starts with `./` To load a file, the `import` keyword is being used. In most cases the whole file is a big lambda function, which gets returned by the import. Once you know that you can start reading nixpkgs and learn about the building blocks to constructs packages.
- FrozenCow 9y agoAlso, for convenience, nested objects/attrsets can be shortened. For instance: { a = { b = { c = 3; }; }; } can be shortened to: { a.b.c = 3; } This is used quite often in NixOS system configuration files. There you'll find lines like: services.openssh.enable = true; For a list of all system configuration options that NixOS supports by default see (NixOS options)[https://nixos.org/nixos/options.html https://nixos.org/nixos/options.html].
- mrkgnao 9y agohttps://github.com/knedlsepp/nix-cheatsheet https://github.com/knedlsepp/nix-cheatsheet
- yaseer 9y agohttps://learnxinyminutes.com/docs/nix/ https://learnxinyminutes.com/docs/nix/ Also includes links to the only other resources I found.
- abhirag 9y agoI read Nix Pills and they were very informative -- https://nixos.org/nixos/nix-pills/ https://nixos.org/nixos/nix-pills/
- olejorgenb 9y agoThe nix language: https://nixos.org/nix/manual/#chap-writing-nix-expressions https://nixos.org/nix/manual/#chap-writing-nix-expressions Abstractions used in nixpkgs: https://nixos.org/nixpkgs/manual/ https://nixos.org/nixpkgs/manual/ http://lethalman.blogspot.no/2014/07/nix-pill-1-why-you-should-give-it-try.html http://lethalman.blogspot.no/2014/07/nix-pill-1-why-you-shou... https://medium.com/@MrJamesFisher/nix-by-example-a0063a1a4c55 https://medium.com/@MrJamesFisher/nix-by-example-a0063a1a4c5...