Hi everyone,
I am trying to switch my home-manager configuration to flakes following the example configuration from @mjlbach: nix-dotfiles/flake.nix at 329d3c847e8895f21698db0253d7a0cadb6ce0e9 · mjlbach/nix-dotfiles · GitHub
{
description = "NixOS configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/master";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nur.url = "github:nix-community/NUR";
};
outputs = inputs@{ self, ... }:
let
overlays = [
(import /home/bogdb/.config/nixpkgs/overlays/default.nix)
inputs.neovim-nightly.overlay
];
in
inputs.flake-utils.lib.eachDefaultSystem (system:
{
legacyPackages = inputs.nixpkgs.legacyPackages.${system};
}
) //
{
homeConfigurations = {
bogdb = inputs.home-manager.lib.homeManagerConfiguration {
stateVersion = "21.05";
system = "x86_64-linux";
homeDirectory = "/home/bogdb";
username = "bogdb";
configuration = { pkgs, ... }:
{
nixpkgs.config = import "/home/bogdb/.config/nixpkgs/config.nix";
nixpkgs.overlays = overlays;
programs.home-manager.enable = true;
home.packages = with pkgs; [
# utilities
alacritty
bat
chessx
datamash
exa
fd
flac
flacon
gh
gitui
...
];
home.sessionVariables = {
EDITOR = "nvim";
TCLLIBPATH = "~/.local/share/tk-themes";
};
programs.bash = {
enable = true;
shellAliases = {
nv = "nvim-qt -- -u ~/.config/nvim/init.vim";
kd = "kitty --detach";
};
};
programs.vscode = {
enable = true;
package = pkgs.vscode;
extensions = with pkgs.vscode-extensions; [
xaver.clang-format
ms-vscode.cpptools
];
};
programs.neovim = {
enable = true;
withPython3 = true;
withNodeJs = true;
plugins = with pkgs.vimPlugins; [
{ plugin = awesome-vim-colorschemes; }
{ plugin = nvim-lspconfig; }
{ plugin = nvim-treesitter; }
{ plugin = completion-nvim; }
{ plugin = lualine-nvim; }
{ plugin = fzf-vim; }
{ plugin = lazygit-nvim; }
{ plugin = nerdtree; }
{ plugin = nvim-base16; }
{ plugin = vim-nix; }
{ plugin = vim-pandoc-syntax; }
{ plugin = vim-pandoc; }
{ plugin = vimtex; }
];
extraConfig = ''
if !exists("homemanagerbug")
let homemanagerbug = "yes"
luafile /home/bogdb/.config/nvim/init.lua
endif
'';
}; # neovim
}; # configuration
};
}; # homeConfigurations
bogdb = self.homeConfigurations.bogdb.activationPackage;
defaultPackage.x86_64-linux = self.bogdb;
}; #outputs
}
However I ran into some problems. If I try to rebuild my home using nixos-rebuild I get:
$ nixos-rebuild --flake .config/nixpkgs/ switch
building the system configuration...
error: flake 'path:/home/bogdb/.config/nixpkgs?narHash=sha256-Kh%2fjUo8skLwdFfFl46YzZ5mCWZnt3RQsvSDNOZHqsio=' does not provide attribute 'packages.x86_64-linux.nixosConfigurations."jaghut".config.system.build.toplevel', 'legacyPackages.x86_64-linux.nixosConfigurations."jaghut".config.system.build.toplevel' or 'nixosConfigurations."jaghut".config.system.build.toplevel'
If I try calling home-manager switch:
$ home-manager switch
error: access to path '/home/bogdb/.config/nixpkgs/config.nix' is forbidden in restricted mode
(use '--show-trace' to show detailed location information)
The only thing that works is $ nix build .config/nixpkgs/.# --impure
followed by manual activation of the result.
I’d be very grateful if anyone could point out my mistakes and help me understand this. Thanks.