I would like a symlink between /etc/nixos/Hyprland/ and ~/.config/hypr/ and all the files inside (recursive) are linked. Is there a way to do that?
Do you use home-manager? If you do, do you use it as a NixOS module or stand-alone?
Yeah, I use home-manager. I haven’t touched Nix in a while though, so I’m not sure but I think it’s a NixOS module (I have imports = [home-manager.nixosModules.home-manager]; in flake.nix)
If possible, can I take a look at your config?
# flake.nix
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager";
plasma-manager.url = "github:nix-community/plasma-manager";
nixvim.url = "github:nix-community/nixvim";
windscribe.url = "github:parkerrdev/nixpkgs-windscribe";
};
outputs =
{ self, nixpkgs, home-manager, ... }@inputs:
let
hostname = "nixos";
username = "me";
in
{
nixosConfigurations."${hostname}" = nixpkgs.lib.nixosSystem {
system = "x86-64-linux";
specialArgs = inputs;
modules = [
# Import some config files
./modules/installed-pkgs.nix
./modules/configuration.nix
./modules/hardware-configuration.nix
# Import some modules
inputs.nixvim.nixosModules.nixvim
# Extra configuration
{
# -- GENERAL SETTINGS --
system.stateVersion = "25.05"; # DO NOT CHANGE
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# Define your hostname
networking.hostName = hostname;
# Define a user account. Don't forget to set a password with 'passwd'.
users.users."${username}" = {
isNormalUser = true;
extraGroups = [ "networkmanager" "wheel" ];
};
# -- IMPORTS & OVERLAYS --
imports = [
home-manager.nixosModules.home-manager
];
# -- HOME MANAGER --
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
sharedModules = [
inputs.plasma-manager.homeModules.plasma-manager
];
# Basic home manager configuration
users."${username}" = {
imports = [
./modules/home-manager/home.nix
];
home.username = username;
home.homeDirectory = "/home/${username}";
};
};
}
];
};
};
}
Is there a link where I can take a look at your whole repo? No worries if it’s private, can you share a your home.nix? I can’t tell how exactly you’re configuring /etc/nixos/hyprland unless I see the whole config sort of. I am kinda new into Nix as well.
Here’s the repo: https://github.com/writeblankspace/nixos
I literally haven’t configged Hyprland at all though, so I just have a single line in configuration.nix: programs.hyprland.enable = true;
Actually it’s still not there. But no prob. You can look at home-manager’s xdg.configFile option. See NixOS Search for options like recursive. By default home-manager links files from the nix store (/nix/store) which is immutable. Every change you make in /etc/nixos/hyprland will require a rebuild. If you want to just link it use the mkOutOfStoreSymlink function (or so it’s called) See the wiki it’s there. Welcome to the nixos discourse.
Thank you! xdg.configFile worked perfectly!
Hello; I decided to use mkOutOfStoreSymlink instead.
Every change you make in /etc/nixos/hyprland will require a rebuild
Is there a way to make sure the changes are updated automatically? I assumed mkOutOfStoreSymlink would do that, but it seems not (they just get symlinked to the store, which has a copy of the files, but only get updated on rebuild)
mkOutOfStoreSymlink links to the specified location.
If you use flakes, you have to specify the location as a string representing the absolute path of the target. If you do not use flakes, an absolute path literal shoult do. HM does a lot of bullshit magic here…
Either way, the links go through the store and through 5ish layers of relinking.
Ohhh okay thanks
Is there anything nicer than literally using /etc/nixos/hypr? Is there some variable for /etc/nixos (e.g. "${configPathIdk}/hypr") or is this the best solution?
If you are using flakes, there can not be a direct reference to where the flake is stored outside of the pure evaluation context, as that wouldn’t be pure anymore.
What I have seen done by people is, that they declare an option that holds the flakes “clone location” or use an adhoc value in lib and then use either of those to build the link target locations.
Yeah, I’m using flakes and having a pure config would be nice.
Can you clarify what you mean by “clone location” or lib though? I’m trying to look for docs/reference on what I can use in lib and found pretty much nothing.
“clone location” would be where you have cloned your local copy of your flake to.
And lib, in this case, is a HM option:
Do you mean I should make a module and declare an option (e.g. clonePath or whatever), give it a value, then use it like a variable? Or am I understanding this wrong?
I’m sorry for being really confused.
I am not saying that you should, I just said, others did it that way, to have a single place where they can set the base path for such links.