mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-05 16:41:04 +01:00
numbat: Add initFile option
This commit is contained in:
parent
d75a547415
commit
26d405da41
3 changed files with 24 additions and 0 deletions
|
|
@ -38,11 +38,26 @@ in
|
|||
<https://numbat.dev/doc/cli-customization.html#configuration> for options.
|
||||
'';
|
||||
};
|
||||
|
||||
initFile = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.lines;
|
||||
default = null;
|
||||
example = ''
|
||||
unit kohm: ElectricResistance = kV/A
|
||||
'';
|
||||
description = ''
|
||||
User initialization file ({file}`init.nbt`) contents.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||
|
||||
home.file."${configDir}/init.nbt" = mkIf (cfg.initFile != null) {
|
||||
text = cfg.initFile;
|
||||
};
|
||||
|
||||
home.file."${configDir}/config.toml" = mkIf (cfg.settings != { }) {
|
||||
source = tomlFormat.generate "numbat-config" cfg.settings;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,5 +14,6 @@ in
|
|||
|
||||
nmt.script = ''
|
||||
assertPathNotExists 'home-files/${configDir}/config.toml'
|
||||
assertPathNotExists 'home-files/${configDir}/init.nbt'
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ in
|
|||
prompt = "> ";
|
||||
exchange-rates.fetching-policy = "on-first-use";
|
||||
};
|
||||
initFile = ''
|
||||
unit kohm: ElectricResistance = kV/A
|
||||
'';
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
|
|
@ -31,5 +34,10 @@ in
|
|||
[exchange-rates]
|
||||
fetching-policy = "on-first-use"
|
||||
''}
|
||||
assertFileExists 'home-files/${configDir}/init.nbt'
|
||||
assertFileContent $(normalizeStorePaths 'home-files/${configDir}/init.nbt') \
|
||||
${builtins.toFile "expected-init.nbt" ''
|
||||
unit kohm: ElectricResistance = kV/A
|
||||
''}
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue