# Nix-Maid: systemd native dotfile management

**URL:** https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619
**Category:** Announcements
**Created:** [May 22, 2025, 4:02pm UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619 "2025-05-22T16:02:37Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![viperML](https://discourse.nixos.org/user_avatar/discourse.nixos.org/viperml/32/34002_2.png) [@viperML](https://discourse.nixos.org/u/viperML)
#### Post date: [May 22, 2025, 4:02pm UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/1 "2025-05-22T16:02:37Z")

</div>

Hello 👋

Today I want to present my latest project: nix-maid. It started as a systemd-centric alternative to home-manager, as it only uses tmpfiles and regular user services (as opposed to activation hooks).

Please visit the page for more information, and let me know if you try it: [viperml.codeberg.page/nix-maid](https://viperml.codeberg.page/nix-maid/) ([Codeberg](https://codeberg.org/viperML/nix-maid))

This is an example standalone nix-maid configuration, that can be installed with `nix-env -if ./my-config.nix && activate` (I also provide a NixOS module and a Flake).

```nix
# my-config.nix
let
  sources = import ./npins;
  pkgs = import sources.nixpkgs;
  nix-maid = import sources.nix-maid;
in
nix-maid pkgs {
  # Add packages to install
  packages = [
    pkgs.yazi
    pkgs.bat
    pkgs.eza
  ];

  # Create files in your home directory
  file.home.".gitconfig".text = ''
    [user]
      name=Maid
  '';

  file.xdg_config."zellij/config.kdl".source = ./config.kdl;

  # `file` supports a mustache syntax, for dynamically resolving the value of {{home}}
  # This same configuration is portable between systems with different home dirs
  file.xdg_config."hypr/hyprland.conf".source = "{{home}}/dotfiles/hyprland.conf";

  # Define systemd-user services, like you would on NixOS
  systemd.services.waybar = {
    path = [pkgs.waybar];
    script = ''
      exec waybar
    '';
    wantedBy = ["graphical-session.target"];
  };

  # Configure gnome with dconf or gsettings
  gsettings.settings = {
    "org.gnome.mutter"."experimental-features" = [
      "scale-monitor-framebuffer" "xwayland-native-scaling"
    ];
  };

  dconf.settings = {
    "/org/gnome/desktop/interface/color-scheme" = "prefer-dark";
  };

  # Mustache syntax is also available in dynamicRules
  systemd.tmpfiles.dynamicRules = [
    "L {{xdg_config_dir}}/hypr/workspaces.conf - - - - {{home}}/dotfiles/workspaces.conf"
  ];
}

```

---

<div class="post-metadata">

### Author: ![Ambroisie](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/a/b2d939/32.png) [@Ambroisie](https://discourse.nixos.org/u/Ambroisie)
#### Post date: [May 23, 2025, 6:36pm UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/2 "2025-05-23T18:36:28Z")

</div>

Why use Moustache when one already has access to Nix for (IMO) much stronger templating support?

---

<div class="post-metadata">

### Author: ![adamcstephens](https://discourse.nixos.org/user_avatar/discourse.nixos.org/adamcstephens/32/35883_2.png) [@adamcstephens](https://discourse.nixos.org/u/adamcstephens)
#### Post date: [May 23, 2025, 7:33pm UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/3 "2025-05-23T19:33:01Z")

</div>

I think it’s for allowing runtime resolution as opposed to eval/build time. I don’t think you could meet these two goals without doing runtime resolution.

```auto
🌐 Portable: Defers the value of your home directory, so the same configuration works for different users.
🚫 No Legacy: API redesigned from scratch, avoiding past mistakes like mkOutOfStoreSymlink.
```

---

<div class="post-metadata">

### Author: ![viperML](https://discourse.nixos.org/user_avatar/discourse.nixos.org/viperml/32/34002_2.png) [@viperML](https://discourse.nixos.org/u/viperML)
#### Post date: [May 23, 2025, 8:02pm UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/4 "2025-05-23T20:02:45Z")

</div>

The mustache syntax is for values that are resolved at runtime, that’s a feature I wanted to use myself.

---

<div class="post-metadata">

### Author: ![jotix](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/j/9fc29f/32.png) [@jotix](https://discourse.nixos.org/u/jotix)
#### Post date: [May 23, 2025, 9:39pm UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/5 "2025-05-23T21:39:45Z")

</div>

OH, this is perfect !  
Is exactly what i’m looking, i don’t really like Home Manager and this look a much simpler solution.  
Thank You !

---

<div class="post-metadata">

### Author: ![codethief](https://discourse.nixos.org/user_avatar/discourse.nixos.org/codethief/32/31696_2.png) [@codethief](https://discourse.nixos.org/u/codethief)
#### Post date: [May 30, 2025, 12:08pm UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/6 "2025-05-30T12:08:30Z")

</div>

Interesting project!

The website says:

> API redesigned from scratch, freeing us from past mistakes like `mkOutOfStoreSymlink`

What does this mean exactly? Can Nix-Maid create simple symlinks like `~/.foo -> ~/.dotfiles/foo` without hackery (i.e. does it avoid intermediate symlinks through the Nix store etc.)?

---

<div class="post-metadata">

### Author: ![viperML](https://discourse.nixos.org/user_avatar/discourse.nixos.org/viperml/32/34002_2.png) [@viperML](https://discourse.nixos.org/u/viperML)
#### Post date: [May 30, 2025, 1:46pm UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/7 "2025-05-30T13:46:24Z")

</div>

HM breaks assumptions from NixOS, e.g. `environment.etc."foo".source = "/bar"` is fine on NixOS, but in HM it will try to cast the string into a path, which later fails when using flakes because of the eval sandbox. `mkOutOfStoreSymlink` exists to restore that functionality, and to me it’s a hack more than anything. For that reason, `.source` in nix-maid works the same as in NixOS.

The other topic is that nix-maid allows you to use a moustache syntax for runtime variables, so you can do either `file.home.".foo".source = "/home/myuser/.dotfiles/foo` or `file.home.".foo".source = "{{home}}/.dotfiles/foo` (both without `mkOutOfStoreSymlink` when using a string literal)

---

<div class="post-metadata">

### Author: ![tejing](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tejing/32/4566_2.png) [@tejing](https://discourse.nixos.org/u/tejing)
#### Post date: [June 26, 2025, 3:19am UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/9 "2025-06-26T03:19:48Z")

</div>

Most home-manager modules are largely just ways to create the text of files which are then installed through `home.file`. You can absolutely just not use that and directly write the text of the config file… and personally, I’ve found that I don’t honestly want to use many of the module from home-manager. The key functionality is the ability to manage the files.

---

<div class="post-metadata">

### Author: ![tejing](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tejing/32/4566_2.png) [@tejing](https://discourse.nixos.org/u/tejing)
#### Post date: [June 26, 2025, 3:22am UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/10 "2025-06-26T03:22:29Z")

</div>

One thing you need to make clear in the introduction is whether `nix-maid` cleans up after itself. Generally, systems based on systemd’s tmpfiles.d don’t do that. If you remove the declaration of a symlink, it sticks around on the filesystem until you manually delete it. This is the biggest thing that keeps me using home-manager’s `home.file` despite everything aggravating about it.

---

<div class="post-metadata">

### Author: ![frozen.frog23](https://discourse.nixos.org/user_avatar/discourse.nixos.org/frozen.frog23/32/31895_2.png) [@frozen.frog23](https://discourse.nixos.org/u/frozen.frog23)
#### Post date: [June 26, 2025, 3:53am UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/11 "2025-06-26T03:53:08Z")

</div>

hmm. is that a big deal? cos yeah, it doesnt… 😕

i mean, isnt there like a command or another helper thingie that removes orphaned symlinks? cos i mightve made a mess just now lol. actually, it doesnt even appear to be an orphan symlink at all! even though i have un-declared it, it’s still out there, in the `nix/store/`… oh, yeah, thats right, doesnt it EVENTUALLY go away in a few generations, no?

i was kinda hoping that `boot.tmp.cleanOnBoot` would sort it out, but no… idk what i was thinking

EDIT (a year later): it was, indeed, a big deal. my old dotfiles made with `nix-maid` were regenerating on every reboot, which made it very difficult to switch to [`hjem`](https://github.com/feel-co/hjem)! anyway, after having to follow some symlinks, only then i could successfully uninstall `nix-maid`. symlinks are scary!

---

<div class="post-metadata">

### Author: ![tejing](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tejing/32/4566_2.png) [@tejing](https://discourse.nixos.org/u/tejing)
#### Post date: [June 26, 2025, 3:58am UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/12 "2025-06-26T03:58:10Z")

</div>

There are certainly ways to remove orphaned symlinks, but that’s not really “correct” as a solution to this problem, since the file still being in the nix store doesn’t mean it’s part of the current generation of your config… as you apparently just discovered, given your edit.

---

<div class="post-metadata">

### Author: ![viperML](https://discourse.nixos.org/user_avatar/discourse.nixos.org/viperml/32/34002_2.png) [@viperML](https://discourse.nixos.org/u/viperML)
#### Post date: [June 26, 2025, 7:08am UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/13 "2025-06-26T07:08:17Z")

</div>

@tejing Regarding the removal of old symlinks, nix-maid uses the static directory method that NixOS uses (but with another layer of indirection as the contents of the static directory are generated at runtime).

With this method, instead of creating direct symlinks `~/.gitconfig -> /nix/store/...-gitconfig`, you put a directory in between:

 ![image](https://discourse.nixos.org/uploads/default/original/3X/8/1/81d6deafbf1e457fa250288da31b71aed895d6a3.png)

For the first generation, following the chain `~/.gitconfig` resolves to the actual gitconfig in the nix store. To perform an upgrade, instead of touch `~/.gitconfig` we can just change which generation the static directory points to.

When we upgrade to a generation (3rd case) where `.gitconfig` is no longer configured by the user, `~/.gitconfig` becomes a stale link into the new generation. Therefore, the configuration has been “removed” without having to remove the old symlinks.

This works fine under the assumptions that:

- The program reading the config file properly handles dead symlinks.
- The program reading the config file doesn’t get upset for 2 more layers of symlink indirection.

…which for the programs I use, they are true.

For the future I plan to:

1. Document this behaviour better in the nix-maid docs.
2. Write an optional systemd service that cleans dead symlinks into the nix-maid static dir.
3. Consider moving away from systemd-tmpfiles. We can probably do the same with a tiny Rust/Go program that ingests a manifest similar to tmpfiles, but with better logging etc and compatible with macos.

---

<div class="post-metadata">

### Author: ![viperML](https://discourse.nixos.org/user_avatar/discourse.nixos.org/viperml/32/34002_2.png) [@viperML](https://discourse.nixos.org/u/viperML)
#### Post date: [June 26, 2025, 7:10am UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/14 "2025-06-26T07:10:27Z")

</div>

(I thought this was already in nix-maid, but in some of the rewrites I forgot to add the static linking behaviour, it should be fine now: [Fix static linking · viperML/nix-maid@534317b · GitHub](https://github.com/viperML/nix-maid/commit/534317bfd2d8279d1aa35ad8dee276c975e0efe2))

---

<div class="post-metadata">

### Author: ![tejing](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tejing/32/4566_2.png) [@tejing](https://discourse.nixos.org/u/tejing)
#### Post date: [June 26, 2025, 7:28am UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/15 "2025-06-26T07:28:07Z")

</div>

Thanks for the detailed explanation. Leaving them as dead symlinks is certainly an improvement on leaving them as working ones. And I’ve always thought it was strange that home-manager _doesn’t_ use the static directory idea that nixos uses for `/etc`. Both atomicity and the simplicity of keeping track of everything push for it.

Idea: You could probably improve the performance of the “cleaning” process (when/if you implement it) by walking the old static directory rather than the entire home directory. Anything you’re supposed to clean should be in that. Nixos’ etc script doesn’t do it, but there usually isn’t much in etc that isn’t declaratively managed, anyway, so the savings would be minimal there. That would require the cleaning process to be part of the activation, though, not a separate service.

---

<div class="post-metadata">

### Author: ![codethief](https://discourse.nixos.org/user_avatar/discourse.nixos.org/codethief/32/31696_2.png) [@codethief](https://discourse.nixos.org/u/codethief)
#### Post date: [August 8, 2025, 11:01am UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/16 "2025-08-08T11:01:18Z")

</div>

@viperML nix-maid looks really interesting, thanks so much!

> It started as a systemd-centric alternative to home-manager, as it only uses tmpfiles and regular user services (as opposed to activation hooks).

Could you elaborate on how nix-maid is “systemd-centric” and on its usage of tmpfiles? (What role do they play?) I have to admit I don’t know home-manager too well (only that it didn’t seem to work for my use case last time I tried it).

---

<div class="post-metadata">

### Author: ![frozen.frog23](https://discourse.nixos.org/user_avatar/discourse.nixos.org/frozen.frog23/32/31895_2.png) [@frozen.frog23](https://discourse.nixos.org/u/frozen.frog23)
#### Post date: [August 10, 2025, 12:36pm UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/17 "2025-08-10T12:36:45Z")

</div>

hey guys, i use `nix-maid` for simple configs n stuff, but i noticed this in `dmesg`?

```auto
[6.089542] systemd[1]: multi-user.target: Wants dependency dropin /nix/store/cgd3bkqm0iydr96bn776x3qha52v0bl6-system-units/multi-user.target.wants/maid-activation@.service target ../maid-activation@.service has different name
[6.101306] systemd[1]: maid-activation@multi-user.service: Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing.
[6.121856] systemd[1]: maid-activation@multi-user.service: Cannot add dependency job, ignoring: Unit maid-activation@multi-user.service has a bad unit file setting.

```

uhm, should i be concerned? works well nevertheless!

ty

---

<div class="post-metadata">

### Author: ![Lubsch](https://discourse.nixos.org/user_avatar/discourse.nixos.org/lubsch/32/36834_2.png) [@Lubsch](https://discourse.nixos.org/u/Lubsch)
#### Post date: [August 20, 2025, 1:07pm UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/18 "2025-08-20T13:07:05Z")

</div>

I also don’t have a very deep understanding so take what I say with a grain of salt.

Home-Mananager makes use of of `mkOutOfStoreSymlink` which is considered a hack by a lot of people and builds a derivation for your current generation under `/run/...` which it links into home using a custom (and slow imo) bash script: [home-manager/modules/files.nix at dd026d86420781e84d0732f2fa28e1c051117b59 · nix-community/home-manager · GitHub](https://github.com/nix-community/home-manager/blob/dd026d86420781e84d0732f2fa28e1c051117b59/modules/files.nix).

It does this with an activation script (running on login / generation switches). As I understand it, nix-maid cuts out these steps and makes use of systems tmpfiles instead.

---

<div class="post-metadata">

### Author: ![viperML](https://discourse.nixos.org/user_avatar/discourse.nixos.org/viperml/32/34002_2.png) [@viperML](https://discourse.nixos.org/u/viperML)
#### Post date: [August 21, 2025, 10:04am UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/19 "2025-08-21T10:04:42Z")

</div>

Nix-maid is first and foremost a framework for writing systemd-user units. Everything else is implemented after systemd. With this design, all that the nix-maid binary runs is to activate the systemd units.

With this is mind, I though about implementing the file linking using systemd-tmpfiles, to keep the systemd theme. All the file.home options map into tmpfiles rules, and this works decently well.

However, I’m thinking about moving away from tmpfiles, into just a program that runs as a systemd service and performs all the linkage. The problem with tmpfiles is that it provides 0 logging information about what it does. This is not something I like for a user-facing too like nix-maid.

---

<div class="post-metadata">

### Author: ![phaer](https://discourse.nixos.org/user_avatar/discourse.nixos.org/phaer/32/8370_2.png) [@phaer](https://discourse.nixos.org/u/phaer)
#### Post date: [August 23, 2025, 11:01pm UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/20 "2025-08-23T23:01:59Z")

</div>

I am currently on mobile, but I do think system-tmpfiles provides logging of it actions. Maybe the log level is too low?

There’s also [GitHub - feel-co/hjem: Streamlined, elegant $HOME management with Nix](https://github.com/feel-co/hjem), another home-manager alternative that uses systemd-tmpfiles. Readme says the authors consider alternative linkers for better support on non-nixos systems.

---

<div class="post-metadata">

### Author: ![viperML](https://discourse.nixos.org/user_avatar/discourse.nixos.org/viperml/32/34002_2.png) [@viperML](https://discourse.nixos.org/u/viperML)
#### Post date: [October 5, 2025, 7:35am UTC](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619/21 "2025-10-05T07:35:25Z")

</div>

Just waking up this thread to announce that I added support for KDE/KConfig for nix-maid:

```nix
{ config, pkgs, ...}: {

  users.users.nixos = {
    isNormalUser = true;

    maid = {
      kconfig.settings = {
        kwinrc = {
          Desktops.Number = 4;
        };
        baloofilerc = {
          "Basic Settings".Indexing-Enabled = false;
        };
      };
    };
  };

}

```

This is a re-implementation of plasma-manager, that instead of parsing kconfig files, directly calls the C++ KDE API. This is also documented in the nix-maid docs: [API Documentation | nix-maid](https://viperml.github.io/nix-maid/api.html#kconfig).

[Next page](https://discourse.nixos.org/t/nix-maid-systemd-native-dotfile-management/64619.md?page=2)
