-
-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixpkgs.config.allowUnfreePredicate does not work with flakes #118115
Comments
Flakes are evaluated hermetically . In a flake you need to explicitly import The error messages should be updated to document how one should do this with flakes. |
I am using flakes with allowUnfreePredicate right now and I cannot reproduce the issue. Can you provide the flake source code? |
@FRidh NixOS module system already imports nixpkgs automatically and passes |
It might also be that the (assuming you're using { config, pkgs, lib, olderNixpkgs }: let
olderPkgs = import olderNixpkgs config.nixpkgs;
in {
environment.systemPackages = with olderPkgs; [ hello-unfree ];
} This will make two Nixpkgs configs identical. |
Right, I was mixing up nixos-rebuild with the nix commands. |
@kisik21 It can be reproduced with the following files:
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/8e2b14aceb1d40c7e8b84c03a7c78955359872bb";
inputs.nixpkgs-nixos-20-09.url = "github:NixOS/nixpkgs/nixos-20.09";
# inputs.nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = inputs@{self, nixpkgs, nixpkgs-nixos-20-09, ...}: let
system = "x86_64-linux";
in {
nixosConfigurations.nixos-202007 = nixpkgs.lib.nixosSystem {
inherit system;
modules = [ ./configuration.nix ./hardware-configuration.nix
"${nixpkgs-nixos-20-09}/nixos/modules/installer/tools/tools.nix"
];
pkgs = import nixpkgs { inherit system; overlays = [
(self: super:
let
# pkgs-nixos-20-09 = import nixpkgs-release-20-09 { inherit system; };
pkgs-nixos-20-09 = (builtins.getAttr system nixpkgs-nixos-20-09.legacyPackages);
# pkgs-unstable = import nixpkgs-unstable { inherit system; };
in {
# inherit (pkgs-nixos-20-09) openssl openssh;
inherit (pkgs-nixos-20-09) sudo;
inherit (pkgs-nixos-20-09) chromium chromiumBeta chromiumDev ungoogled-chromium;
inherit (pkgs-nixos-20-09) firefoxPackages;
inherit (pkgs-nixos-20-09) nix nixStable nixUnstable nixFlakes;
})
];};
extraArgs = {
inherit nixpkgs-nixos-20-09;
};
};
};
}
{ config, pkgs, system, ... }:
{
disabledModules = [ "installer/tools/tools.nix" ];
boot.loader.efi.canTouchEfiVariables = true;
# I hope to have Grub installed
# boot.loader.grub.device = "/dev/disk/by-uuid/04CB-DC08";
boot.loader.grub.enable = true;
boot.loader.grub.device = "nodev";
boot.loader.grub.version = 2;
boot.loader.grub.efiSupport = true;
boot.loader.grub.useOSProber = true;
nixpkgs.config.allowUnfreePredicate = (pkg: true);
environment.systemPackages = with pkgs; [ hello-unfree ];
}
# Do not modify this file! It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "sd_mod" "sr_mod" "rtsx_pci_sdmmc" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/95673e06-72a1-428f-9c54-377ca2c7cf46";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/04CB-DC08";
fsType = "vfat";
};
fileSystems."/home/shamrock/Documents" =
{ device = "/dev/disk/by-uuid/f702acd1-5cc6-42be-ba39-4058afb453fb";
fsType = "ext4";
};
fileSystems."/home/shamrock/Downloads" =
{ device = "/home/shamrock/Documents/shamrock-shared/bindings/Downloads";
fsType = "none";
options = [ "bind" ];
};
fileSystems."/home/shamrock/Music" =
{ device = "/home/shamrock/Documents/shamrock-shared/bindings/Music";
fsType = "none";
options = [ "bind" ];
};
fileSystems."/home/shamrock/Pictures" =
{ device = "/home/shamrock/Documents/shamrock-shared/bindings/Pictures";
fsType = "none";
options = [ "bind" ];
};
fileSystems."/home/shamrock/Videos" =
{ device = "/home/shamrock/Documents/shamrock-shared/bindings/Videos";
fsType = "none";
options = [ "bind" ];
};
fileSystems."/var/lib/anbox/rootfs" =
{ device = "/nix/store/qhfx6fp5qsvlnkqf76n2awi8b6ajsh0r-android_amd64.img";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/var/lib/anbox/combined-rootfs" =
{ device = "overlay";
fsType = "overlay";
};
fileSystems."/var/lib/anbox/combined-rootfs/cache" =
{ device = "/var/lib/anbox/cache";
fsType = "none";
options = [ "bind" ];
};
fileSystems."/var/lib/anbox/combined-rootfs/data" =
{ device = "/var/lib/anbox/data";
fsType = "none";
options = [ "bind" ];
};
swapDevices =
[ { device = "/dev/disk/by-uuid/115e7d69-e91b-4f8f-87f9-7cb5b722433e"; }
];
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
} Here is the
|
Oh, I see. You're setting { config, pkgs, lib, nixpkgs-nixos-20-09, ... }: let
stable-overlay = (self: super: let
pkgs-nixos-20-09 = import nixpkgs-nixos-20-09 config.nixpkgs;
in {
# inherit (pkgs-nixos-20-09) openssl openssh;
inherit (pkgs-nixos-20-09) sudo;
inherit (pkgs-nixos-20-09) chromium chromiumBeta chromiumDev ungoogled-chromium;
inherit (pkgs-nixos-20-09) firefoxPackages;
inherit (pkgs-nixos-20-09) nix nixStable nixUnstable nixFlakes;
});
in {
nixpkgs.overlays = [ stable-overlay ];
} Please report if this fixes your problem (it should, but I haven't tested if this fully evaluates properly!) |
@kisik21 The build failed, saying that it cannot find "system" or something. It now says that the error is cached, and I don't know how to show it. I'll write a toy configuration (as shown previously) later to reproduce this. |
@ShamrockLee you should be able to work around the cached failure thing by deleting IIRC there's no flag to force a re-evaluation although it seems possible on a low-level in the code. Since I got bitten by this in the past, I guess I'll file a patch for this against Nix :) |
I think that it's not very helpful to get "cached failures" in a wrong `flake.nix`. This can be very confusing when debugging a Nix expression. See for instance NixOS/nixpkgs#118115. In fact, the eval cache allows a forced reevaluation which is used for e.g. `nix eval`. To provide a way around this for `nix build`, I added a flag `--force-reevaluation` (and `-F` as shorthand) to repeatedly get the error: λ ma27 [~/Projects/exp] → ../nix/outputs/out/bin/nix build -L --rebuild --experimental-features 'nix-command flakes' error: cached failure of attribute 'defaultPackage.x86_64-linux' λ ma27 [~/Projects/exp] → ../nix/outputs/out/bin/nix build -L --rebuild --experimental-features 'nix-command flakes' -F error: attribute 'hell' missing at /nix/store/mrnvi9ss8zn5wj6gpn4bcd68vbh42mfh-source/flake.nix:6:35: 5| 6| packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hell; | ^ 7| (use '--show-trace' to show detailed location information)
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/8e2b14aceb1d40c7e8b84c03a7c78955359872bb";
inputs.nixpkgs-nixos-20-09.url = "github:NixOS/nixpkgs/nixos-20.09";
outputs = inputs@{self, nixpkgs, nixpkgs-nixos-20-09, ...}: let
system = "x86_64-linux";
in {
nixosConfigurations.nixos-202007 = nixpkgs.lib.nixosSystem {
inherit system;
modules = [ ./configuration.nix ./hardware-configuration.nix
"${nixpkgs-nixos-20-09}/nixos/modules/installer/tools/tools.nix"
];
extraArgs = {
inherit nixpkgs-nixos-20-09;
};
};
};
}
{ config, pkgs, lib, system, nixpkgs-nixos-20-09, ... }:
let
pkgs-nixos-20-09 = import nixpkgs-nixos-20-09 config.nixpkgs;
stable-overlay = (self: super:
let
in {
inherit (pkgs-nixos-20-09) openssh;
inherit (pkgs-nixos-20-09) sudo;
inherit (pkgs-nixos-20-09) nix nixStable nixUnstable nixFlakes;
inherit (pkgs-nixos-20-09) chromium chromiumBeta chromiumDev ungoogled-chromium;
inherit (pkgs-nixos-20-09) firefoxPackages;
inherit (pkgs-nixos-20-09) links elinks lynx w3m;
inherit (pkgs-nixos-20-09) git gitAndTools;
});
in {
disabledModules = [ "installer/tools/tools.nix" ];
nixpkgs.config.overlays = [
stable-overlay
];
nixpkgs.config.allowUnfreePredicate = let
getPnameFromPackage = pkg:
pkg.pname or (builtins.parseDrvName pkg.name).name;
in (pkg: let
pname = getPnameFromPackage pkg;
in
builtins.trace "unfree package ${pkg.name or pkg.outPath or ""}, got pname=${pname}"
(builtins.any (prefix: pkgs-nixos-20-09.lib.hasPrefix prefix pname) [
"hello"
])
);
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.grub.enable = true;
boot.loader.grub.device = "nodev";
boot.loader.grub.version = 2;
boot.loader.grub.efiSupport = true;
boot.loader.grub.useOSProber = true;
networking.hostName = "nixos-202007";
nix = {
package = pkgs-nixos-20-09.nixFlakes;
extraOptions = ''
experimental-features = nix-command flakes
'';
};
environment.systemPackages = with pkgs-nixos-20-09; [
hello-unfree
];
}
File content
# Do not modify this file! It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "sd_mod" "sr_mod" "rtsx_pci_sdmmc" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/95673e06-72a1-428f-9c54-377ca2c7cf46";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/04CB-DC08";
fsType = "vfat";
};
fileSystems."/home/shamrock/Documents" =
{ device = "/dev/disk/by-uuid/f702acd1-5cc6-42be-ba39-4058afb453fb";
fsType = "ext4";
};
fileSystems."/home/shamrock/Downloads" =
{ device = "/home/shamrock/Documents/shamrock-shared/bindings/Downloads";
fsType = "none";
options = [ "bind" ];
};
fileSystems."/home/shamrock/Music" =
{ device = "/home/shamrock/Documents/shamrock-shared/bindings/Music";
fsType = "none";
options = [ "bind" ];
};
fileSystems."/home/shamrock/Pictures" =
{ device = "/home/shamrock/Documents/shamrock-shared/bindings/Pictures";
fsType = "none";
options = [ "bind" ];
};
fileSystems."/home/shamrock/Videos" =
{ device = "/home/shamrock/Documents/shamrock-shared/bindings/Videos";
fsType = "none";
options = [ "bind" ];
};
fileSystems."/var/lib/anbox/rootfs" =
{ device = "/nix/store/qhfx6fp5qsvlnkqf76n2awi8b6ajsh0r-android_amd64.img";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/var/lib/anbox/combined-rootfs" =
{ device = "overlay";
fsType = "overlay";
};
fileSystems."/var/lib/anbox/combined-rootfs/cache" =
{ device = "/var/lib/anbox/cache";
fsType = "none";
options = [ "bind" ];
};
fileSystems."/var/lib/anbox/combined-rootfs/data" =
{ device = "/var/lib/anbox/data";
fsType = "none";
options = [ "bind" ];
};
swapDevices =
[ { device = "/dev/disk/by-uuid/115e7d69-e91b-4f8f-87f9-7cb5b722433e"; }
];
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
}
File content{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1596615455,
"narHash": "sha256-qOp3QRL7dUbN+Kus7tReThC5ZuIqG9fy7/nkqlO78n8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8e2b14aceb1d40c7e8b84c03a7c78955359872bb",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8e2b14aceb1d40c7e8b84c03a7c78955359872bb",
"type": "github"
}
},
"nixpkgs-nixos-20-09": {
"locked": {
"lastModified": 1617542311,
"narHash": "sha256-YbYqpUA8EChwUaUSj8wIukv9ieFQdUnSSm5RypghNBA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "91b77fe6942fe999b1efbe906dc98024d1917c0d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-20.09",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"nixpkgs-nixos-20-09": "nixpkgs-nixos-20-09"
}
}
},
"root": "root",
"version": 7
} Output: Terminal output[shamrock@nixos-202007:/etc/nixos]$ sudo nixos-rebuild build --show-trace 2>&1 | tee nixos-rebuild_build_202104052159.txt
tee: nixos-rebuild_build_202104052159.txt: Permission denied
warning: Git tree '/etc/nixos' is dirty
building the system configuration...
warning: Git tree '/etc/nixos' is dirty
error: assertion '(((args) ? localSystem) -> (! (((args) ? system) || ((args) ? platform))))' failed
at /nix/store/snsfv9nmawna59cnqdghb2l72rrl2zac-source/pkgs/top-level/impure.nix:82:1:
81| # not be passed.
82| assert args ? localSystem -> !(args ? system || args ? platform);
| ^
83|
… while evaluating anonymous lambda
at /nix/store/snsfv9nmawna59cnqdghb2l72rrl2zac-source/pkgs/top-level/impure.nix:15:1:
14|
15| { # We combine legacy `system` and `platform` into `localSystem`, if
| ^
16| # `localSystem` was not passed. Strictly speaking, this is pure desugar, but
… from call site
at /nix/store/h4n8621dxkd30im5j6r6c9mjxk8zgql8-source/configuration.nix:4:22:
3| let
4| pkgs-nixos-20-09 = import nixpkgs-nixos-20-09 config.nixpkgs;
| ^
5| stable-overlay = (self: super:
… while evaluating the attribute 'value'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:281:44:
280| defnsByName' = byName "config" (module: value:
281| [{ inherit (module) file; inherit value; }]
| ^
282| ) configs;
… while evaluating 'dischargeProperties'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:467:25:
466| */
467| dischargeProperties = def:
| ^
468| if def._type or "" == "merge" then
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:396:137:
395| defs' = concatMap (m:
396| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
| ^
397| ) defs;
… while evaluating definitions from `/nix/store/h4n8621dxkd30im5j6r6c9mjxk8zgql8-source/configuration.nix':
… while evaluating anonymous lambda
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:395:28:
394| # Process mkMerge and mkIf properties.
395| defs' = concatMap (m:
| ^
396| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:395:17:
394| # Process mkMerge and mkIf properties.
395| defs' = concatMap (m:
| ^
396| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
… while evaluating the attribute 'values'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:508:7:
507| in {
508| values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
| ^
509| inherit highestPrio;
… while evaluating the attribute 'values'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:409:9:
408| in {
409| values = defs''';
| ^
410| inherit (defs'') highestPrio;
… while evaluating the attribute 'mergedValue'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:415:5:
414| # Type-check the remaining definitions, and merge them. Or throw if no definitions.
415| mergedValue =
| ^
416| if isDefined then
… while evaluating the option `nix.package':
… while evaluating the attribute 'value'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:383:9:
382| in opt //
383| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
384| inherit (res.defsFinal') highestPrio;
… while evaluating anonymous lambda
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:84:45:
83| yieldConfig = prefix: set:
84| let res = removeAttrs (mapAttrs (n: v:
| ^
85| if isOption v then v.value
… from call site
… while evaluating the attribute 'nix.package.out'
… while evaluating the attribute 'value'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:281:44:
280| defnsByName' = byName "config" (module: value:
281| [{ inherit (module) file; inherit value; }]
| ^
282| ) configs;
… while evaluating 'dischargeProperties'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:467:25:
466| */
467| dischargeProperties = def:
| ^
468| if def._type or "" == "merge" then
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:396:137:
395| defs' = concatMap (m:
396| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
| ^
397| ) defs;
… while evaluating definitions from `/nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/nixos/modules/services/misc/nix-gc.nix':
… while evaluating anonymous lambda
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:395:28:
394| # Process mkMerge and mkIf properties.
395| defs' = concatMap (m:
| ^
396| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:395:17:
394| # Process mkMerge and mkIf properties.
395| defs' = concatMap (m:
| ^
396| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
… while evaluating the attribute 'values'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:508:7:
507| in {
508| values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
| ^
509| inherit highestPrio;
… while evaluating the attribute 'values'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:409:9:
408| in {
409| values = defs''';
| ^
410| inherit (defs'') highestPrio;
… while evaluating the attribute 'mergedValue'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:415:5:
414| # Type-check the remaining definitions, and merge them. Or throw if no definitions.
415| mergedValue =
| ^
416| if isDefined then
… while evaluating the option `systemd.services.nix-gc.script':
… while evaluating the attribute 'value'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:383:9:
382| in opt //
383| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
384| inherit (res.defsFinal') highestPrio;
… while evaluating anonymous lambda
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:84:45:
83| yieldConfig = prefix: set:
84| let res = removeAttrs (mapAttrs (n: v:
| ^
85| if isOption v then v.value
… from call site
… while evaluating the attribute 'script'
… while evaluating the attribute 'condition'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:552:14:
551| { _type = "if";
552| inherit condition content;
| ^
553| };
… while evaluating the attribute 'condition'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:552:14:
551| { _type = "if";
552| inherit condition content;
| ^
553| };
… while evaluating 'dischargeProperties'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:467:25:
466| */
467| dischargeProperties = def:
| ^
468| if def._type or "" == "merge" then
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:396:137:
395| defs' = concatMap (m:
396| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
| ^
397| ) defs;
… while evaluating definitions from `/nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/nixos/modules/system/boot/systemd.nix':
… while evaluating anonymous lambda
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:395:28:
394| # Process mkMerge and mkIf properties.
395| defs' = concatMap (m:
| ^
396| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:395:17:
394| # Process mkMerge and mkIf properties.
395| defs' = concatMap (m:
| ^
396| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
… while evaluating the attribute 'values'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:508:7:
507| in {
508| values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
| ^
509| inherit highestPrio;
… while evaluating the attribute 'values'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:409:9:
408| in {
409| values = defs''';
| ^
410| inherit (defs'') highestPrio;
… while evaluating the attribute 'mergedValue'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:415:5:
414| # Type-check the remaining definitions, and merge them. Or throw if no definitions.
415| mergedValue =
| ^
416| if isDefined then
… while evaluating the option `systemd.services.nix-gc.serviceConfig':
… while evaluating the attribute 'value'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:383:9:
382| in opt //
383| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
384| inherit (res.defsFinal') highestPrio;
… while evaluating anonymous lambda
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:84:45:
83| yieldConfig = prefix: set:
84| let res = removeAttrs (mapAttrs (n: v:
| ^
85| if isOption v then v.value
… from call site
… while evaluating the attribute 'serviceConfig.Type'
… while evaluating 'optional'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/lists.nix:254:20:
253| */
254| optional = cond: elem: if cond then [elem] else [];
| ^
255|
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/nixos/modules/system/boot/systemd.nix:894:10:
893| restart = service.serviceConfig.Restart or "no";
894| in optional
| ^
895| (type == "oneshot" && (restart == "always" || restart == "on-success"))
… while evaluating anonymous lambda
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/nixos/modules/system/boot/systemd.nix:890:51:
889|
890| warnings = concatLists (mapAttrsToList (name: service:
| ^
891| let
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/attrsets.nix:234:16:
233| mapAttrsToList = f: attrs:
234| map (name: f name attrs.${name}) (attrNames attrs);
| ^
235|
… while evaluating anonymous lambda
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/attrsets.nix:234:10:
233| mapAttrsToList = f: attrs:
234| map (name: f name attrs.${name}) (attrNames attrs);
| ^
235|
… from call site
… while evaluating the attribute 'value'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:281:44:
280| defnsByName' = byName "config" (module: value:
281| [{ inherit (module) file; inherit value; }]
| ^
282| ) configs;
… while evaluating 'dischargeProperties'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:467:25:
466| */
467| dischargeProperties = def:
| ^
468| if def._type or "" == "merge" then
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:396:137:
395| defs' = concatMap (m:
396| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
| ^
397| ) defs;
… while evaluating definitions from `/nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/nixos/modules/system/boot/systemd.nix':
… while evaluating anonymous lambda
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:395:28:
394| # Process mkMerge and mkIf properties.
395| defs' = concatMap (m:
| ^
396| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:395:17:
394| # Process mkMerge and mkIf properties.
395| defs' = concatMap (m:
| ^
396| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
… while evaluating the attribute 'values'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:508:7:
507| in {
508| values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
| ^
509| inherit highestPrio;
… while evaluating the attribute 'values'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:409:9:
408| in {
409| values = defs''';
| ^
410| inherit (defs'') highestPrio;
… while evaluating the attribute 'mergedValue'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:415:5:
414| # Type-check the remaining definitions, and merge them. Or throw if no definitions.
415| mergedValue =
| ^
416| if isDefined then
… while evaluating the option `warnings':
… while evaluating the attribute 'value'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:383:9:
382| in opt //
383| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
384| inherit (res.defsFinal') highestPrio;
… while evaluating anonymous lambda
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/modules.nix:84:45:
83| yieldConfig = prefix: set:
84| let res = removeAttrs (mapAttrs (n: v:
| ^
85| if isOption v then v.value
… from call site
… while evaluating the attribute 'warnings'
… while evaluating 'fold''
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/lists.nix:55:15:
54| len = length list;
55| fold' = n:
| ^
56| if n == len
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/lists.nix:59:8:
58| else op (elemAt list n) (fold' (n + 1));
59| in fold' 0;
| ^
60|
… while evaluating 'foldr'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/lists.nix:52:20:
51| */
52| foldr = op: nul: list:
| ^
53| let
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/trivial.nix:302:33:
301|
302| showWarnings = warnings: res: lib.fold (w: x: warn w x) res warnings;
| ^
303|
… while evaluating 'showWarnings'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/trivial.nix:302:28:
301|
302| showWarnings = warnings: res: lib.fold (w: x: warn w x) res warnings;
| ^
303|
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/nixos/modules/system/activation/top-level.nix:125:10:
124| then throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}"
125| else showWarnings config.warnings baseSystem;
| ^
126|
… while evaluating 'fold''
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/lists.nix:55:15:
54| len = length list;
55| fold' = n:
| ^
56| if n == len
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/lists.nix:59:8:
58| else op (elemAt list n) (fold' (n + 1));
59| in fold' 0;
| ^
60|
… while evaluating 'foldr'
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/lib/lists.nix:52:20:
51| */
52| foldr = op: nul: list:
| ^
53| let
… from call site
at /nix/store/17457fc7h1d2z9ivm458xvka6nq6lv0n-source/nixos/modules/system/activation/top-level.nix:128:12:
127| # Replace runtime dependencies
128| system = fold ({ oldDependency, newDependency }: drv:
| ^
129| pkgs.replaceDependency { inherit oldDependency newDependency drv; }
|
Also, if the lines about { config, pkgs , system, lib, ... }: let
pkgs-nixos-20-09 = import nixpkgs-20-09 { inherit system; };
# ...
in {
# ...
}
|
I think that it's not very helpful to get "cached failures" in a wrong `flake.nix`. This can be very confusing when debugging a Nix expression. See for instance NixOS/nixpkgs#118115. In fact, the eval cache allows a forced reevaluation which is used for e.g. `nix eval`. This change makes sure that this is the case for `nix build` as well. So rather than λ ma27 [~/Projects/exp] → ../nix/outputs/out/bin/nix build -L --rebuild --experimental-features 'nix-command flakes' error: cached failure of attribute 'defaultPackage.x86_64-linux' the evaluation of already-evaluated (and failed) attributes looks like this now: λ ma27 [~/Projects/exp] → ../nix/outputs/out/bin/nix build -L --rebuild --experimental-features 'nix-command flakes' error: attribute 'hell' missing at /nix/store/mrnvi9ss8zn5wj6gpn4bcd68vbh42mfh-source/flake.nix:6:35: 5| 6| packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hell; | ^ 7| (use '--show-trace' to show detailed location information)
I marked this as stale due to inactivity. → More info |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/nixos-config-in-flakes-crash-on-impure-nix/16178/1 |
Your module takes a
You want import nixpkgs-nixos-20-09 { inherit (config.nixpkgs) localSystem crossSystem config overlays; } I think we might want to add a warning in https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/misc/nixpkgs.nix if both |
Not
sgtm |
I'm second-guessing this now. What if something outside the user's control sets |
It has been 3 years since I opened this issue. I suspect that the problem is caused by direct specification of the Now I think The "cached failure" of flake when doing flake-based
Should we close it now, or should we document such shadowing behavior? (Not sure where |
There's an assertion added in ce87196 which should prevent this: nixpkgs/nixos/modules/misc/nixpkgs.nix Lines 385 to 392 in e6057cf
If a user really wants to externally configure nixpkgs, they can add the module |
It bites again to be precise ;-) |
Unfortunately it was never documented. We should run nixdoc on the flake |
Describe the bug
When using flake.nix along side configuration.nix to do
nixos-rebuid
,nixpkgs.config.allowUnfreePredicate
can no longer be used to allow unfree package to build.To Reproduce
Steps to reproduce the behavior:
nixpkgs.config.allowUnfreePredicate = (pkg: true)
environment.systemPackages = [ hello-unfree ];
or use unfree options such as the nvidia driver.Expected behavior
allowUnfreePredicate
or equivalent options be available inconfiguration.nix
orflake.nix
Screenshots
Additional context
Notify maintainers
Metadata
"x86_64-linux"
Linux 5.4.55, NixOS, 20.09.20200805.8e2b14a (Nightingale)
yes
yes
nix-env (Nix) 2.4pre20210308_1c0e3e4
"home-manager"
/nix/var/nix/profiles/per-user/root/channels/nixos
Maintainer information:
The text was updated successfully, but these errors were encountered: