mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
kraftkit: new module
This commit is contained in:
parent
0a3fb53ee2
commit
aa888ffc10
5 changed files with 91 additions and 0 deletions
10
modules/misc/news/2025/10/2025-10-26_14-36-05.nix
Normal file
10
modules/misc/news/2025/10/2025-10-26_14-36-05.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
time = "2025-10-26T07:36:05+00:00";
|
||||
condition = true;
|
||||
message = ''
|
||||
A new module is available: `programs.kraftkit`.
|
||||
|
||||
kraftkit is a CLI tool for building custom, minimal, immutable lightweight
|
||||
unikernel virtual machines based on Unikraft.
|
||||
'';
|
||||
}
|
||||
50
modules/programs/kraftkit.nix
Normal file
50
modules/programs/kraftkit.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
mkEnableOption
|
||||
mkPackageOption
|
||||
mkOption
|
||||
mkIf
|
||||
literalExpression
|
||||
;
|
||||
|
||||
cfg = config.programs.kraftkit;
|
||||
yamlFormat = pkgs.formats.yaml { };
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ lib.hm.maintainers.folliehiyuki ];
|
||||
|
||||
options.programs.kraftkit = {
|
||||
enable = mkEnableOption "kraftkit - CLI to build and use customized unikernel VMs";
|
||||
|
||||
package = mkPackageOption pkgs "kraft" { nullable = true; };
|
||||
|
||||
settings = mkOption {
|
||||
type = yamlFormat.type;
|
||||
default = { };
|
||||
description = ''
|
||||
Configuration written to {file}`$XDG_CONFIG_HOME/kraftkit/config.yaml`.
|
||||
'';
|
||||
example = literalExpression ''
|
||||
no_prompt = true;
|
||||
log = {
|
||||
level = "info";
|
||||
type = "fancy";
|
||||
};
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||
|
||||
xdg.configFile."kraftkit/config.yaml" = mkIf (cfg.settings != { }) {
|
||||
source = yamlFormat.generate "kraftkit-config" cfg.settings;
|
||||
};
|
||||
};
|
||||
}
|
||||
1
tests/modules/programs/kraftkit/default.nix
Normal file
1
tests/modules/programs/kraftkit/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ kraftkit-example-settings = ./example-settings.nix; }
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
collect_anonymous_telemetry: false
|
||||
log:
|
||||
level: info
|
||||
timestamps: false
|
||||
type: fancy
|
||||
no_check_updates: true
|
||||
24
tests/modules/programs/kraftkit/example-settings.nix
Normal file
24
tests/modules/programs/kraftkit/example-settings.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
programs.kraftkit = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { };
|
||||
|
||||
settings = {
|
||||
no_check_updates = true;
|
||||
collect_anonymous_telemetry = false;
|
||||
log = {
|
||||
level = "info";
|
||||
timestamps = false;
|
||||
type = "fancy";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists "home-files/.config/kraftkit/config.yaml"
|
||||
assertFileContent \
|
||||
"home-files/.config/kraftkit/config.yaml" \
|
||||
${./example-config-expected.yaml}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue