Skip to content

Instantly share code, notes, and snippets.

@danbst
Created December 27, 2019 15:17
Show Gist options
  • Select an option

  • Save danbst/eb55f9363c0b9151d65271ae6c20f39b to your computer and use it in GitHub Desktop.

Select an option

Save danbst/eb55f9363c0b9151d65271ae6c20f39b to your computer and use it in GitHub Desktop.
Manage your /etc from home-manager (install home-manager as root)
{ config, pkgs, lib, ... }: {
imports = [
(import <nixpkgs/nixos/modules/system/etc/etc.nix>)
];
options.system.build.etc = lib.mkOption { type = lib.types.package; };
options.system.activationScripts.etc =
lib.mkOption { type = lib.types.unspecified; };
config = {
home.activation.setupEtc = config.lib.dag.entryAfter [ "writeBoundary" ] ''
exec ${
pkgs.writeScript "etc-activation"
config.system.activationScripts.etc.text
}
'';
};
}
@AsahiRocks

AsahiRocks commented Jul 6, 2026

Copy link
Copy Markdown

In more recent versions of Nixpkgs (around 2022), this snippet broke due to a change in the upsteam etc.nix module. For anyone else wanting to use this file, I've found that the easiest fix is to replace mentions of system.activationScripts.etc with system.build.etcActivationCommands.

Also, you might want to replace (import <nixpkgs/nixos/modules/system/etc/etc.nix>) with a pure version that works with flakes: (inputs.nixpkgs + "/nixos/modules/system/etc/etc.nix") (you need to add inputs into your home-manager's extraSpecialArgs and then also actually import them at the top of this module).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment