Move uid and customNixRootPath into config.host module
Also make the type of host.uid consistently int.
This commit is contained in:
parent
359c8b601d
commit
c03ca68795
5 changed files with 53 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
|||
{ modules ? [], uid ? 0, pkgs, customNixRootPath ? "", }:
|
||||
{ modules ? [], uid ? "0", pkgs, hostNixStorePrefix ? "", }:
|
||||
|
||||
let _pkgs = pkgs;
|
||||
in
|
||||
|
@ -19,14 +19,15 @@ let
|
|||
builtinModules = [
|
||||
argsModule
|
||||
./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._module.args.customNixRootPath = customNixRootPath;
|
||||
config.host.nixStorePrefix = hostNixStorePrefix;
|
||||
config.host.uid = lib.toInt uid;
|
||||
};
|
||||
|
||||
in
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
- docker-compose.services
|
||||
|
||||
*/
|
||||
{ pkgs, uid, lib, config, customNixRootPath, ... }:
|
||||
{ pkgs, lib, config, ... }:
|
||||
|
||||
let
|
||||
evalService = name: modules:
|
||||
|
@ -23,14 +23,14 @@ let
|
|||
argsModule
|
||||
../service/docker-compose-service.nix
|
||||
../service/host-store.nix
|
||||
../service/host.nix
|
||||
];
|
||||
|
||||
argsModule = {
|
||||
_file = ./docker-compose.nix;
|
||||
key = ./docker-compose.nix;
|
||||
config._module.args.pkgs = lib.mkForce pkgs;
|
||||
config._module.args.uid = uid;
|
||||
config._module.args.customNixRootPath = customNixRootPath;
|
||||
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.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
when the service.useHostStore option is set to true.
|
||||
|
||||
*/
|
||||
{ lib, config, pkgs, customNixRootPath, ... }:
|
||||
{ lib, config, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkOption types mkIf;
|
||||
|
@ -21,8 +21,8 @@ in
|
|||
service.image = "arion-base";
|
||||
service.build.context = "${../../../arion-image}";
|
||||
service.volumes = [
|
||||
"${customNixRootPath}/nix/store:/nix/store"
|
||||
"${customNixRootPath}${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