nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.16k stars 1.85k forks source link

bug: git-sync dies when whitespace in repo path #6023

Open RedEtherbloom opened 4 weeks ago

RedEtherbloom commented 4 weeks ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

This happens due to an improper unit environment. Example error message:

systemctl status --user git-sync-xyz.service                                                  
 ○ git-sync-xyz.service - Git Sync xyz
      Loaded: loaded (/home/<username>/.config/systemd/user/git-sync-xyz.service; enabled; preset: ignored)
      Active: inactive (dead)

      Okt 31 21:34:05 <hostname> systemd[<pid>]: /home/<username>/.config/systemd/user/git-sync-xyz.service:6: Invalid environment assignment, ignoring: Space/home-manager

Example code:

{ config, ...}:
{
  services.git-sync = {
    enable = true;
    repositories = {
      xyz = {
        path = "${config.home.homeDirectory}/Stuff Space/home-manager";
        interval = 1000;
        uri = "git@github.com:nix-community/home-manager.git";
      };
    };
  };
}

Reason in code: https://github.com/nix-community/home-manager/blob/e83414058edd339148dc142a8437edb9450574c8/modules/services/git-sync.nix#L19

Path gets written verbatim to Environment variable in systemd unit. The resulting environment variable gets rejected by sysemd as invalid.

PR is in the works, I will link it to this issue later.

Maintainer CC

@colonelpanic8 @cab404 @ryane

System information

- system: `"x86_64-linux"`
- host os: `Linux 6.10.14, NixOS, 24.11 (Vicuna), 24.11.20241023.2768c7d`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.24.9`
- channels(root): `"nixos"`
- nixpkgs: `/nix/store/lsy6c2f9alj2gkjj36h754kk63x6701l-source`
RedEtherbloom commented 3 weeks ago

The bug in home-manager should be fixed, but during testing I discovered that the git-sync version in nixpkgs is outdated, resulting in a similar bug with whitespaces.

PR bumping the git-sync version in nixpkgs has been linked for documentation.

colonelpanic8 commented 3 weeks ago

looks good

RedEtherbloom commented 2 weeks ago

I would advocate for keeping this issue open until the second required upstream fix(https://github.com/simonthum/git-sync/issues/33) has been released and pushed to nixpkgs, to avoid a weird state where an issue is listed and merged but not fixed, in case someone else stumbles onto it.