-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Flakes: per-system configuration #3075
Comments
I also want this feature! |
I also ran into this inconvenience. This part of my config became a bit strange due to this restriction: https://github.com/bobvanderlinden/nixos-config/blob/bdfd8d94def9dc36166ef5725589bf3d7ae2d233/flake.nix#L38-L46 It now also isn't possible to share this home-manager configuration with OSX. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/improving-a-flake-nix-config-that-configures-home-manager/23389/2 |
Still relevant. |
Okay, so I'm new to Nix, but I may have a solution. When I ran
So, I tried to export The work around explained by @nixos-discourse will also work, with It still might be an idea to consider support for TL;DR: It appears that |
Meh, I do see it is a solution, but that shouldn't be a documented solution 😅 The suggestion from @wmertens still makes sense to me. Especially new people shouldn't be placing home configuration into packages, as that adds to the already (sometimes) confusing Nix ecosystem. |
The current interface seems fairly consistent with the attributes for NixOS, the idea being that a Perhaps for your use case, an attribute like |
I think homeConfigurations is more like packages than nixosConfigurations. The reason each nixosConfiguration specifies system is that it is meant to run on specific hardware, whereas the point of hm is to make your home profile portable across hosts. |
Unfortunately, the workaround detailed by @scottwillmoore doesn't work in a
Update: |
Sharing configuration across {
description = "Home Manager configuration of shados";
inputs = {
nixpkgs.url = "nixpkgs";
home-manager = {
url = github:nix-community/home-manager;
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, home-manager, ... } @ inputs:
let
mkHomeConfig = machineModule: system: home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs {
inherit system;
};
modules = [
./sharedConfig
machineModule
];
extraSpecialArgs = {
inherit inputs system;
};
};
in {
homeConfigurations."shados@desktop" = mkHomeConfig ./machine/desktop.nix "x86_64-linux";
homeConfigurations."shados@laptop" = mkHomeConfig ./machine/laptop.nix "x86_64-linux";
homeConfigurations."shados@work" = mkHomeConfig ./machine/work.nix "x86_64-darwin";
homeConfigurations."shados@arm-vm" = mkHomeConfig ./machine/arm-vm.nix "aarch64-linux";
};
} Anything truly portable lives in the If your HM config is intended to be 100% portable and identical across machines, you could get something pretty close to what @wmertens originally wanted: homeConfigurations = with nixpkgs.lib; listToAttrs (flip map flake-utils.lib.defaultSystems
(system: nameValuePair "${username}-${system}" home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs { inherit system; };
modules = [
# ...
];
})); And then build with If anything, I would say a better change would be for |
Oh this was a pitfall. I was wondering why it was complaining
because I didn't understand that the (standalone) So I have to I don't understand why the |
Maybe because it (my HM nix setup/repo) always imports all HM modules for all systems (read: any configured Linux user/combo) through a A symlink is needed though to |
@x10an14 I couldn't figure out how to do that. For me, it will always try to find the configuration of the My situation is probably different and that might be relevant, because my configuration is strictly separated. My HM profile is a single-user multi-host configuration that I want to resolve by hostname only, similarly how Nix is doing it for the system flakes in I think my recent issue #4246 is a dub, so I will quote myself:
Lastly, I want to emphasize that I don't like any work-arounds that require more abstraction and complexity. I'm happy to learn Flakes in their purest form, I don't want to involve additional abstractions, I even keep myself from defining any functions to re-use (i.e. For now, I will just have to pass more arguments to Thank you. |
Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting. If you are the original author of the issue
If you are not the original author of the issue
Memorandum on closing issuesDon't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort. |
Still relevant. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/strategy-to-use-same-config-at-work-and-home/34317/4 |
Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting. If you are the original author of the issue
If you are not the original author of the issue
Memorandum on closing issuesDon't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort. |
Still relevant. |
Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting. If you are the original author of the issue
If you are not the original author of the issue
Memorandum on closing issuesDon't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort. |
Still relevant. |
Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting. If you are the original author of the issue
If you are not the original author of the issue
Memorandum on closing issuesDon't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort. |
Still relevant 🥲 |
Still relevant 🥲 |
still unrelevant |
genus!!! it works |
Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting. If you are the original author of the issue
If you are not the original author of the issue
Memorandum on closing issuesDon't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort. |
Still relevant. |
For anyone wanting a system agnostic setup for Home Manager and not wanting to give extra argument to {
description = "unvX: a simple Home Manager configuration";
inputs = {
# nixpkgs, home-manager and flake-utils are by default loaded since they are
# available in the global flake registry.
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
nixpkgs,
home-manager,
flake-utils,
...
}:
flake-utils.lib.eachSystem flake-utils.lib.allSystems (system: {
# Specify your Home Manager profiles. Home Manager will by
# default match first `$USER@$(hostname)`. If not found, it
# will then default to `$USER`.
packages.homeConfigurations = {
"marty@Mcfly-MacBook-Pro.local" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.${system};
# Specify your Home Manager configurations.
modules = [./host/Mcfly-MacBook-Pro/user/marty/home.nix];
# Specify extra arguments to pass through your configurations.
};
};
});
} If you want to use symlinks with Nix flakes, see my repo unvX. |
With flakes, the system has to be embedded in the pkgs selection. Instead, it would be easier to reuse configurations across platforms by having a setup like apps and packages, where the second level is the system.
Then
pkgs
can be optional.So a config would go from
to
I suppose both configurations could be supported by checking if the current system is an attribute in the home-manager script
The text was updated successfully, but these errors were encountered: