Hello,
I recently moved to the flake based home manager. I didn’t have this issue on the old non-flake home manager.
I am aware that this issue has already been mentioned several times in the past here and in other places. However, I couldn’t find any solution or mention of this issue for non-NixOS distros.
System Specs
System:
Kernel: 6.12.31-1-lts arch: x86_64 bits: 64 compiler: gcc v: 15.1.1
clocksource: tsc avail: hpet,acpi_pm
parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-lts
root=UUID=50a0e52f-4c78-4ef8-9f28-035e9a972853 rw rootflags=subvol=@
nowatchdog nvme_load=YES rd.luks.uuid=256a30de-ba5f-4b0f-8f79-0db4cc84e305
loglevel=3 nvidia-drm.modeset=1 nvidia-drm.fbdev=1
Desktop: KDE Plasma v: 6.3.5 tk: Qt v: N/A info: frameworks v: 6.14.0
wm: kwin_x11 vt: 2 dm: SDDM Distro: EndeavourOS base: Arch Linux
Machine:
Type: Laptop System: Apple product: MacBookPro10,1 v: 1.0
serial: <superuser required> Chassis: type: 10 v: Mac-C3EC7CD22292981F
serial: <superuser required>
Mobo: Apple model: Mac-C3EC7CD22292981F v: MacBookPro10,1
serial: <superuser required> uuid: <superuser required> UEFI: Apple
v: 429.0.0.0.0 date: 03/18/2022
CPU:
Info: model: Intel Core i7-3615QM bits: 64 type: MT MCP arch: Ivy Bridge
gen: core 3 level: v2 built: 2012-15 process: Intel 22nm family: 6
model-id: 0x3A (58) stepping: 9 microcode: 0x21
Topology: cpus: 1x dies: 1 clusters: 4 cores: 4 threads: 8 tpc: 2
smt: enabled cache: L1: 256 KiB desc: d-4x32 KiB; i-4x32 KiB L2: 1024 KiB
desc: 4x256 KiB L3: 6 MiB desc: 1x6 MiB
Speed (MHz): avg: 1209 min/max: 1200/3300 scaling: driver: intel_cpufreq
governor: schedutil cores: 1: 1209 2: 1209 3: 1209 4: 1209 5: 1209 6: 1209
7: 1209 8: 1209 bogomips: 36729
Flags: avx ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
Vulnerabilities:
Type: gather_data_sampling status: Not affected
Type: indirect_target_selection status: Not affected
Type: itlb_multihit status: KVM: Split huge pages
Type: l1tf mitigation: PTE Inversion; VMX: conditional cache flushes, SMT
vulnerable
Type: mds mitigation: Clear CPU buffers; SMT vulnerable
Type: meltdown mitigation: PTI
Type: mmio_stale_data status: Unknown: No mitigations
Type: reg_file_data_sampling status: Not affected
Type: retbleed status: Not affected
Type: spec_rstack_overflow status: Not affected
Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via
prctl
Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer
sanitization
Type: spectre_v2 mitigation: Retpolines; IBPB: conditional; IBRS_FW;
STIBP: conditional; RSB filling; PBRSB-eIBRS: Not affected; BHI: Not
affected
Type: srbds status: Vulnerable: No microcode
Type: tsx_async_abort status: Not affected
Packages: 1263 pm: nix-default pkgs: 64 pm: nix-sys pkgs: 0 pm: nix-usr
pkgs: 100 libs: 16 pm: pacman pkgs: 1085 libs: 282 tools: yay pm: flatpak
pkgs: 14 Compilers: gcc: 15.1.1 Shell: Bash v: 5.2.37 running-in: konsole
inxi: 3.3.38
My `flake.nix` file
{
description = "Home Manager configuration of chirag";
inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
nixGL = {
url = "github:nix-community/nixGL";
inputs.nixpkgs.follows = "nixpkgs";
};
tldr = {
type = "github";
owner = "tldr-pages";
repo = "tldr";
flake = false;
};
};
outputs =
{ nixpkgs, home-manager, ... }@inputs:
let
system = "x86_64-linux";
# pkgs = nixpkgs.legacyPackages.${system};
pkgs = import inputs.nixpkgs { inherit system; config.allowUnfree = true; };
in
{
homeConfigurations."chirag" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [ ./home.nix ];
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
extraSpecialArgs = {
nixgl = inputs.nixGL;
tldr = inputs.tldr;
};
};
};
}
Brief version of my `home.nix` file
{ config, lib, pkgs, nixgl, tldr, ... }:
{
home.username = "myuser";
home.homeDirectory = "/home/myuser";
targets.genericLinux.enable = true;
# Get NixGL
nixGL.packages = nixgl.packages;
nixGL.defaultWrapper = "nvidia";
nixGL.offloadWrapper = "nvidiaPrime";
home.stateVersion = "25.05";
home.packages = with pkgs; [
...
];
home.file = {
...
};
programs.ghostty = import ./ghostty.nix { inherit config pkgs lib; };
}
My `ghostty.nix` file
{config, lib, pkgs, ...}:
{
enable = true;
package = config.lib.nixGL.wrap pkgs.ghostty;
enableBashIntegration = true;
settings = {
...
};
}
The command I’m using to build the configuration is:
home-manager switch --impure
Solutions that work
Adding the following to ~/.config/nixpkgs/config.nix
works without any issues.
{
allowUnfree = true;
}
Alternatively, running the following command (without having to set allowUnfree in config.nix
) also seems to work:
NIXPKGS_ALLOW_UNFREE=1 home-manager switch --impure
Related issue on Discourse:
I came across a related issue here in discourse. I created a flake.nix
that produces a simple nix shell environment
just as shown in the discourse post, and in the output
section of flake.nix, I set pkgs = import nixpkgs {inherit system; config.allowUnfree = true;};
and I was able to run nix develop
and install mongodb without any issues. But for some reason, I’m not able to do the same with home-manager
. This solutions seems to be working for a lot of others but not in my case.
Questions:
- What could be the reason that even after setting
pkgs = import inputs.nixpkgs { inherit system; config.allowUnfree = true; };
in myflake.nix
, Nix is refusing to evaluate? - Am I missing something? How should I write my flake so as not to always depend on
~/.config/nixpkgs/config.nix
? - Is there a bug in
home-manager
?
Thank you very much for your help.