8 ms·
The big thing this is going to miss between 2018 and now is that flakes have greatly increased presence. The small things are: - nix-direnv[1] is much more po
by flurie 4y ago
The big thing this is going to miss between 2018 and now is that flakes have greatly increased presence.
The small things are:
- nix-direnv[1] is much more powerful and stable, with or without flakes
- devshell[2] exists and is reasonably mature for those who want to give this to a team without teaching them (most) nix
Still, apart from those, this is still a good intro.
[1] https://github.com/nix-community/nix-direnv https://github.com/nix-community/nix-direnv
[2] https://github.com/numtide/devshell https://github.com/numtide/devshell
- JamesSwift 4y agoYeah, I checked the date after seeing a lack of flakes and sure enough: 2018. If you are new to nix I 100% recommend starting with flakes. It simplifies so much for a newbie, e.g. no management of NIX_PATH and simple upgrades (`sudo nix upgrade-nix`). It also enables essentially single-line machine bootstrap on a new box even if you use home-manager.
- flurie 4y agoDo you know of any basic nix tutorials that skip the non-flake world? I'm not sure that they exist, but I think they could be really helpful. A lot of confusion when adopting flakes seems to come from the fact that the terrible UX of the old nix commands doesn't map cleanly to the (not perfect but visibly improved) new commands. Why learn this... nix-env -iA nixpkgs.hello ...when you can learn this instead? nix profile install nixpkgs#hello
- JamesSwift 4y agoI have no idea, I have been with nix for long enough that I hadn't sought anything like that out. I should note that flakes are still technically experimental (i.e. opt-in), and theres still some community drama around not wanting to go with flakes mainly by longtime nix users. Also note that the "modernized" `nix` CLI interface is experimental/opt-in as well vs the out-of-the-box "legacy" commands (e.g. nix-env). So yeah, its a bit of an odd time in nix land as they transition but I don't see any indication that you would be poorly served or burned by moving to both nix command and flakes now.
- SkyMarshal 4y agoFor anyone interested in learning Nix Flakes: https://www.reddit.com/r/NixOS/comments/v2xpjm/big_list_of_flakes_tutorials/ https://www.reddit.com/r/NixOS/comments/v2xpjm/big_list_of_f...
- zamalek 4y agoUsing these with home-manager is also really simple. You simply enable nix-direnv[0], and then `use flake` in your envrc[1]. Finally, set up your flake.nix with a dev shell[2] (I'm definitely going to take a look at numtide's devshell). You'll also need flakes and the nix command enabled first [3] (add that line to `/etc/nix/nix.conf` if you aren't using nixos). Why use flakes? Mostly because it has a lockfile: there's a really good chance that "works on my machine" is "works on my team's machines." Flakes are also much cleaner than vanilla Nix. [0]: https://gitlab.com/jcdickinson/nix/-/blob/main/home/general.nix#L65 https://gitlab.com/jcdickinson/nix/-/blob/main/home/general.... [1]: https://gitlab.com/jcdickinson/nix/-/blob/main/.envrc#L3 https://gitlab.com/jcdickinson/nix/-/blob/main/.envrc#L3 [2]: https://gitlab.com/jcdickinson/nix/-/blob/main/flake.nix#L65 https://gitlab.com/jcdickinson/nix/-/blob/main/flake.nix#L65 [3]: https://gitlab.com/jcdickinson/nix/-/blob/70844981d5cd63c83932f201480ad736c322335c/system/configuration.nix#L26 https://gitlab.com/jcdickinson/nix/-/blob/70844981d5cd63c839...
- ghoward 4y agoCan someone please ELI5 flakes to me? Specifically: * What they add from vanilla Nix. * What they take away. * How they work. * Why channels are unnecessary with flakes (once they're complete) as TFA implies. * How much they replace home-manager. * Why they add even more reproducibility. * Why else I should care about them. Other questions that might help me: Are they just adding the equivalent of lockfiles to vanilla Nix? If so, why is that such a hard transition? My initial impression on reading about Nix, and I've read a lot, is that Nix already had lockfiles. Context: not a Nix user, but I've read the Nix thesis, the NixOS thesis, a lot of the Tweag blog posts about flakes, a lot of the xeiaso.net posts about flakes, and a lot of the other posts listed in the Reddit link of a child of a sibling comment. Despite all of that reading, I don't get them. I have a hard time following regular Nix as it is, and if I start using Nix, I want to start with flakes.
- JamesSwift 4y agoI'm not knowledgeable enough to tackle all of those but for most of them they can be summed up as "they add more hermeticity/reproducibility to the system", and (my understanding) is that this is mostly due to how nix-channels work. Basically nix-channels is an environment variable NIX_PATH that works sort of like PATH, and is where your nix derivations would look when resolving references. So, for example, I could set my NIX_PATH to a private clone of the nix store and have my personal derivations there and builds I did would not be the same as on your machine where you point your NIX_PATH at the canonical upstream. Flakes require all of these dynamic parts of the build (including the build architecture etc) to be injected as inputs to the system. Similar to how Bazel workspace files work from what I understand. As part of that standardization of the inputs into a `flake.nix` / `flake.lock` file there was also work done to define a standard interface for a flake as a unit. Before flakes, if you imported another "unit" there was no telling what was being exported by the target (is it a derivation? an overlay?). With flakes there are well-known, enforced patterns on what and how you would expose to consumers. > How much they replace home-manager. Not at all really. But home-manager is now provided as a flake and so you no longer need to install it separately, and can instead import their flake to get a fully-working system. > Context: not a Nix user, but [...] To be honest, nix is a system you have to actually use to begin to understand and synthesize. As noted, flakes make this hill less steep, but you won't really internalize the value and the system as a whole until you actually start using it some.
- xelxebar 4y agoAs a Guix user who also dabbles in Nix, I am still confused by how to use flakes as a "package consumer". I have a flake (non-declaritively) added to my nix-profile, along with some packages that came from my nixpkgs/config.nix. However, after adding the flake, I am unable to update my profile's packages: `nix profile update` becomes essentially a no-op, even after updating the channel. * How does declarative management of user nix-profiles work now with flakes?
- JamesSwift 4y agoI use home-manager as my profile management layer so I might not understand your setup fully, but Flakes dont really mesh with channels. They instead use a flake.lock and so you would need to do a `nix flake update` to get the flake-managed packages updated. EDIT: you also might be able to inject your local channels "pkgs" definition into the flake so that they reference the same versions. e.g. for home-manager with flakes you would do it like this inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; home-manager = { inputs.nixpkgs.follows = "nixpkgs"; # <- deduped version of packages url = "github:nix-community/home-manager"; }; };
- grumbel 4y ago> I am still confused by how to use flakes as a "package consumer" A Flake is a git repository or another Flake compatible URL. If you want to run a flake, it's simply: nix run github:juser/hello or: nix shell github:juser/hello If you want to install it as a user: nix profile install github:juser/hello If you do: nix profile update '.*' It will go through the packages in your profile and check for updates to the Git repositories and update the packages. If you have the Flake URL pointing to a specific revision, it will stay with that and never update: nix run github:juser/hello?rev=53cd89289e44b269e28d2340f022e5f63525bcd3 As far as I understand it, the 'nix profile' command is imperative, not declarative. Only the packages installed system wide in /etc/nixos/ are declarative. If you want to use flakes there, create a /etc/nixos/flake.nix and declare your flakes as input. nix-channel is no longer necessary when you go fully with Flakes. For declarative management of your $HOME directory you need home-manager, which is still a separate community project, not part of the core NixOS.