From 9cc30b18f710eba6aa1f72155a747a640fc17b2a Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Thu, 8 Aug 2019 18:24:08 +0200 Subject: [PATCH] nixos: add backup file extension and verbosity options --- nixos/default.nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/nixos/default.nix b/nixos/default.nix index 4628d1f2d..51f4640c0 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -23,6 +23,14 @@ let }; }); + serviceEnvironment = + optionalAttrs (cfg.backupFileExtension != null) { + HOME_MANAGER_BACKUP_EXT = cfg.backupFileExtension; + } + // optionalAttrs cfg.verbose { + VERBOSE = "1"; + }; + in { @@ -33,6 +41,18 @@ in option. ''; + backupFileExtension = mkOption { + type = types.nullOr types.str; + default = null; + example = "backup"; + description = '' + On activation move existing files by appending the given + file extension rather than exiting with an error. + ''; + }; + + verbose = mkEnableOption "verbose output on activation"; + users = mkOption { type = types.attrsOf hmModule; default = {}; @@ -70,6 +90,8 @@ in wants = [ "nix-daemon.socket" ]; after = [ "nix-daemon.socket" ]; + environment = serviceEnvironment; + serviceConfig = { User = usercfg.home.username; Type = "oneshot";