-
Notifications
You must be signed in to change notification settings - Fork 6
Use upstream-compatible Nix store path #46
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
Open
thrix-bot
wants to merge
3
commits into
thrix:main
Choose a base branch
from
thrix-bot:use-upstream-nix-store-path
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| # Host Config Module | ||
|
|
||
| When running Home Manager inside a nix-toolbox container on Fedora Atomic Desktops, config files managed by Home Manager are symlinks pointing to `/nix/store/...` paths. | ||
| The Nix store data lives on the host at `$XDG_DATA_HOME/nix/root/nix/` (or `$XDG_DATA_HOME/nix` for legacy installs), but the `/nix` bind mount only exists inside the container. | ||
| Host-side programs like sway, waybar, foot, or firefox cannot resolve these symlinks — the config files are effectively invisible to the host. | ||
|
|
||
| The `hostConfig` Home Manager module solves this by materializing symlinks as real files after each `home-manager switch`. | ||
|
|
||
| ## How it works | ||
|
|
||
| The module generates two Home Manager activation scripts: | ||
|
|
||
| 1. **`restoreNixLinks`** (runs before `checkLinkTargets`) — restores symlink backups (`.lnk` files) so Home Manager can replace them, and cleans up leftover `.new` temp files from any previous partial run. | ||
| 2. **`createHostConfig`** (runs after `linkGeneration`) — copies each symlink to a real file using an atomic copy-before-move pattern, so a failed copy never leaves you without a config file. | ||
|
|
||
| ## Installation | ||
|
|
||
| The module is available as a flake output from [thrix/nix-config](https://github.com/thrix/nix-config). | ||
|
|
||
| Add it to your `flake.nix`: | ||
|
|
||
| ```nix | ||
| { | ||
| inputs = { | ||
| nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | ||
|
|
||
| home-manager = { | ||
| url = "github:nix-community/home-manager"; | ||
| inputs.nixpkgs.follows = "nixpkgs"; | ||
| }; | ||
|
|
||
| nix-config = { | ||
| url = "github:thrix/nix-config"; | ||
| inputs.nixpkgs.follows = "nixpkgs"; | ||
| inputs.home-manager.follows = "home-manager"; | ||
| }; | ||
| }; | ||
|
|
||
| outputs = { nixpkgs, home-manager, nix-config, ... }: { | ||
| homeConfigurations."alice" = home-manager.lib.homeManagerConfiguration { | ||
| pkgs = nixpkgs.legacyPackages.x86_64-linux; | ||
| modules = [ | ||
| nix-config.homeManagerModules.hostConfig | ||
| ./home.nix | ||
| ]; | ||
| }; | ||
| }; | ||
| } | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| In your `home.nix`: | ||
|
|
||
| ```nix | ||
| hostConfig = { | ||
| enable = true; | ||
|
|
||
| # Automatically materialize all xdg.desktopEntries as real files | ||
| xdgDesktopEntries = true; | ||
|
|
||
| # Any other Home Manager-managed files the host needs to read | ||
| files = [ | ||
| ".config/sway/config" | ||
| ".config/waybar/config" | ||
| ".config/waybar/style.css" | ||
| ".config/foot/foot.ini" | ||
| ]; | ||
| }; | ||
| ``` | ||
|
|
||
| ## Options | ||
|
|
||
| ### `hostConfig.enable` | ||
|
|
||
| Whether to enable host config file materialization. | ||
|
|
||
| **Type:** `boolean` | ||
| **Default:** `false` | ||
|
|
||
| ### `hostConfig.files` | ||
|
|
||
| Home-relative paths to materialize as real files for host access. | ||
| Home Manager normally creates symlinks into the Nix store, which the host cannot follow from outside the toolbox container. | ||
| Files listed here are copied to real files after each switch. | ||
|
|
||
| **Type:** `list of string` | ||
| **Default:** `[]` | ||
|
|
||
| ### `hostConfig.xdgDesktopEntries` | ||
|
|
||
| When `true`, automatically materialize all desktop entries declared via `xdg.desktopEntries`. | ||
| Paths are derived directly from that option — adding a new entry in `xdg.desktopEntries` is sufficient, no need to list it in `files` too. | ||
|
|
||
| This is useful for sharing Nix-installed desktop applications (such as 1Password, Discord, or Dropbox) with the host's application launcher. | ||
|
|
||
| **Type:** `boolean` | ||
| **Default:** `false` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.