Merge pull request #21 from hercules-ci/composition-level-environment
Host environment
This commit is contained in:
commit
da85a4cbbe
6 changed files with 59 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
|||
{ modules ? [], uid ? 0, pkgs }:
|
||||
{ modules ? [], uid ? "0", pkgs, hostNixStorePrefix ? "", }:
|
||||
|
||||
let _pkgs = pkgs;
|
||||
in
|
||||
|
@ -18,14 +18,16 @@ let
|
|||
|
||||
builtinModules = [
|
||||
argsModule
|
||||
./docker-compose-module.nix
|
||||
./modules/composition/docker-compose.nix
|
||||
./modules/composition/host-environment.nix
|
||||
];
|
||||
|
||||
argsModule = {
|
||||
_file = ./eval-composition.nix;
|
||||
key = ./eval-composition.nix;
|
||||
config._module.args.pkgs = lib.mkIf (pkgs != null) (lib.mkForce pkgs);
|
||||
config._module.args.uid = uid;
|
||||
config.host.nixStorePrefix = hostNixStorePrefix;
|
||||
config.host.uid = lib.toInt uid;
|
||||
};
|
||||
|
||||
in
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
- docker-compose.services
|
||||
|
||||
*/
|
||||
{ pkgs, uid, lib, config, ... }:
|
||||
{ pkgs, lib, config, ... }:
|
||||
|
||||
let
|
||||
evalService = name: modules:
|
||||
|
@ -21,15 +21,16 @@ let
|
|||
|
||||
builtinModules = [
|
||||
argsModule
|
||||
./service.nix
|
||||
./service-host-store.nix
|
||||
../service/docker-compose-service.nix
|
||||
../service/host-store.nix
|
||||
../service/host.nix
|
||||
];
|
||||
|
||||
argsModule = {
|
||||
_file = ./docker-compose-module.nix;
|
||||
key = ./docker-compose-module.nix;
|
||||
_file = ./docker-compose.nix;
|
||||
key = ./docker-compose.nix;
|
||||
config._module.args.pkgs = lib.mkForce pkgs;
|
||||
config._module.args.uid = uid;
|
||||
config.host = config.host;
|
||||
};
|
||||
|
||||
in
|
32
src/nix/modules/composition/host-environment.nix
Normal file
32
src/nix/modules/composition/host-environment.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
options = {
|
||||
|
||||
host.uid = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
description = ''
|
||||
The numeric user id (UID) of the user running arion.
|
||||
|
||||
Assuming this user id is helpful when dealing with the user's
|
||||
files, mounted into the container as a volume.
|
||||
'';
|
||||
};
|
||||
|
||||
host.nixStorePrefix = lib.mkOption {
|
||||
type = lib.types.string;
|
||||
default = "";
|
||||
example = "/mnt/foo";
|
||||
description = ''
|
||||
Prefixes store paths on the host, allowing the Nix store to be
|
||||
stored at an alternate location without altering the format of
|
||||
store paths.
|
||||
|
||||
For example: instead of mounting the host's /nix/store as the
|
||||
container's /nix/store, this will mount /mnt/foo/nix/store
|
||||
as the container's /nix/store.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
*/
|
||||
{ lib, config, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkOption types mkIf;
|
||||
in
|
||||
|
@ -18,10 +19,10 @@ in
|
|||
};
|
||||
config = mkIf config.service.useHostStore {
|
||||
service.image = "arion-base";
|
||||
service.build.context = "${../arion-image}";
|
||||
service.build.context = "${../../../arion-image}";
|
||||
service.volumes = [
|
||||
"/nix/store:/nix/store"
|
||||
"${pkgs.buildEnv { name = "container-system-env"; paths = [ pkgs.bashInteractive pkgs.coreutils ]; }}:/run/system"
|
||||
"${config.host.nixStorePrefix}/nix/store:/nix/store"
|
||||
"${config.host.nixStorePrefix}${pkgs.buildEnv { name = "container-system-env"; paths = [ pkgs.bashInteractive pkgs.coreutils ]; }}:/run/system"
|
||||
];
|
||||
};
|
||||
}
|
11
src/nix/modules/service/host.nix
Normal file
11
src/nix/modules/service/host.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{ lib, ... }:
|
||||
{
|
||||
options = {
|
||||
host = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
description = ''
|
||||
The composition-level host option values.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue