Compare commits
92 commits
issue-175-
...
main
Author | SHA1 | Date | |
---|---|---|---|
ec4f2a836d | |||
|
90bc855327 | ||
|
16c4d4d8b8 | ||
|
236f9dd82d | ||
|
ab9bdaf08f | ||
|
555e7ba634 | ||
|
01777136c6 | ||
|
8f0549b434 | ||
|
c24c185e67 | ||
|
d917218d05 | ||
|
e9945eb6cd | ||
|
0449d31ffb | ||
|
7e7aa3dfc6 | ||
|
efa008e12f | ||
|
df306b74bc | ||
|
add0e67d2b | ||
|
c8c61a3c67 | ||
|
1886d25075 | ||
|
c2cc3dae34 | ||
|
d2d48c9ec3 | ||
|
c1597ef64b | ||
|
2b1fa9a8e9 | ||
|
4fb872dc07 | ||
|
39ee2bc7f7 | ||
|
245fec68a2 | ||
|
9e5caa2b48 | ||
|
5321799830 | ||
|
e92e133563 | ||
|
6ad33828e7 | ||
|
f295eabd25 | ||
|
a27295cbf5 | ||
|
b181b822f8 | ||
|
49bc39d860 | ||
|
91e67df844 | ||
|
da2141cd93 | ||
|
14b8d91ce0 | ||
|
2d546f6372 | ||
|
f68888200d | ||
|
39030b9566 | ||
|
493fa1e575 | ||
|
172e69d563 | ||
|
6881b440b6 | ||
|
28902d3488 | ||
|
57516c38fa | ||
|
e9ebb6f79f | ||
|
51ed7054c1 | ||
|
3588b01e13 | ||
|
638c4b8e55 | ||
|
a8d9725e6c | ||
|
f0436c8478 | ||
|
8868689d3f | ||
|
408841513b | ||
|
22ef4649d8 | ||
|
0e7dc62ccf | ||
|
9ba47f9fbb | ||
|
16f9888732 | ||
|
b175f45613 | ||
|
f8359746cc | ||
|
2ef502c912 | ||
|
daf4aebad7 | ||
|
6a1f03329c | ||
|
7e98b7af10 | ||
|
5ba2990f72 | ||
|
cb13795408 | ||
|
0f27ae484f | ||
|
399c8c0b36 | ||
|
de9930171a | ||
|
e67a5d3049 | ||
|
a38db89ef8 | ||
|
591036ae85 | ||
|
1b65892ea6 | ||
|
76a6bdbdb2 | ||
|
379724cdcd | ||
|
54079bfbc3 | ||
|
09ef2d1377 | ||
|
4ea9760991 | ||
|
f7391f3e17 | ||
|
6cbf0860ca | ||
|
d1cc2b2a7d | ||
|
3ac9c63a01 | ||
|
50bf4fe6c5 | ||
|
ce3e96e212 | ||
|
c946f1ecc2 | ||
|
0e27a7acd1 | ||
|
48b4787a5a | ||
|
0f5f229425 | ||
|
2dc6bbe049 | ||
|
1a174e2eaa | ||
|
cabcbcacca | ||
|
d0b8e02c28 | ||
|
6851553d2b | ||
|
295e8698bd |
43 changed files with 487 additions and 1564 deletions
.gitignoreCHANGELOG.mdarion-compose.cabalbors.toml
docs
examples
flake.lockflake.nixnixos-module.nixrun-arion-via-nixsrc
haskell
test
testdata/Arion/NixSpec
nix
tests
update-options
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,3 +5,5 @@ dist/
|
|||
dist-newstyle/
|
||||
cabal.project.local
|
||||
|
||||
*.swp
|
||||
|
||||
|
|
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -1,5 +1,18 @@
|
|||
# Revision history for Arion
|
||||
|
||||
## 0.2.1.0 -- 2023-07-26
|
||||
|
||||
### Added
|
||||
|
||||
* `service.networks` now supports attribute set values with various options, thanks to @pedorich-n.
|
||||
* `docker-compose.volumes` can now be specified in multiple modules, thanks to @qaifshaikh.
|
||||
* `image.fakeRootCommands` for making modifications to the image that aren't "add a link farm".
|
||||
|
||||
### Fixed
|
||||
|
||||
* Regular maintenance fixes, including one by olebedev
|
||||
|
||||
|
||||
## 0.2.0.0 -- 2022-12-02
|
||||
|
||||
### BREAKING
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
cabal-version: 2.4
|
||||
|
||||
name: arion-compose
|
||||
version: 0.2.0.0
|
||||
version: 0.2.1.0
|
||||
synopsis: Run docker-compose with help from Nix/NixOS
|
||||
description: Arion is a tool for building and running applications that consist of multiple docker containers using NixOS modules. It has special support for docker images that are built with Nix, for a smooth development experience and improved performance.
|
||||
homepage: https://github.com/hercules-ci/arion#readme
|
||||
|
@ -30,7 +30,7 @@ source-repository head
|
|||
location: https://github.com/hercules-ci/arion
|
||||
|
||||
common common
|
||||
build-depends: base >=4.12.0.0 && <4.17
|
||||
build-depends: base >=4.12.0.0 && <4.99
|
||||
, aeson >=2
|
||||
, aeson-pretty
|
||||
, async
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
status = [
|
||||
"ci/hercules/derivations",
|
||||
"ci/hercules/onPush/default",
|
||||
"ci/hercules/evaluation",
|
||||
]
|
||||
delete_merged_branches = true
|
||||
|
|
|
@ -4,3 +4,4 @@ version: 'master'
|
|||
nav:
|
||||
- modules/ROOT/nav.adoc
|
||||
- modules/reference/nav.adoc
|
||||
nix: true
|
||||
|
|
|
@ -1,20 +1,31 @@
|
|||
{
|
||||
perSystem = { config, pkgs, ... }:
|
||||
let
|
||||
doc-options = import ./options.nix { };
|
||||
perSystem = { config, pkgs, lib, ... }: {
|
||||
packages.generated-option-doc-arion =
|
||||
# TODO: use the render pipeline in flake-parts,
|
||||
# which has support for things like {options}`foo`.
|
||||
let
|
||||
eval = lib.evalModules {
|
||||
modules = import ../src/nix/modules.nix;
|
||||
};
|
||||
in
|
||||
(pkgs.nixosOptionsDoc
|
||||
{
|
||||
options = eval.options;
|
||||
}).optionsCommonMark;
|
||||
|
||||
in
|
||||
{
|
||||
packages.doc-options = pkgs.callPackage ./options.nix { };
|
||||
|
||||
checks.doc-options = pkgs.runCommand "doc-options-check" { } ''
|
||||
if diff --color -u ${./modules/ROOT/partials/NixOSOptions.adoc} ${config.packages.doc-options}; then
|
||||
touch $out
|
||||
else
|
||||
echo 1>&2 "The doc options have changed and need to be added."
|
||||
echo 1>&2 "Please run ./update-options in the root of your arion clone."
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
};
|
||||
packages.generated-antora-files =
|
||||
pkgs.runCommand "generated-antora-files"
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.pandoc ];
|
||||
doc_arion = config.packages.generated-option-doc-arion;
|
||||
}
|
||||
# TODO: use the render pipeline in flake-parts,
|
||||
# which has support for things like {options}`foo`.
|
||||
''
|
||||
mkdir -p $out/modules/ROOT/partials
|
||||
pandoc --from=markdown --to=asciidoc \
|
||||
< $doc_arion \
|
||||
> $out/modules/ROOT/partials/arion-options.adoc
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
1
docs/modules/ROOT/examples/full-nixos/arion-compose.nix
Symbolic link
1
docs/modules/ROOT/examples/full-nixos/arion-compose.nix
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../../../../examples/full-nixos/arion-compose.nix
|
1
docs/modules/ROOT/examples/minimal/arion-compose.nix
Symbolic link
1
docs/modules/ROOT/examples/minimal/arion-compose.nix
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../../../../examples/minimal/arion-compose.nix
|
1
docs/modules/ROOT/examples/nixos-unit/arion-compose.nix
Symbolic link
1
docs/modules/ROOT/examples/nixos-unit/arion-compose.nix
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../../../../examples/nixos-unit/arion-compose.nix
|
|
@ -45,18 +45,21 @@ NOTE: This deployment method does NOT use an `arion-pkgs.nix` file, but reuses
|
|||
# Pick one of:
|
||||
# - niv
|
||||
((import ./nix/sources.nix).arion + "/nixos-module.nix")
|
||||
# - flakes (where arion is a flake input)
|
||||
# - or flakes (where arion is a flake input)
|
||||
arion.nixosModules.arion
|
||||
# - other
|
||||
arionPath + "/nixos-module.nix")
|
||||
# - or other: copy commit hash of arion and replace HASH in:
|
||||
(builtins.fetchTarball "https://github.com/hercules-ci/arion/archive/HASH.tar.gz") + "/nixos-module.nix")
|
||||
];
|
||||
|
||||
virtualisation.arion = {
|
||||
backend = "podman-socket"; # or "docker"
|
||||
projects.example.settings = {
|
||||
# Specify you project here, or import it from a file.
|
||||
# NOTE: This does NOT use ./arion-pkgs.nix, but defaults to NixOS' pkgs.
|
||||
imports = [ ./arion-compose.nix ];
|
||||
projects.example = {
|
||||
serviceName = "example"; # optional systemd service name, defaults to arion-example in this case
|
||||
settings = {
|
||||
# Specify you project here, or import it from a file.
|
||||
# NOTE: This does NOT use ./arion-pkgs.nix, but defaults to NixOS' pkgs.
|
||||
imports = [ ./arion-compose.nix ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -113,14 +113,16 @@ Describe containers using NixOS-style modules. There are a few options:
|
|||
|
||||
==== Minimal: Plain command using nixpkgs
|
||||
|
||||
`examples/minimal/arion-compose.nix`:
|
||||
|
||||
```nix
|
||||
`examples/minimal/arion-compose.nix`
|
||||
[,nix]
|
||||
----
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
config.services = {
|
||||
project.name = "webapp";
|
||||
services = {
|
||||
|
||||
webserver = {
|
||||
image.enableRecommendedContents = true;
|
||||
service.useHostStore = true;
|
||||
service.command = [ "sh" "-c" ''
|
||||
cd "$$WEB_ROOT"
|
||||
|
@ -130,58 +132,36 @@ Describe containers using NixOS-style modules. There are a few options:
|
|||
"8000:8000" # host:container
|
||||
];
|
||||
service.environment.WEB_ROOT = "${pkgs.nix.doc}/share/doc/nix/manual";
|
||||
service.stop_signal = "SIGINT";
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
==== NixOS: run only one systemd service
|
||||
|
||||
`examples/nixos-unit/arion-compose.nix`:
|
||||
|
||||
```nix
|
||||
{
|
||||
services.webserver = { config, pkgs, ... }: {
|
||||
|
||||
nixos.configuration = {config, pkgs, ...}: {
|
||||
boot.isContainer = true;
|
||||
services.nginx.enable = true;
|
||||
services.nginx.virtualHosts.localhost.root = "${pkgs.nix.doc}/share/doc/nix/manual";
|
||||
system.build.run-nginx = pkgs.writeScript "run-nginx" ''
|
||||
#!${pkgs.bash}/bin/bash
|
||||
PATH='${config.systemd.services.nginx.environment.PATH}'
|
||||
echo nginx:x:${toString config.users.users.nginx.uid}:${toString config.users.groups.nginx.gid}:nginx web server user:/var/empty:/bin/sh >>/etc/passwd
|
||||
echo nginx:x:${toString config.users.groups.nginx.gid}:nginx >>/etc/group
|
||||
${config.systemd.services.nginx.runner}
|
||||
'';
|
||||
};
|
||||
service.command = [ config.nixos.build.run-nginx ];
|
||||
service.useHostStore = true;
|
||||
service.ports = [
|
||||
"8000:80" # host:container
|
||||
];
|
||||
};
|
||||
}
|
||||
```
|
||||
----
|
||||
|
||||
==== NixOS: run full OS
|
||||
|
||||
`examples/full-nixos/arion-compose.nix`:
|
||||
|
||||
```nix
|
||||
[,nix]
|
||||
----
|
||||
{
|
||||
services.webserver = { pkgs, ... }: {
|
||||
project.name = "full-nixos";
|
||||
services.webserver = { pkgs, lib, ... }: {
|
||||
nixos.useSystemd = true;
|
||||
nixos.configuration.boot.tmpOnTmpfs = true;
|
||||
nixos.configuration.boot.tmp.useTmpfs = true;
|
||||
nixos.configuration.services.nginx.enable = true;
|
||||
nixos.configuration.services.nginx.virtualHosts.localhost.root = "${pkgs.nix.doc}/share/doc/nix/manual";
|
||||
nixos.configuration.services.nscd.enable = false;
|
||||
nixos.configuration.system.nssModules = lib.mkForce [];
|
||||
nixos.configuration.systemd.services.nginx.serviceConfig.AmbientCapabilities =
|
||||
lib.mkForce [ "CAP_NET_BIND_SERVICE" ];
|
||||
service.useHostStore = true;
|
||||
service.ports = [
|
||||
"8000:80" # host:container
|
||||
];
|
||||
};
|
||||
}
|
||||
```
|
||||
----
|
||||
|
||||
==== Docker image from DockerHub
|
||||
|
||||
|
@ -195,6 +175,11 @@ Describe containers using NixOS-style modules. There are a few options:
|
|||
}
|
||||
```
|
||||
|
||||
==== NixOS: run only one systemd service
|
||||
|
||||
Running individual units from NixOS is possible using an experimental script.
|
||||
See `examples/nixos-unit/arion-compose.nix`.
|
||||
|
||||
=== Run
|
||||
|
||||
Start containers and watch their logs:
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// To update option descriptions
|
||||
// - use git grep or github search
|
||||
// - or browse through src/nix/modules
|
||||
# Arion Options
|
||||
|
||||
include::partial$NixOSOptions.adoc[]
|
||||
include::partial$arion-options.adoc[]
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,8 @@
|
|||
project.name = "full-nixos";
|
||||
services.webserver = { pkgs, lib, ... }: {
|
||||
nixos.useSystemd = true;
|
||||
nixos.configuration.boot.tmpOnTmpfs = true;
|
||||
nixos.configuration.boot.tmp.useTmpfs = true;
|
||||
nixos.configuration.networking.useDHCP = false;
|
||||
nixos.configuration.services.nginx.enable = true;
|
||||
nixos.configuration.services.nginx.virtualHosts.localhost.root = "${pkgs.nix.doc}/share/doc/nix/manual";
|
||||
nixos.configuration.services.nscd.enable = false;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
config.project.name = "webapp";
|
||||
config.services = {
|
||||
project.name = "webapp";
|
||||
services = {
|
||||
|
||||
webserver = {
|
||||
image.enableRecommendedContents = true;
|
||||
|
|
|
@ -10,6 +10,17 @@
|
|||
*/
|
||||
{ lib, pkgs, ... }: {
|
||||
config.project.name = "traefik";
|
||||
config.networks = {
|
||||
traefik-custom = {
|
||||
name = "traefik-custom";
|
||||
ipam = {
|
||||
config = [{
|
||||
subnet = "172.32.0.0/16";
|
||||
gateway = "172.32.0.1";
|
||||
}];
|
||||
};
|
||||
};
|
||||
};
|
||||
config.services = {
|
||||
traefik = {
|
||||
image.command = [
|
||||
|
@ -24,6 +35,7 @@
|
|||
stop_signal = "SIGINT";
|
||||
ports = [ "80:80" "8080:8080" ];
|
||||
volumes = [ "/var/run/docker.sock:/var/run/docker.sock:ro" ];
|
||||
networks = [ "traefik-custom" ];
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -34,14 +46,17 @@
|
|||
${pkgs.python3}/bin/python -m http.server
|
||||
''}"];
|
||||
service.container_name = "simple-service";
|
||||
service.ports = [
|
||||
"8000:8000" # host:container
|
||||
];
|
||||
service.stop_signal = "SIGINT";
|
||||
service.labels = {
|
||||
"traefik.enable" = "true";
|
||||
"traefik.http.routers.nix-docs.rule" = "Host(`nix-docs.localhost`)";
|
||||
"traefik.http.routers.nix-docs.entrypoints" = "web";
|
||||
"traefik.http.services.nix-docs.loadBalancer.server.port" = "8000";
|
||||
};
|
||||
service.networks = {
|
||||
traefik-custom = {
|
||||
ipv4_address = "172.32.0.5";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
64
flake.lock
generated
64
flake.lock
generated
|
@ -7,47 +7,88 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1669931201,
|
||||
"narHash": "sha256-UnYFeaLPLj7e4eEt4GJooeJZhaZXyloQZYinwO/CeUw=",
|
||||
"lastModified": 1722555600,
|
||||
"narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "995d6bc162c0539998ef6375c2c6b612972dc016",
|
||||
"rev": "8471fe90ad337a8074e957b69ca4d0089218391d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"ref": "easyOverlay",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts_2": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": [
|
||||
"hercules-ci-effects",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1712014858,
|
||||
"narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "9126214d0a59633752a136528f5f3b9aa8565b7d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "flake-parts",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"haskell-flake": {
|
||||
"locked": {
|
||||
"lastModified": 1668167720,
|
||||
"narHash": "sha256-5wDTR6xt9BB3BjgKR+YOjOkZgMyDXKaX79g42sStzDU=",
|
||||
"lastModified": 1675296942,
|
||||
"narHash": "sha256-u1X1sblozi5qYEcLp1hxcyo8FfDHnRUVX3dJ/tW19jY=",
|
||||
"owner": "srid",
|
||||
"repo": "haskell-flake",
|
||||
"rev": "4fc511d93a55fedf815c1647ad146c26d7a2054e",
|
||||
"rev": "c2cafce9d57bfca41794dc3b99c593155006c71e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "srid",
|
||||
"ref": "0.1.0",
|
||||
"repo": "haskell-flake",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"hercules-ci-effects": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts_2",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1719226092,
|
||||
"narHash": "sha256-YNkUMcCUCpnULp40g+svYsaH1RbSEj6s4WdZY/SHe38=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "hercules-ci-effects",
|
||||
"rev": "11e4b8dc112e2f485d7c97e1cee77f9958f498f5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "hercules-ci-effects",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1669980218,
|
||||
"narHash": "sha256-HBK1tIqarj7ZsSwQEKGlyvbAIFnglytG7FxuS4K3nY8=",
|
||||
"lastModified": 1722630782,
|
||||
"narHash": "sha256-hMyG9/WlUi0Ho9VkRrrez7SeNlDzLxalm9FwY7n/Noo=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "da7988fe440ef5b8779d4f76340ad7dc79ff3b33",
|
||||
"rev": "d04953086551086b44b6f3c6b7eeb26294f207da",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "haskell-updates",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
|
@ -56,6 +97,7 @@
|
|||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"haskell-flake": "haskell-flake",
|
||||
"hercules-ci-effects": "hercules-ci-effects",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
|
|
40
flake.nix
40
flake.nix
|
@ -2,16 +2,19 @@
|
|||
description = "Arion - use Docker Compose via Nix";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/haskell-updates";
|
||||
haskell-flake.url = "github:srid/haskell-flake";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts/easyOverlay"; # TODO merge
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
haskell-flake.url = "github:srid/haskell-flake/0.1.0";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||
hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects";
|
||||
hercules-ci-effects.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = inputs@{ self, flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit self; } ({ config, lib, extendModules, ... }: {
|
||||
flake-parts.lib.mkFlake { inherit inputs; } ({ config, lib, extendModules, ... }: {
|
||||
imports = [
|
||||
inputs.haskell-flake.flakeModule
|
||||
inputs.hercules-ci-effects.flakeModule
|
||||
inputs.flake-parts.flakeModules.easyOverlay
|
||||
./docs/flake-module.nix
|
||||
./tests/flake-module.nix
|
||||
|
@ -63,15 +66,26 @@
|
|||
];
|
||||
});
|
||||
};
|
||||
|
||||
hercules-ci.flake-update = {
|
||||
enable = true;
|
||||
autoMergeMethod = "merge";
|
||||
when = {
|
||||
hour = [ 2 ];
|
||||
dayOfMonth = [ 5 ];
|
||||
};
|
||||
};
|
||||
|
||||
herculesCI.ciSystems = [
|
||||
# "aarch64-darwin"
|
||||
# "aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"x86_64-linux"
|
||||
];
|
||||
|
||||
flake = {
|
||||
debug = { inherit inputs config lib; };
|
||||
|
||||
defaultPackage =
|
||||
lib.mapAttrs
|
||||
(ps: lib.warn "arion.defaultPackage has been removed in favor of arion.packages.\${system}.default"
|
||||
ps.default)
|
||||
config.flake.packages;
|
||||
|
||||
lib = {
|
||||
eval = import ./src/nix/eval-composition.nix;
|
||||
build = args@{ ... }:
|
||||
|
@ -79,12 +93,6 @@
|
|||
in composition.config.out.dockerComposeYaml;
|
||||
};
|
||||
nixosModules.arion = ./nixos-module.nix;
|
||||
herculesCI.ciSystems = [
|
||||
# "aarch64-darwin"
|
||||
# "aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"x86_64-linux"
|
||||
];
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, options, pkgs, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
attrValues
|
||||
|
@ -26,9 +26,14 @@ let
|
|||
visible = "shallow";
|
||||
};
|
||||
_systemd = mkOption { internal = true; };
|
||||
serviceName = mkOption {
|
||||
description = "The name of the Arion project's systemd service";
|
||||
type = types.str;
|
||||
default = "arion-${name}";
|
||||
};
|
||||
};
|
||||
config = {
|
||||
_systemd.services."arion-${name}" = {
|
||||
_systemd.services.${config.serviceName} = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "sockets.target" ];
|
||||
|
||||
|
@ -46,7 +51,7 @@ let
|
|||
};
|
||||
|
||||
arionSettingsType = name:
|
||||
(cfg.package.eval { modules = [ { project.name = lib.mkDefault name; } ]; }).type or (
|
||||
(cfg.package.eval { modules = [{ project.name = lib.mkDefault name; }]; }).type or (
|
||||
throw "lib.evalModules did not produce a type. Please upgrade Nixpkgs to nixos-unstable or >=nixos-21.11"
|
||||
);
|
||||
|
||||
|
@ -64,7 +69,7 @@ in
|
|||
};
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
|
||||
|
||||
default = (import ./. { inherit pkgs; }).arion;
|
||||
description = ''
|
||||
Arion package to use. This will provide <literal>arion</literal>
|
||||
|
@ -97,7 +102,10 @@ in
|
|||
virtualisation.docker.enable = false;
|
||||
virtualisation.podman.enable = true;
|
||||
virtualisation.podman.dockerSocket.enable = true;
|
||||
virtualisation.podman.defaultNetwork.dnsname.enable = true;
|
||||
virtualisation.podman.defaultNetwork =
|
||||
if options?virtualisation.podman.defaultNetwork.settings
|
||||
then { settings.dns_enabled = true; } # since 2023-01 https://github.com/NixOS/nixpkgs/pull/199965
|
||||
else { dnsname.enable = true; }; # compat <2023
|
||||
|
||||
virtualisation.arion.docker.client.package = pkgs.docker-client;
|
||||
})
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
# For manual testing of a hacked arion built via Nix.
|
||||
# Works when called from outside the project directory.
|
||||
|
||||
exec nix run -f "$(dirname ${BASH_SOURCE[0]})" arion -c arion "$@"
|
||||
exec nix run -f "$(dirname ${BASH_SOURCE[0]})" arion "$@"
|
||||
|
|
|
@ -13,19 +13,34 @@ import qualified Data.Text as T
|
|||
import qualified Data.Text.IO as T
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "evaluateComposition" $ it "matches an example" $ do
|
||||
x <- Arion.Nix.evaluateComposition EvaluationArgs
|
||||
{ evalUid = 123
|
||||
, evalModules = NEL.fromList
|
||||
["src/haskell/testdata/Arion/NixSpec/arion-compose.nix"]
|
||||
, evalPkgs = "import <nixpkgs> { system = \"x86_64-linux\"; }"
|
||||
, evalWorkDir = Nothing
|
||||
, evalMode = ReadOnly
|
||||
, evalUserArgs = ["--show-trace"]
|
||||
}
|
||||
let actual = pretty x
|
||||
expected <- T.readFile "src/haskell/testdata/Arion/NixSpec/arion-compose.json"
|
||||
censorPaths actual `shouldBe` censorPaths expected
|
||||
spec = describe "evaluateComposition" $ do
|
||||
it "matches an example" $ do
|
||||
x <- Arion.Nix.evaluateComposition EvaluationArgs
|
||||
{ evalUid = 123
|
||||
, evalModules = NEL.fromList
|
||||
["src/haskell/testdata/Arion/NixSpec/arion-compose.nix"]
|
||||
, evalPkgs = "import <nixpkgs> { system = \"x86_64-linux\"; }"
|
||||
, evalWorkDir = Nothing
|
||||
, evalMode = ReadOnly
|
||||
, evalUserArgs = ["--show-trace"]
|
||||
}
|
||||
let actual = pretty x
|
||||
expected <- T.readFile "src/haskell/testdata/Arion/NixSpec/arion-compose.json"
|
||||
censorPaths actual `shouldBe` censorPaths expected
|
||||
|
||||
it "matches an build.context example" $ do
|
||||
x <- Arion.Nix.evaluateComposition EvaluationArgs
|
||||
{ evalUid = 1234
|
||||
, evalModules = NEL.fromList
|
||||
["src/haskell/testdata/Arion/NixSpec/arion-context-compose.nix"]
|
||||
, evalPkgs = "import <nixpkgs> { system = \"x86_64-linux\"; }"
|
||||
, evalWorkDir = Nothing
|
||||
, evalMode = ReadOnly
|
||||
, evalUserArgs = ["--show-trace"]
|
||||
}
|
||||
let actual = pretty x
|
||||
expected <- T.readFile "src/haskell/testdata/Arion/NixSpec/arion-context-compose.json"
|
||||
censorPaths actual `shouldBe` censorPaths expected
|
||||
|
||||
censorPaths :: Text -> Text
|
||||
censorPaths = censorImages . censorStorePaths
|
||||
|
|
|
@ -9,3 +9,4 @@ import qualified Arion.NixSpec
|
|||
spec :: Spec
|
||||
spec = do
|
||||
describe "Arion.Nix" Arion.NixSpec.spec
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
}
|
||||
},
|
||||
"version": "3.4",
|
||||
"volumes": {},
|
||||
"x-arion": {
|
||||
"images": [
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
project.name = "unit-test-data";
|
||||
services.webserver = { pkgs, ... }: {
|
||||
nixos.useSystemd = true;
|
||||
nixos.configuration.boot.tmpOnTmpfs = true;
|
||||
nixos.configuration.boot.tmp.useTmpfs = true;
|
||||
nixos.configuration.services.nginx.enable = true;
|
||||
nixos.configuration.services.nginx.virtualHosts.localhost.root = "${pkgs.nix.doc}/share/doc/nix/manual";
|
||||
service.useHostStore = true;
|
||||
|
|
41
src/haskell/testdata/Arion/NixSpec/arion-context-compose.json
vendored
Normal file
41
src/haskell/testdata/Arion/NixSpec/arion-context-compose.json
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"networks": {
|
||||
"default": {
|
||||
"name": "unit-test-data"
|
||||
}
|
||||
},
|
||||
"services": {
|
||||
"webserver": {
|
||||
"build": {
|
||||
"context": "<STOREPATH>"
|
||||
},
|
||||
"environment": {},
|
||||
"ports": [
|
||||
"8080:80"
|
||||
],
|
||||
"sysctls": {},
|
||||
"volumes": []
|
||||
}
|
||||
},
|
||||
"version": "3.4",
|
||||
"volumes": {},
|
||||
"x-arion": {
|
||||
"images": [
|
||||
{
|
||||
"imageExe": "<STOREPATH>",
|
||||
"imageName": "localhost/webserver",
|
||||
"imageTag": "<HASH>"
|
||||
}
|
||||
],
|
||||
"project": {
|
||||
"name": "unit-test-data"
|
||||
},
|
||||
"serviceInfo": {
|
||||
"webserver": {
|
||||
"defaultExec": [
|
||||
"/bin/sh"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
9
src/haskell/testdata/Arion/NixSpec/arion-context-compose.nix
vendored
Normal file
9
src/haskell/testdata/Arion/NixSpec/arion-context-compose.nix
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
project.name = "unit-test-data";
|
||||
services.webserver.service = {
|
||||
build.context = "${./build-context}";
|
||||
ports = [
|
||||
"8080:80"
|
||||
];
|
||||
};
|
||||
}
|
4
src/haskell/testdata/Arion/NixSpec/build-context/Dockerfile
vendored
Normal file
4
src/haskell/testdata/Arion/NixSpec/build-context/Dockerfile
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
FROM nginx
|
||||
|
||||
RUN echo this is a dockerfile to be built
|
||||
|
|
@ -1,16 +1,21 @@
|
|||
{ lib }:
|
||||
let
|
||||
|
||||
link = url: text:
|
||||
''link:${url}[${text}]'';
|
||||
link = url: text: ''[${text}](${url})'';
|
||||
|
||||
dockerComposeRef = fragment:
|
||||
''See ${link "https://docs.docker.com/compose/compose-file/#${fragment}" "Docker Compose#${fragment}"}'';
|
||||
composeSpecRev = "55b450aee50799a2f33cc99e1d714518babe305e";
|
||||
|
||||
serviceRef = fragment:
|
||||
''See ${link "https://github.com/compose-spec/compose-spec/blob/${composeSpecRev}/05-services.md#${fragment}" "Compose Spec Services #${fragment}"}'';
|
||||
|
||||
networkRef = fragment:
|
||||
''See ${link "https://github.com/compose-spec/compose-spec/blob/${composeSpecRev}/06-networks.md#${fragment}" "Compose Spec Networks #${fragment}"}'';
|
||||
|
||||
in
|
||||
{
|
||||
inherit
|
||||
dockerComposeRef
|
||||
link
|
||||
networkRef
|
||||
serviceRef
|
||||
;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ let
|
|||
inherit (lib) types mkOption;
|
||||
|
||||
link = url: text:
|
||||
''link:${url}[${text}]'';
|
||||
''[${text}](${url})'';
|
||||
|
||||
in
|
||||
{
|
||||
|
|
|
@ -63,6 +63,11 @@ in
|
|||
type = lib.types.attrsOf (lib.types.submodule service);
|
||||
description = "An attribute set of service configurations. A service specifies how to run an image as a container.";
|
||||
};
|
||||
docker-compose.volumes = lib.mkOption {
|
||||
type = lib.types.attrsOf lib.types.unspecified;
|
||||
description = "A attribute set of volume configurations.";
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
config = {
|
||||
out.dockerComposeYaml = pkgs.writeText "docker-compose.yaml" config.out.dockerComposeYamlText;
|
||||
|
@ -73,6 +78,7 @@ in
|
|||
version = "3.4";
|
||||
services = lib.mapAttrs (k: c: c.out.service) config.services;
|
||||
x-arion = config.docker-compose.extended;
|
||||
volumes = config.docker-compose.volumes;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
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.
|
||||
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`.
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ in
|
|||
build.imagesToLoad = lib.mkOption {
|
||||
type = listOf unspecified;
|
||||
internal = true;
|
||||
description = "List of dockerTools image derivations.";
|
||||
description = "List of `dockerTools` image derivations.";
|
||||
};
|
||||
};
|
||||
config = {
|
||||
|
|
|
@ -7,7 +7,7 @@ let
|
|||
types
|
||||
;
|
||||
inherit (import ../../lib.nix { inherit lib; })
|
||||
dockerComposeRef
|
||||
link
|
||||
;
|
||||
in
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ in
|
|||
];
|
||||
});
|
||||
description = ''
|
||||
${dockerComposeRef "networks-top-level-element"}
|
||||
See ${link "https://docs.docker.com/compose/compose-file/06-networks/" "Docker Compose Networks"}
|
||||
'';
|
||||
};
|
||||
enableDefaultNetwork = mkOption {
|
||||
|
|
|
@ -7,7 +7,7 @@ let
|
|||
types
|
||||
;
|
||||
inherit (import ../../lib.nix { inherit lib; })
|
||||
dockerComposeRef
|
||||
networkRef
|
||||
;
|
||||
in
|
||||
{
|
||||
|
@ -15,21 +15,21 @@ in
|
|||
driver = mkOption {
|
||||
description = ''
|
||||
`"none"`, `"host"`, or a platform-specific value.
|
||||
${dockerComposeRef "driver"}
|
||||
${networkRef "driver"}
|
||||
'';
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
driver_opts = mkOption {
|
||||
description = ''
|
||||
${dockerComposeRef "driver_opts"}
|
||||
${networkRef "driver_opts"}
|
||||
'';
|
||||
type = types.lazyAttrsOf types.raw or types.unspecified;
|
||||
};
|
||||
|
||||
attachable = mkOption {
|
||||
description = ''
|
||||
${dockerComposeRef "attachable"}
|
||||
${networkRef "attachable"}
|
||||
'';
|
||||
type = types.bool;
|
||||
example = true;
|
||||
|
@ -39,7 +39,7 @@ in
|
|||
description = ''
|
||||
Whether we've entered the 21st century yet.
|
||||
|
||||
${dockerComposeRef "enable_ipv6"}
|
||||
${networkRef "enable_ipv6"}
|
||||
'';
|
||||
type = types.bool;
|
||||
};
|
||||
|
@ -49,7 +49,7 @@ in
|
|||
description = ''
|
||||
Manage IP addresses.
|
||||
|
||||
${dockerComposeRef "ipam"}
|
||||
${networkRef "ipam"}
|
||||
'';
|
||||
type = types.raw or types.unspecified;
|
||||
};
|
||||
|
@ -58,7 +58,7 @@ in
|
|||
description = ''
|
||||
Achieves "external isolation".
|
||||
|
||||
${dockerComposeRef "internal"}
|
||||
${networkRef "internal"}
|
||||
'';
|
||||
defaultText = false;
|
||||
type = types.bool;
|
||||
|
@ -68,7 +68,7 @@ in
|
|||
description = ''
|
||||
Metadata.
|
||||
|
||||
${dockerComposeRef "labels"}
|
||||
${networkRef "labels"}
|
||||
'';
|
||||
# no list support, because less expressive wrt overriding
|
||||
type = types.attrsOf types.str;
|
||||
|
@ -79,7 +79,7 @@ in
|
|||
When `true`, don't create or destroy the network, but assume that it
|
||||
exists.
|
||||
|
||||
${dockerComposeRef "external"}
|
||||
${networkRef "external"}
|
||||
'';
|
||||
type = types.bool;
|
||||
};
|
||||
|
@ -92,7 +92,7 @@ in
|
|||
|
||||
Note the `default` network's default `name` is set to `project.name` by Arion.
|
||||
|
||||
${dockerComposeRef "name"}
|
||||
${networkRef "name"}
|
||||
'';
|
||||
type = types.str;
|
||||
};
|
||||
|
|
|
@ -12,15 +12,9 @@ let
|
|||
|
||||
inherit (import ../../lib.nix { inherit lib; })
|
||||
link
|
||||
dockerComposeRef
|
||||
serviceRef
|
||||
;
|
||||
|
||||
dockerComposeKitchenSink = ''
|
||||
Analogous to the `docker run` counterpart.
|
||||
|
||||
${dockerComposeRef "domainname-hostname-ipc-mac_address-privileged-read_only-shm_size-stdin_open-tty-user-working_dir"}
|
||||
'';
|
||||
|
||||
cap_add = lib.attrNames (lib.filterAttrs (name: value: value == true) config.service.capabilities);
|
||||
cap_drop = lib.attrNames (lib.filterAttrs (name: value: value == false) config.service.capabilities);
|
||||
|
||||
|
@ -56,12 +50,12 @@ in
|
|||
service.volumes = mkOption {
|
||||
type = listOf types.unspecified;
|
||||
default = [];
|
||||
description = dockerComposeRef "volumes";
|
||||
description = serviceRef "volumes";
|
||||
};
|
||||
service.tmpfs = mkOption {
|
||||
type = listOf types.str;
|
||||
default = [];
|
||||
description = dockerComposeRef "tmpfs";
|
||||
description = serviceRef "tmpfs";
|
||||
};
|
||||
service.build.context = mkOption {
|
||||
type = nullOr str;
|
||||
|
@ -69,44 +63,65 @@ in
|
|||
description = ''
|
||||
Locates a Dockerfile to use for creating an image to use in this service.
|
||||
|
||||
${dockerComposeRef "context"}
|
||||
https://docs.docker.com/compose/compose-file/build/#context
|
||||
'';
|
||||
};
|
||||
service.build.dockerfile = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
Sets an alternate Dockerfile. A relative path is resolved from the build context.
|
||||
https://docs.docker.com/compose/compose-file/build/#dockerfile
|
||||
'';
|
||||
};
|
||||
service.build.target = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
Defines the stage to build as defined inside a multi-stage Dockerfile.
|
||||
https://docs.docker.com/compose/compose-file/build/#target
|
||||
'';
|
||||
};
|
||||
service.hostname = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = dockerComposeKitchenSink;
|
||||
description = ''
|
||||
${serviceRef "hostname"}
|
||||
'';
|
||||
};
|
||||
service.tty = mkOption {
|
||||
type = nullOr bool;
|
||||
default = null;
|
||||
description = dockerComposeKitchenSink;
|
||||
description = ''
|
||||
${serviceRef "tty"}
|
||||
'';
|
||||
};
|
||||
service.environment = mkOption {
|
||||
type = attrsOf (either str int);
|
||||
default = {};
|
||||
description = dockerComposeRef "environment";
|
||||
description = serviceRef "environment";
|
||||
};
|
||||
service.image = mkOption {
|
||||
type = str;
|
||||
description = dockerComposeRef "image";
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = serviceRef "image";
|
||||
};
|
||||
service.command = mkOption {
|
||||
type = nullOr types.unspecified;
|
||||
default = null;
|
||||
description = dockerComposeRef "command";
|
||||
description = serviceRef "command";
|
||||
};
|
||||
service.container_name = mkOption {
|
||||
type = nullOr types.str;
|
||||
default = null;
|
||||
description = dockerComposeRef "container_name";
|
||||
description = serviceRef "container_name";
|
||||
};
|
||||
service.depends_on =
|
||||
let conditionsModule = {
|
||||
options = {
|
||||
condition = mkOption {
|
||||
type = enum ["service_started" "service_healthy" "service_completed_successfully"];
|
||||
description = dockerComposeRef "depends_on";
|
||||
description = serviceRef "depends_on";
|
||||
default = "service_started";
|
||||
};
|
||||
};
|
||||
|
@ -114,10 +129,10 @@ in
|
|||
in mkOption {
|
||||
type = either (listOf str) (attrsOf (submodule conditionsModule));
|
||||
default = [];
|
||||
description = dockerComposeRef "depends_on";
|
||||
description = serviceRef "depends_on";
|
||||
};
|
||||
service.healthcheck = mkOption {
|
||||
description = dockerComposeRef "healthcheck";
|
||||
description = serviceRef "healthcheck";
|
||||
type = submodule ({ config, options, ...}: {
|
||||
options = {
|
||||
_out = mkOption {
|
||||
|
@ -130,30 +145,30 @@ in
|
|||
type = nullOr (listOf str);
|
||||
default = null;
|
||||
example = [ "CMD" "pg_isready" ];
|
||||
description = dockerComposeRef "healthcheck";
|
||||
description = serviceRef "healthcheck";
|
||||
};
|
||||
interval = mkOption {
|
||||
type = str;
|
||||
default = "30s";
|
||||
example = "1m";
|
||||
description = dockerComposeRef "healthcheck";
|
||||
description = serviceRef "healthcheck";
|
||||
};
|
||||
timeout = mkOption {
|
||||
type = str;
|
||||
default = "30s";
|
||||
example = "10s";
|
||||
description = dockerComposeRef "healthcheck";
|
||||
description = serviceRef "healthcheck";
|
||||
};
|
||||
start_period = mkOption {
|
||||
type = str;
|
||||
default = "0s";
|
||||
example = "30s";
|
||||
description = dockerComposeRef "healthcheck";
|
||||
description = serviceRef "healthcheck";
|
||||
};
|
||||
retries = mkOption {
|
||||
type = int;
|
||||
default = 3;
|
||||
description = dockerComposeRef "healthcheck";
|
||||
description = serviceRef "healthcheck";
|
||||
};
|
||||
};
|
||||
});
|
||||
|
@ -165,14 +180,14 @@ in
|
|||
See ${link "https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities"
|
||||
"`docker run --device` documentation"}
|
||||
|
||||
${dockerComposeRef "devices"}
|
||||
${serviceRef "devices"}
|
||||
'';
|
||||
};
|
||||
service.dns = mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
example = [ "8.8.8.8" "8.8.4.4" ];
|
||||
description = dockerComposeRef "dns";
|
||||
description = serviceRef "dns";
|
||||
};
|
||||
service.labels = mkOption {
|
||||
type = attrsOf str;
|
||||
|
@ -183,47 +198,58 @@ in
|
|||
"traefik.http.routers.my-service.rule" = "Host(`my-service.localhost`)";
|
||||
"traefik.http.routers.my-service.entrypoints" = "web";
|
||||
};
|
||||
description = dockerComposeRef "labels";
|
||||
description = serviceRef "labels";
|
||||
};
|
||||
service.links = mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = dockerComposeRef "links";
|
||||
description = serviceRef "links";
|
||||
};
|
||||
service.external_links = mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = dockerComposeRef "external_links";
|
||||
description = serviceRef "external_links";
|
||||
};
|
||||
service.profiles = mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = serviceRef "profiles";
|
||||
};
|
||||
service.extra_hosts = mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = dockerComposeRef "extra_hosts";
|
||||
description = serviceRef "extra_hosts";
|
||||
};
|
||||
service.working_dir = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = dockerComposeKitchenSink;
|
||||
description = ''
|
||||
${serviceRef "working_dir"}
|
||||
'';
|
||||
};
|
||||
service.privileged = mkOption {
|
||||
type = nullOr bool;
|
||||
default = null;
|
||||
description = dockerComposeKitchenSink;
|
||||
description = ''
|
||||
${serviceRef "privileged"}
|
||||
'';
|
||||
};
|
||||
service.entrypoint = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = dockerComposeRef "entrypoint";
|
||||
description = serviceRef "entrypoint";
|
||||
};
|
||||
service.restart = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = dockerComposeRef "restart";
|
||||
description = serviceRef "restart";
|
||||
};
|
||||
service.user = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = dockerComposeKitchenSink;
|
||||
description = ''
|
||||
${serviceRef "user"}
|
||||
'';
|
||||
};
|
||||
service.ports = mkOption {
|
||||
type = listOf types.unspecified;
|
||||
|
@ -231,38 +257,76 @@ in
|
|||
description = ''
|
||||
Expose ports on host. "host:container" or structured.
|
||||
|
||||
${dockerComposeRef "ports"}
|
||||
${serviceRef "ports"}
|
||||
'';
|
||||
};
|
||||
service.expose = mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = dockerComposeRef "expose";
|
||||
description = serviceRef "expose";
|
||||
};
|
||||
service.env_file = mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = dockerComposeRef "env_file";
|
||||
description = serviceRef "env_file";
|
||||
};
|
||||
service.network_mode = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = dockerComposeRef "network_mode";
|
||||
};
|
||||
service.networks = mkOption {
|
||||
type = nullOr (listOf types.str);
|
||||
default = null;
|
||||
description = dockerComposeRef "networks";
|
||||
description = serviceRef "network_mode";
|
||||
};
|
||||
service.networks =
|
||||
let
|
||||
networksModule = submodule ({ config, options, ...}: {
|
||||
options = {
|
||||
_out = mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
default = lib.mapAttrs (k: opt: opt.value) (lib.filterAttrs (_: opt: opt.isDefined) { inherit (options) aliases ipv4_address ipv6_address link_local_ips priority; });
|
||||
};
|
||||
aliases = mkOption {
|
||||
type = listOf str;
|
||||
description = serviceRef "aliases";
|
||||
default = [ ];
|
||||
};
|
||||
ipv4_address = mkOption {
|
||||
type = str;
|
||||
description = serviceRef "ipv4_address-ipv6_address";
|
||||
};
|
||||
ipv6_address = mkOption {
|
||||
type = str;
|
||||
description = serviceRef "ipv4_address-ipv6_address";
|
||||
};
|
||||
link_local_ips = mkOption {
|
||||
type = listOf str;
|
||||
description = serviceRef "link_local_ips";
|
||||
};
|
||||
priority = mkOption {
|
||||
type = int;
|
||||
description = serviceRef "priority";
|
||||
};
|
||||
};
|
||||
});
|
||||
in
|
||||
mkOption {
|
||||
type = either (listOf str) (attrsOf networksModule);
|
||||
default = [];
|
||||
description = serviceRef "networks";
|
||||
};
|
||||
service.stop_signal = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = dockerComposeRef "stop_signal";
|
||||
description = serviceRef "stop_signal";
|
||||
};
|
||||
service.stop_grace_period = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = serviceRef "stop_grace_period";
|
||||
};
|
||||
service.sysctls = mkOption {
|
||||
type = attrsOf (either str int);
|
||||
default = {};
|
||||
description = dockerComposeRef "sysctls";
|
||||
description = serviceRef "sysctls";
|
||||
};
|
||||
service.capabilities = mkOption {
|
||||
type = attrsOf (nullOr bool);
|
||||
|
@ -273,13 +337,15 @@ in
|
|||
|
||||
Setting a capability to `true` means that it will be
|
||||
"added". Setting it to `false` means that it will be "dropped".
|
||||
${dockerComposeRef "cap_add-cap_drop"}
|
||||
|
||||
Omitted and `null` capabilities will therefore be set
|
||||
according to Docker's ${
|
||||
link "https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities"
|
||||
"default list of capabilities."
|
||||
}
|
||||
|
||||
${serviceRef "cap_add"}
|
||||
${serviceRef "cap_drop"}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
@ -289,10 +355,11 @@ in
|
|||
volumes
|
||||
environment
|
||||
sysctls
|
||||
image
|
||||
;
|
||||
} // lib.optionalAttrs (config.service.build.context != null) {
|
||||
inherit (config.service) build;
|
||||
} // lib.optionalAttrs (config.service.image != null) {
|
||||
inherit (config.service) image;
|
||||
} // lib.optionalAttrs (config.service.build.context != null ) {
|
||||
build = lib.filterAttrs (n: v: v != null) config.service.build;
|
||||
} // lib.optionalAttrs (cap_add != []) {
|
||||
inherit cap_add;
|
||||
} // lib.optionalAttrs (cap_drop != []) {
|
||||
|
@ -331,12 +398,16 @@ in
|
|||
inherit (config.service) privileged;
|
||||
} // lib.optionalAttrs (config.service.network_mode != null) {
|
||||
inherit (config.service) network_mode;
|
||||
} // lib.optionalAttrs (config.service.networks != null) {
|
||||
inherit (config.service) networks;
|
||||
} // lib.optionalAttrs (config.service.networks != [] && config.service.networks != {}) {
|
||||
networks =
|
||||
if (builtins.isAttrs config.service.networks) then builtins.mapAttrs (_: v: v._out) config.service.networks
|
||||
else config.service.networks;
|
||||
} // lib.optionalAttrs (config.service.restart != null) {
|
||||
inherit (config.service) restart;
|
||||
} // lib.optionalAttrs (config.service.stop_signal != null) {
|
||||
inherit (config.service) stop_signal;
|
||||
} // lib.optionalAttrs (config.service.stop_grace_period != null) {
|
||||
inherit (config.service) stop_grace_period;
|
||||
} // lib.optionalAttrs (config.service.tmpfs != []) {
|
||||
inherit (config.service) tmpfs;
|
||||
} // lib.optionalAttrs (config.service.tty != null) {
|
||||
|
@ -345,5 +416,7 @@ in
|
|||
inherit (config.service) working_dir;
|
||||
} // lib.optionalAttrs (config.service.user != null) {
|
||||
inherit (config.service) user;
|
||||
} // lib.optionalAttrs (config.service.profiles != []) {
|
||||
inherit (config.service) profiles;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ in
|
|||
type = attrsOf unspecified;
|
||||
description = ''
|
||||
Information about a service to include in the Docker Compose file,
|
||||
but that will not be used by the `docker-compose`> command
|
||||
but that will not be used by the `docker-compose` command
|
||||
itself.
|
||||
|
||||
It will be inserted in `x-arion.serviceInfo.<service.name>`.
|
||||
|
|
|
@ -20,7 +20,7 @@ in
|
|||
service.hostStoreAsReadOnly = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Adds a ':ro' (read-only) access mode to the host nix store bind mount.";
|
||||
description = "Adds a `:ro` (read-only) access mode to the host nix store bind mount.";
|
||||
};
|
||||
service.useHostNixDaemon = mkOption {
|
||||
type = types.bool;
|
||||
|
|
|
@ -30,6 +30,7 @@ let
|
|||
{
|
||||
name = null; tag = null; contents = null; config = null;
|
||||
created = null; extraCommands = null; maxLayers = null;
|
||||
fakeRootCommands = null;
|
||||
}
|
||||
args;
|
||||
acceptedArgs = functionArgs dockerTools.streamLayeredImage;
|
||||
|
@ -67,6 +68,8 @@ let
|
|||
ln -s $i nix/var/nix/gcroots/docker/$(basename $i)
|
||||
done;
|
||||
'';
|
||||
|
||||
fakeRootCommands = config.image.fakeRootCommands;
|
||||
};
|
||||
|
||||
priorityIsDefault = option: option.highestPrio >= (lib.mkDefault true).priority;
|
||||
|
@ -76,18 +79,18 @@ in
|
|||
build.image = mkOption {
|
||||
type = nullOr package;
|
||||
description = ''
|
||||
Docker image derivation to be `docker load`ed.
|
||||
Docker image derivation to be `docker load`-ed.
|
||||
'';
|
||||
internal = true;
|
||||
};
|
||||
build.imageName = mkOption {
|
||||
type = str;
|
||||
description = "Derived from build.image";
|
||||
description = "Derived from `build.image`";
|
||||
internal = true;
|
||||
};
|
||||
build.imageTag = mkOption {
|
||||
type = str;
|
||||
description = "Derived from build.image";
|
||||
description = "Derived from `build.image`";
|
||||
internal = true;
|
||||
};
|
||||
image.nixBuild = mkOption {
|
||||
|
@ -120,13 +123,22 @@ in
|
|||
Top level paths in the container.
|
||||
'';
|
||||
};
|
||||
image.fakeRootCommands = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Commands that build the root of the container in the current working directory.
|
||||
|
||||
See [`dockerTools.buildLayeredImage`](https://nixos.org/manual/nixpkgs/stable/#ssec-pkgs-dockerTools-buildLayeredImage).
|
||||
'';
|
||||
};
|
||||
image.includeStorePaths = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
internal = true;
|
||||
description = ''
|
||||
Include all referenced store paths. You generally want this in your
|
||||
image, unless you load store paths via some other means, like useHostStore = true;
|
||||
image, unless you load store paths via some other means, like `useHostStore = true`;
|
||||
'';
|
||||
};
|
||||
image.rawConfig = mkOption {
|
||||
|
@ -140,8 +152,8 @@ in
|
|||
Please use the specific `image` options instead.
|
||||
|
||||
Run-time configuration of the container. A full list of the
|
||||
options is available in the https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions[Docker Image Specification
|
||||
v1.2.0].
|
||||
options is available in the [Docker Image Specification
|
||||
v1.2.0](https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions).
|
||||
'';
|
||||
};
|
||||
image.command = mkOption {
|
||||
|
@ -151,17 +163,19 @@ in
|
|||
'';
|
||||
};
|
||||
};
|
||||
config = {
|
||||
build.image = builtImage;
|
||||
build.imageName = config.build.image.imageName;
|
||||
build.imageTag =
|
||||
if config.build.image.imageTag != ""
|
||||
then config.build.image.imageTag
|
||||
else lib.head (lib.strings.splitString "-" (baseNameOf config.build.image.outPath));
|
||||
|
||||
service.image = lib.mkDefault "${config.build.imageName}:${config.build.imageTag}";
|
||||
image.rawConfig.Cmd = config.image.command;
|
||||
|
||||
image.nixBuild = lib.mkDefault (priorityIsDefault options.service.image);
|
||||
};
|
||||
config = lib.mkMerge [{
|
||||
build.image = builtImage;
|
||||
build.imageName = config.build.image.imageName;
|
||||
build.imageTag =
|
||||
if config.build.image.imageTag != ""
|
||||
then config.build.image.imageTag
|
||||
else lib.head (lib.strings.splitString "-" (baseNameOf config.build.image.outPath));
|
||||
image.rawConfig.Cmd = config.image.command;
|
||||
image.nixBuild = lib.mkDefault (priorityIsDefault options.service.image);
|
||||
}
|
||||
( lib.mkIf (config.service.build.context == null)
|
||||
{
|
||||
service.image = lib.mkDefault "${config.build.imageName}:${config.build.imageTag}";
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ in
|
|||
service.tmpfs = [
|
||||
"/run" # noexec is fine because exes should be symlinked from elsewhere anyway
|
||||
"/run/wrappers" # noexec breaks this intentionally
|
||||
] ++ lib.optional (config.nixos.evaluatedConfig.boot.tmpOnTmpfs) "/tmp:exec,mode=777";
|
||||
] ++ lib.optional (config.nixos.evaluatedConfig.boot.tmp.useTmpfs) "/tmp:exec,mode=777";
|
||||
|
||||
service.stop_signal = "SIGRTMIN+3";
|
||||
service.tty = true;
|
||||
|
|
|
@ -29,17 +29,9 @@ in
|
|||
enable = true;
|
||||
dockerSocket.enable = true;
|
||||
};
|
||||
|
||||
# no caches, because no internet
|
||||
nix.binaryCaches = lib.mkForce [];
|
||||
|
||||
# FIXME: Sandbox seems broken with current version of NixOS test
|
||||
# w/ writable store. Error:
|
||||
# machine# error: linking '/nix/store/7r8z2zvhwda85pgpdn5hzzz6hs1njklc-stdenv-linux.drv.chroot/nix/store/6v3y7s4q4wd16hsw393gjpxvcf9159bv-patch-shebangs.sh' to '/nix/store/6v3y7s4q4wd16hsw393gjpxvcf9159bv-patch-shebangs.sh': Operation not permitted
|
||||
#
|
||||
# There should be no reason why arion can't run without
|
||||
# sandboxing, so please re-enable.
|
||||
nix.useSandbox = false;
|
||||
# no caches, because no internet
|
||||
nix.settings.substituters = lib.mkForce [];
|
||||
|
||||
virtualisation.writableStore = true;
|
||||
# Switch to virtualisation.additionalPaths when dropping all NixOS <= 21.05.
|
||||
|
@ -53,7 +45,7 @@ in
|
|||
pkgs.stdenv
|
||||
];
|
||||
|
||||
virtualisation.memorySize = 1024;
|
||||
virtualisation.memorySize = 2048;
|
||||
virtualisation.diskSize = 8000;
|
||||
};
|
||||
testScript = ''
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
virtualisation.arion.backend = "docker";
|
||||
};
|
||||
|
||||
nixosModuleWithPodman =
|
||||
import ./nixos-virtualization-arion-test/test.nix final {
|
||||
virtualisation.arion.backend = "podman-socket";
|
||||
};
|
||||
# Currently broken; kafka can't reach zookeeper
|
||||
# nixosModuleWithPodman =
|
||||
# import ./nixos-virtualization-arion-test/test.nix final {
|
||||
# virtualisation.arion.backend = "podman-socket";
|
||||
# };
|
||||
|
||||
testWithPodman =
|
||||
nixosTest (import ./arion-test { usePodman = true; pkgs = final; });
|
||||
|
|
|
@ -4,7 +4,7 @@ pkgs.nixosTest {
|
|||
name = "test-basic-arion-kafka";
|
||||
nodes = {
|
||||
machine = { ... }: {
|
||||
virtualisation.memorySize = 3000;
|
||||
virtualisation.memorySize = 4096;
|
||||
virtualisation.diskSize = 10000;
|
||||
imports = [
|
||||
../../nixos-module.nix
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p jq
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
cd "$(dirname ${BASH_SOURCE[0]})"
|
||||
|
||||
doc_options="$(nix build .#doc-options --json | jq -r .[].outputs.out)"
|
||||
cat "$doc_options" >docs/modules/ROOT/partials/NixOSOptions.adoc
|
Loading…
Add table
Reference in a new issue