I have this flake.nix
file
{
description = "My GNOME Nix config";
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs/release-23.05";
};
home-manager = {
url = "github:nix-community/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, home-manager, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
permittedInsecurePackages = [
"electron-12.2.3"
];
};
};
config = nixpkgs.config;
username = "sayantan";
hostname = "srcnix";
stateVersion = "23.05";
in
{
nixosConfigurations.${hostname} = nixpkgs.lib.nixosSystem {
inherit system;
modules =
[
{
imports = [
./my_general_configs.nix
];
}
];
};
};
}
Everything is already defined here - pkgs
with non-free option, home-manager
etc.
My my_general_configs.nix
file is as below:
{ config, pkgs, home-manager, ... }:
{
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
users.sayantan = { pkgs, ... }: {
home = {
stateVersion = "23.05";
packages = with pkgs; [
google-chrome
];
};
};
};
}
This is a shortened version, but there are many other lines of code.
When I try to compile this with - nixos-rebuild build --impure --flake .#srcnix
I get this error:
error: The option `home-manager' does not exist. Definition values:
- In `/nix/store/2xy5f03gjdkhvw88j0adr4q8ya3ka0k6-source/my_general_configs.nix':
{
useGlobalPkgs = true;
useUserPackages = true;
users = {
sayantan = <function, args: {pkgs}>;
...
Sure I can fix it by changing my_general_configs.nix
file as below
{ config, pkgs, ... }:
let
home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz";
in {
imports = [ <home-manager/nixos> ];
nixpkgs.config.allowUnfree = true;
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
users.sayantan = { pkgs, ... }: {
home = {
stateVersion = "23.05";
packages = with pkgs; [
google-chrome
];
};
};
};
}
But then what is the point of defining home-manager and all other variables in the flake.nix
file? I am even having to declare the unfree option again which was already declared in the flake.nix
file. Not to mention I always have to use --impure
option because of the import statement.
I really need some assistance regarding how to pass home-manager
and other variables from the flake.nix
file to other modules. Thanks in advance.