cross-posted from: https://group.lt/post/30446

1652 contributors, who authored 30371 commits since the previous release.

NixOS is already known as the most up to date distribution while also being the distribution with the most packages.

This release saw 16678 new packages and 14680 updated packages in nixpkgs. We also removed 2812 packages in an effort to keep the package set maintainable and secure. In addition to packages the NixOS distribution also features modules and tests that make it what it is. This release brought 91 new modules and removed 20. In that process we added 1322 options and removed 487.

The main feature that was awaited for a long time is the introduction of experimental features, namely the flakes experimental feature.

Flakes is suppose to replace nix-channel, Is still experimental but nix-channel is IMO way too buggy, I wasted days due to this bug , including the time of several community members (If anybody wants to try nix, especially on third party linux distro i suggest he will have a look at, it seems to me something that should be very common and a lot of users should encounter it and it basically brakes the installation).

I hope that if flakes will replace nix-channel it will have the same ease of learning, so nix could be a good flatpak alternative to most users.

Yuu Yin
creator
link
fedilink
42M

Flakes are easier and better than channels. Use it instead.

I looked at, it seems way more complex, it is still experimental and last i checked it does not have official documentation, nix-channel works now and is a lot simpler so i will stick to that for now. hopefully when it will be mature they will have an option to make it dead simple for busy people who just want a leaner flatpak, something like specifying a single line in the file:

main-channel: https://nixos.org/channels/nixos-22.05

Yuu Yin
creator
link
fedilink
3
edit-2
2M

https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html

or man nix3-flake.

For a NixOS flake example: https://git.sr.ht/~misterio/nix-config/tree/main/item/flake.nix

For specific language examples https://github.com/NixOS/templates (which you can nix flake new my-project-name --template "templates#template-name". For real examples https://sourcegraph.com/search?q=context:global+.*+file:flake.nix+lang:Nix&patternType=regexp&sm=1

here a pytorch example when I was learning Flakes

# https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html
# https://discourse.nixos.org/t/pytorch-cuda-on-wsl/18267
# https://discourse.nixos.org/t/pytorch-and-cuda-torch-not-compiled-with-cuda-enabled/11272
# https://gitlab.com/abstract-binary/nix-nar-rs/-/blob/main/flake.nix
# https://github.com/hasktorch/libtorch-nix
# https://github.com/google-research/dex-lang/blob/main/flake.nix
# https://yuanwang.ca/posts/getting-started-with-flakes.html

{
  description = "PyTorch";

  # Specifies other flakes that this flake depends on.
  inputs = {
    devshell.url = "github:numtide/devshell";
    utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
  };

  # Function that produces an attribute set.
  # Its function arguments are the flakes specified in inputs.
  # The self argument denotes this flake.
  outputs = inputs@{ self, nixpkgs, utils, ... }:
    (utils.lib.eachSystem [ "x86_64-linux" ] (system:
      let
        pkgs = (import nixpkgs {
          inherit system;
          config = {
            # For CUDA.
            allowUnfree = true;
            # Enables CUDA support in packages that support it.
            cudaSupport = true;
          };
        });
      in rec {
        # Executed by `nix build .#<name>`
        packages = utils.lib.flattenTree {
          hello = pkgs.hello;
        };

        # Executed by `nix build .`
        defaultPackage = packages.hello;
        # defaultPackage = pkgs.callPackage ./default.nix { };

        # Executed by `nix develop`
        devShell = with pkgs; mkShell {
          buildInputs = ([
            python39 # numba-0.54.1 not supported for interpreter python3.10
          ] ++ (with python39.pkgs; [
            inflect
            librosa
            pip
            pytorch-bin
            unidecode
          ]) ++ (with cudaPackages; [
            cudatoolkit
          ]));

          shellHook = ''
            export CUDA_PATH=${pkgs.cudatoolkit}
          '';
        };
      }
    ));
}

nix-channel works now and is a lot simpler

It is not. Once you understand flakes, you will see how much better it is. If you do not understand why flakes exist to begin with, read https://www.tweag.io/blog/2020-05-25-flakes/

also use in conjunction with flakes:

  • direnv, nix-direnv
  • devshell

I read the article, flakes sound like an interesting solution that could make it a lot easier to contribute to open source projects (which reportedly often causes an increase in contributions).

With that said, nix-channel still seems like a simpler (by simpler i mean easier to learn and use) at least for simple use case of replacing flatpak , I still don’t know how to replace nix-channel with it, I am not really trying hard but the bottom line it is hard to compete with the ease of use/learning of just doing:

nix-channel --add some_channel nix-channel --update

Yuu Yin
creator
link
fedilink
1
edit-2
2M
nix flake update

And to add a new flake to flake.nix

inputs.my-flake.url = "github:owner/repo";

✨✨✨✨✨✨✨✨✨✨✨✨

Maybe there is a way to add flakes through the command line which I do not know of.

Where do i put the flake file? (another disadvantage, an implicit dependency).

Also does it get added to “~/.nix-profile/bin/” ? Does it use a binary cache (do every package in nixpkgs has to be rebuilt from source?)

Yuu Yin
creator
link
fedilink
1
edit-2
2M

For nixos /etc/nixos/flake.nix. Example https://git.sr.ht/~misterio/nix-config/tree/main/item/flake.nix

For home-manager see https://nix-community.github.io/home-manager/index.html#ch-nix-flakes

For individual projects like that Pytorch one you can put on any git repo.

If you use same nixpkgs revision as the one you currently have using channels nix should not rebuild derivations.

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

  • 0 users online
  • 10 users / day
  • 23 users / week
  • 59 users / month
  • 141 users / 6 months
  • 1 subscriber
  • 328 Posts
  • 298 Comments
  • Modlog