mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
distrobox: add settings option and other general improvements
This commit is contained in:
parent
a48dd228d9
commit
b7cc2466f1
8 changed files with 149 additions and 42 deletions
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
programs.distrobox = {
|
||||
enable = true;
|
||||
enableSystemdUnit = true;
|
||||
};
|
||||
|
||||
test.asserts.assertions.expected = [
|
||||
"Cannot set `programs.distrobox.enableSystemdUnit` if `programs.distrobox.containers` is unset."
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
programs.distrobox = {
|
||||
enable = true;
|
||||
package = null;
|
||||
enableSystemdUnit = true;
|
||||
containers = {
|
||||
python-project = {
|
||||
image = "fedora:40";
|
||||
additional_packages = "python3 git";
|
||||
init_hooks = "pip3 install numpy pandas torch torchvision";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
test.asserts.assertions.expected = [
|
||||
"Cannot set `programs.distrobox.enableSystemdUnit` if `programs.distrobox.package` is set to null."
|
||||
];
|
||||
}
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
{ lib, pkgs, ... }:
|
||||
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||
distrobox-example-config = ./example-config.nix;
|
||||
distrobox-no-asserts = ./no-asserts.nix;
|
||||
distrobox-assert-package-systemd-unit = ./assert-package-systemd-unit.nix;
|
||||
distrobox-assert-containers-systemd-unit = ./assert-containers-systemd-unit.nix;
|
||||
}
|
||||
|
|
|
|||
12
tests/modules/programs/distrobox/distrobox.conf
Normal file
12
tests/modules/programs/distrobox/distrobox.conf
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
container_additional_volumes="/example:/example1 /example2:/example3:ro"
|
||||
container_always_pull="1"
|
||||
container_generate_entry=0
|
||||
container_image_default="registry.opensuse.org/opensuse/toolbox:latest"
|
||||
container_init_hook="~/.local/distrobox/a_custom_default_init_hook.sh"
|
||||
container_manager="docker"
|
||||
container_manager_additional_flags="--env-file /path/to/file --custom-flag"
|
||||
container_name_default="test-name-1"
|
||||
container_pre_init_hook="~/a_custom_default_pre_init_hook.sh"
|
||||
container_user_custom_home="$HOME/.local/share/container-home-test"
|
||||
non_interactive="1"
|
||||
skip_workdir="0"
|
||||
|
|
@ -1,8 +1,22 @@
|
|||
{
|
||||
programs.distrobox = {
|
||||
enable = true;
|
||||
containers = {
|
||||
settings = {
|
||||
container_always_pull = "1";
|
||||
container_generate_entry = 0;
|
||||
container_manager = "docker";
|
||||
container_image_default = "registry.opensuse.org/opensuse/toolbox:latest";
|
||||
container_name_default = "test-name-1";
|
||||
container_user_custom_home = "$HOME/.local/share/container-home-test";
|
||||
container_init_hook = "~/.local/distrobox/a_custom_default_init_hook.sh";
|
||||
container_pre_init_hook = "~/a_custom_default_pre_init_hook.sh";
|
||||
container_manager_additional_flags = "--env-file /path/to/file --custom-flag";
|
||||
container_additional_volumes = "/example:/example1 /example2:/example3:ro";
|
||||
non_interactive = "1";
|
||||
skip_workdir = "0";
|
||||
};
|
||||
|
||||
containers = {
|
||||
python-project = {
|
||||
image = "fedora:40";
|
||||
additional_packages = "python3 git";
|
||||
|
|
@ -29,13 +43,16 @@
|
|||
clone = "common-debian";
|
||||
entry = false;
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/distrobox/distrobox.conf
|
||||
assertFileContent home-files/.config/distrobox/distrobox.conf \
|
||||
${./distrobox.conf}
|
||||
|
||||
assertFileExists home-files/.config/distrobox/containers.ini
|
||||
assertFileContent home-files/.config/distrobox/containers.ini \
|
||||
${./example-config.ini}
|
||||
${./containers.ini}
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
6
tests/modules/programs/distrobox/no-asserts.nix
Normal file
6
tests/modules/programs/distrobox/no-asserts.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
programs.distrobox = {
|
||||
enable = true;
|
||||
package = null;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue