NixOS system configuration: Difference between revisions
Remove the word “modern” for an experimental API as it suggests stable code is not modern |
m Right, that also needs buildPackages |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 180: | Line 180: | ||
==== Importing packages from multiple nixpkgs branches ==== | ==== Importing packages from multiple nixpkgs branches ==== | ||
A NixOS config flake could be as follows (replace | A NixOS config flake could be as follows (replace hostname with your hostname): | ||
{{file|3=<nowiki> | {{file|3=<nowiki> | ||
| Line 194: | Line 194: | ||
{ nixpkgs, nixpkgs-unstable, ... }: | { nixpkgs, nixpkgs-unstable, ... }: | ||
{ | { | ||
nixosConfigurations." | nixosConfigurations."hostname" = nixpkgs.lib.nixosSystem { | ||
modules = [ | modules = [ | ||
{ | { | ||
| Line 257: | Line 257: | ||
path = pkgs.path; | path = pkgs.path; | ||
narHash = builtins.readFile | narHash = builtins.readFile | ||
(pkgs.runCommandLocal "get-nixpkgs-hash" | (pkgs.buildPackages.runCommandLocal "get-nixpkgs-hash" | ||
{ nativeBuildInputs = [ pkgs.nix ]; } | { nativeBuildInputs = [ pkgs.buildPackages.nix ]; } | ||
"nix-hash --type sha256 --sri ${pkgs.path} > $out"); | "nix-hash --type sha256 --sri ${pkgs.path} > $out"); | ||
}; | }; | ||
}; | }; | ||
</nowiki> | </nowiki> | ||
}} | |name=|lang=}} | ||
This has the unfortunate side-effect of requiring import-from-derivation and slowing down build times, however it may greatly speed up almost every eval. Full-time flakes users may be able to just use <code>narHash = pkgs.narHash</code>. | This has the unfortunate side-effect of requiring import-from-derivation and slowing down build times, however it may greatly speed up almost every eval. Full-time flakes users may be able to just use <code>narHash = pkgs.narHash</code>. | ||