Where can I find actual NixOS manuals to learn NixOS, nix and nixpkg?

Hello!

Trying to use this article https://nixos.wiki/wiki/Build_flags
and rebuild my NixOS (the whole system)
With this code

  nixpkgs.localSystem = {
     gcc.arch = "skylake";
     gcc.tune = "skylake";
     system = "x86_64-linux";
  };

I have this error:

   error:
   Failed assertions:
   - Your system configures nixpkgs with the platform parameter:
   nixpkgs.hostPlatform, with values defined in:
     - /etc/nixos/hardware-configuration.nix

   However, it also defines the legacy options:
   nixpkgs.system, with values defined in:
     - /root/.nix-defexpr/channels/nixpkgs/nixos/lib/eval-config.nix
   nixpkgs.localSystem, with values defined in:
     - /etc/nixos/configuration.nix

   For a future proof system configuration, we recommend to remove
   the legacy definitions.

After trying this:

  nixpkgs.hostPlatform = {
     gcc.arch = "skylake";
     gcc.tune = "skylake";
     system = "x86_64-linux";
  };

this:

error: a ‘x86_64-linux’ with features {gccarch-skylake} is required to build ‘/nix/store/2c3lj8fq2x8m6cdrzmm5z5fg2ah6965l-bootstrap-stage0-glibc-bootstrapFiles.drv’, but I am a ‘x86_64-linux’ with features {benchmark, big-parallel, kvm, nixos-test}

Where can I find relevant info to learn NixOS?

And what is the proper way to rebuild all?
with -march=native/specific cpu
and/or with -O3/-Ofast (I understand I will receive errors for particular packages)

Thank you
Sergey

1 Like

https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-system-features

Add gccarch-skylake to it

with this string at /etc/nixos/configuration.nix:

nix.settings.system-features = [ “gccarch-skylake” ];

I have no errors:

[root@nixos:~]# nixos-rebuild switch --upgrade
unpacking channels...
building Nix...
building the system configuration...
these 6 derivations will be built:
  /nix/store/gqahjsgvz1bbxs9y95nkj6xdjd4xpw8s-nix.conf.drv
  /nix/store/x9kbvr8jxb79m58h6r22di7gsry1bn8y-X-Restart-Triggers.drv
  /nix/store/ji7m2l4xz0f6492ijzlxlglqq6r7pz38-unit-nix-daemon.service.drv
  /nix/store/lsbl2hz99r2mjbf1qyb7g2rqph91rb1q-system-units.drv
  /nix/store/42cjwjkzwsz5qjwqw53iqbxiac14l60c-etc.drv
  /nix/store/mxngajwqb89g00wkybrn0pi34z4ch7vh-nixos-system-nixos-23.11pre513838.750fc50bfd13.drv
building '/nix/store/gqahjsgvz1bbxs9y95nkj6xdjd4xpw8s-nix.conf.drv'...
Validating generated nix.conf
building '/nix/store/x9kbvr8jxb79m58h6r22di7gsry1bn8y-X-Restart-Triggers.drv'...
building '/nix/store/ji7m2l4xz0f6492ijzlxlglqq6r7pz38-unit-nix-daemon.service.drv'...
building '/nix/store/lsbl2hz99r2mjbf1qyb7g2rqph91rb1q-system-units.drv'...
building '/nix/store/42cjwjkzwsz5qjwqw53iqbxiac14l60c-etc.drv'...
building '/nix/store/mxngajwqb89g00wkybrn0pi34z4ch7vh-nixos-system-nixos-23.11pre513838.750fc50bfd13.drv'...
activating the configuration...
setting up /etc...
reloading user units for spiage...
setting up tmpfiles

And no rebuilds )))

So is there the way to force whole system rebuild with -march and/or with -O’s?
I’m can’t find, still googling
(the way from https://nixos.wiki/wiki/Build_flags does not work)

this combo can start rebuilding, but I see no -march and -mtune when cc is invoked

  nix.settings.system-features = [ "big-parallel" "kvm" "gccarch-skylake" "gcctune-skylake" ];
  nixpkgs.hostPlatform = {
    gcc.arch = "skylake";
    gcc.tune = "skylake";
    system = "x86_64-linux";
  };

According to this https://nixos.wiki/wiki/Talk:Build_flags
This documentation isn’t up to date anymore. I’m not sure since when, but gcc.arch = “whatever” and gcc.host = “whatever” are both gone. If you try to use them on 22.05 it’s not going to work.

Where can I find actual NixOS manuals to learn NixOS, nix and nixpkg?

Where can I find actual NixOS manuals to learn NixOS, nix and nixpkg?

I had the same question. I just came across this Cheatsheet - NixOS Wiki and this Resources - NixOS Wiki which look really helpful.

The canonical manuals are all linked at https://nixos.org/learn

2 Likes

How could I have missed this!Thank you!

I had used that manuals,
https://nixos.org/manual/nixos/stable/#sec-installation
# nix-channel --add https://channels.nixos.org/nixos-unstable nixos
but one nix maintainer said it was my mistake to use this line because of manual is outdated and I need flakes as it is new paradigm
Later I found that comment inside nixos.wiki
And I’m confused now and do not know how to find starting point and proper manuals

The ones Abathur linked to are the official ones.

Whereas, as the nixos.wiki landing page points out, it’s an unofficial wiki.

one nix maintainer said it was my mistake to use this line because of manual is outdated and I need flakes as it is new paradigm

I think “mistake” and “need” are unnecessarily strong terms.

flakes more/less replace channels, and have many UX benefits to them. (e.g. for helping beginners, it’s probably better the beginner uses flakes rather than channels). Generally, I’d expect new blogposts/etc. to use flakes, whereas I’d expect channels only in older blogposts/etc.

2 Likes

No, there is no need, flakes are an experimental feature, and as such the docs are right to not communicate it as the canonical way.

2 Likes

I think to follow this steps:

  • Nix (as language)
  • Nix (as package manager)
  • flakes
  • nixpkgs
  • NixOS (by learning all above with this System, I’m comfortable with it now, it is fantastic!)

Am I right?

that should work, just tried it, but it seems like u have to wait until the first bootstrapping stages are built, after that cc uses it for me unsure if u can force the first stages to use it too, but when the packages themself are built/the system it should use it, just not to build the first compilers themself?

... _SOURCE' '-D' '_FORTIFY_SOURCE=3' '-fno-strict-overflow' '-Wformat=1' '-Wformat-security' '-Werror=format-security' '-march=znver3' '-mtune=znver3' ...

And learning canonical manuals with wrong info is the canonical way for me? =)

ok, will try it now and tell you

There is nothing “wrong” in the canonical manuals.

“Channels” are not wrong, they are just different. And if you use flakes, you simple have to know enough about both worlds to translate.

2 Likes

Thank you!
Now I understand my mistake

1 Like