Compare commits
55 commits
compose-sp
...
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 | ||
|
daf4aebad7 |
21 changed files with 244 additions and 66 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,3 +5,5 @@ dist/
|
||||||
dist-newstyle/
|
dist-newstyle/
|
||||||
cabal.project.local
|
cabal.project.local
|
||||||
|
|
||||||
|
*.swp
|
||||||
|
|
||||||
|
|
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -1,5 +1,18 @@
|
||||||
# Revision history for Arion
|
# 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
|
## 0.2.0.0 -- 2022-12-02
|
||||||
|
|
||||||
### BREAKING
|
### BREAKING
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
cabal-version: 2.4
|
cabal-version: 2.4
|
||||||
|
|
||||||
name: arion-compose
|
name: arion-compose
|
||||||
version: 0.2.0.0
|
version: 0.2.1.0
|
||||||
synopsis: Run docker-compose with help from Nix/NixOS
|
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.
|
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
|
homepage: https://github.com/hercules-ci/arion#readme
|
||||||
|
@ -30,7 +30,7 @@ source-repository head
|
||||||
location: https://github.com/hercules-ci/arion
|
location: https://github.com/hercules-ci/arion
|
||||||
|
|
||||||
common common
|
common common
|
||||||
build-depends: base >=4.12.0.0 && <4.17
|
build-depends: base >=4.12.0.0 && <4.99
|
||||||
, aeson >=2
|
, aeson >=2
|
||||||
, aeson-pretty
|
, aeson-pretty
|
||||||
, async
|
, async
|
||||||
|
|
|
@ -45,18 +45,21 @@ NOTE: This deployment method does NOT use an `arion-pkgs.nix` file, but reuses
|
||||||
# Pick one of:
|
# Pick one of:
|
||||||
# - niv
|
# - niv
|
||||||
((import ./nix/sources.nix).arion + "/nixos-module.nix")
|
((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
|
arion.nixosModules.arion
|
||||||
# - other
|
# - or other: copy commit hash of arion and replace HASH in:
|
||||||
arionPath + "/nixos-module.nix")
|
(builtins.fetchTarball "https://github.com/hercules-ci/arion/archive/HASH.tar.gz") + "/nixos-module.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
virtualisation.arion = {
|
virtualisation.arion = {
|
||||||
backend = "podman-socket"; # or "docker"
|
backend = "podman-socket"; # or "docker"
|
||||||
projects.example.settings = {
|
projects.example = {
|
||||||
# Specify you project here, or import it from a file.
|
serviceName = "example"; # optional systemd service name, defaults to arion-example in this case
|
||||||
# NOTE: This does NOT use ./arion-pkgs.nix, but defaults to NixOS' pkgs.
|
settings = {
|
||||||
imports = [ ./arion-compose.nix ];
|
# 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 ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ Describe containers using NixOS-style modules. There are a few options:
|
||||||
project.name = "full-nixos";
|
project.name = "full-nixos";
|
||||||
services.webserver = { pkgs, lib, ... }: {
|
services.webserver = { pkgs, lib, ... }: {
|
||||||
nixos.useSystemd = true;
|
nixos.useSystemd = true;
|
||||||
nixos.configuration.boot.tmpOnTmpfs = true;
|
nixos.configuration.boot.tmp.useTmpfs = true;
|
||||||
nixos.configuration.services.nginx.enable = true;
|
nixos.configuration.services.nginx.enable = true;
|
||||||
nixos.configuration.services.nginx.virtualHosts.localhost.root = "${pkgs.nix.doc}/share/doc/nix/manual";
|
nixos.configuration.services.nginx.virtualHosts.localhost.root = "${pkgs.nix.doc}/share/doc/nix/manual";
|
||||||
nixos.configuration.services.nscd.enable = false;
|
nixos.configuration.services.nscd.enable = false;
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
project.name = "full-nixos";
|
project.name = "full-nixos";
|
||||||
services.webserver = { pkgs, lib, ... }: {
|
services.webserver = { pkgs, lib, ... }: {
|
||||||
nixos.useSystemd = true;
|
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.enable = true;
|
||||||
nixos.configuration.services.nginx.virtualHosts.localhost.root = "${pkgs.nix.doc}/share/doc/nix/manual";
|
nixos.configuration.services.nginx.virtualHosts.localhost.root = "${pkgs.nix.doc}/share/doc/nix/manual";
|
||||||
nixos.configuration.services.nscd.enable = false;
|
nixos.configuration.services.nscd.enable = false;
|
||||||
|
|
54
flake.lock
54
flake.lock
|
@ -7,11 +7,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1675933616,
|
"lastModified": 1722555600,
|
||||||
"narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=",
|
"narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-parts",
|
||||||
"rev": "47478a4a003e745402acf63be7f9a092d51b83d7",
|
"rev": "8471fe90ad337a8074e957b69ca4d0089218391d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -20,6 +20,26 @@
|
||||||
"type": "github"
|
"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": {
|
"haskell-flake": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1675296942,
|
"lastModified": 1675296942,
|
||||||
|
@ -36,13 +56,34 @@
|
||||||
"type": "github"
|
"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": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1676300157,
|
"lastModified": 1722630782,
|
||||||
"narHash": "sha256-1HjRzfp6LOLfcj/HJHdVKWAkX9QRAouoh6AjzJiIerU=",
|
"narHash": "sha256-hMyG9/WlUi0Ho9VkRrrez7SeNlDzLxalm9FwY7n/Noo=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "545c7a31e5dedea4a6d372712a18e00ce097d462",
|
"rev": "d04953086551086b44b6f3c6b7eeb26294f207da",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -56,6 +97,7 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-parts": "flake-parts",
|
"flake-parts": "flake-parts",
|
||||||
"haskell-flake": "haskell-flake",
|
"haskell-flake": "haskell-flake",
|
||||||
|
"hercules-ci-effects": "hercules-ci-effects",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
32
flake.nix
32
flake.nix
|
@ -6,12 +6,15 @@
|
||||||
haskell-flake.url = "github:srid/haskell-flake/0.1.0";
|
haskell-flake.url = "github:srid/haskell-flake/0.1.0";
|
||||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
|
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, ... }:
|
outputs = inputs@{ self, flake-parts, ... }:
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } ({ config, lib, extendModules, ... }: {
|
flake-parts.lib.mkFlake { inherit inputs; } ({ config, lib, extendModules, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
inputs.haskell-flake.flakeModule
|
inputs.haskell-flake.flakeModule
|
||||||
|
inputs.hercules-ci-effects.flakeModule
|
||||||
inputs.flake-parts.flakeModules.easyOverlay
|
inputs.flake-parts.flakeModules.easyOverlay
|
||||||
./docs/flake-module.nix
|
./docs/flake-module.nix
|
||||||
./tests/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 = {
|
flake = {
|
||||||
debug = { inherit inputs config lib; };
|
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 = {
|
lib = {
|
||||||
eval = import ./src/nix/eval-composition.nix;
|
eval = import ./src/nix/eval-composition.nix;
|
||||||
build = args@{ ... }:
|
build = args@{ ... }:
|
||||||
|
@ -79,12 +93,6 @@
|
||||||
in composition.config.out.dockerComposeYaml;
|
in composition.config.out.dockerComposeYaml;
|
||||||
};
|
};
|
||||||
nixosModules.arion = ./nixos-module.nix;
|
nixosModules.arion = ./nixos-module.nix;
|
||||||
herculesCI.ciSystems = [
|
|
||||||
# "aarch64-darwin"
|
|
||||||
# "aarch64-linux"
|
|
||||||
"x86_64-darwin"
|
|
||||||
"x86_64-linux"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,14 @@ let
|
||||||
visible = "shallow";
|
visible = "shallow";
|
||||||
};
|
};
|
||||||
_systemd = mkOption { internal = true; };
|
_systemd = mkOption { internal = true; };
|
||||||
|
serviceName = mkOption {
|
||||||
|
description = "The name of the Arion project's systemd service";
|
||||||
|
type = types.str;
|
||||||
|
default = "arion-${name}";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
_systemd.services."arion-${name}" = {
|
_systemd.services.${config.serviceName} = {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "sockets.target" ];
|
after = [ "sockets.target" ];
|
||||||
|
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
# For manual testing of a hacked arion built via Nix.
|
# For manual testing of a hacked arion built via Nix.
|
||||||
# Works when called from outside the project directory.
|
# 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
|
import qualified Data.Text.IO as T
|
||||||
|
|
||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = describe "evaluateComposition" $ it "matches an example" $ do
|
spec = describe "evaluateComposition" $ do
|
||||||
x <- Arion.Nix.evaluateComposition EvaluationArgs
|
it "matches an example" $ do
|
||||||
{ evalUid = 123
|
x <- Arion.Nix.evaluateComposition EvaluationArgs
|
||||||
, evalModules = NEL.fromList
|
{ evalUid = 123
|
||||||
["src/haskell/testdata/Arion/NixSpec/arion-compose.nix"]
|
, evalModules = NEL.fromList
|
||||||
, evalPkgs = "import <nixpkgs> { system = \"x86_64-linux\"; }"
|
["src/haskell/testdata/Arion/NixSpec/arion-compose.nix"]
|
||||||
, evalWorkDir = Nothing
|
, evalPkgs = "import <nixpkgs> { system = \"x86_64-linux\"; }"
|
||||||
, evalMode = ReadOnly
|
, evalWorkDir = Nothing
|
||||||
, evalUserArgs = ["--show-trace"]
|
, evalMode = ReadOnly
|
||||||
}
|
, evalUserArgs = ["--show-trace"]
|
||||||
let actual = pretty x
|
}
|
||||||
expected <- T.readFile "src/haskell/testdata/Arion/NixSpec/arion-compose.json"
|
let actual = pretty x
|
||||||
censorPaths actual `shouldBe` censorPaths expected
|
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 :: Text -> Text
|
||||||
censorPaths = censorImages . censorStorePaths
|
censorPaths = censorImages . censorStorePaths
|
||||||
|
|
|
@ -9,3 +9,4 @@ import qualified Arion.NixSpec
|
||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = do
|
spec = do
|
||||||
describe "Arion.Nix" Arion.NixSpec.spec
|
describe "Arion.Nix" Arion.NixSpec.spec
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
project.name = "unit-test-data";
|
project.name = "unit-test-data";
|
||||||
services.webserver = { pkgs, ... }: {
|
services.webserver = { pkgs, ... }: {
|
||||||
nixos.useSystemd = true;
|
nixos.useSystemd = true;
|
||||||
nixos.configuration.boot.tmpOnTmpfs = true;
|
nixos.configuration.boot.tmp.useTmpfs = true;
|
||||||
nixos.configuration.services.nginx.enable = true;
|
nixos.configuration.services.nginx.enable = true;
|
||||||
nixos.configuration.services.nginx.virtualHosts.localhost.root = "${pkgs.nix.doc}/share/doc/nix/manual";
|
nixos.configuration.services.nginx.virtualHosts.localhost.root = "${pkgs.nix.doc}/share/doc/nix/manual";
|
||||||
service.useHostStore = true;
|
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
|
||||||
|
|
|
@ -66,6 +66,22 @@ in
|
||||||
https://docs.docker.com/compose/compose-file/build/#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 {
|
service.hostname = mkOption {
|
||||||
type = nullOr str;
|
type = nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
|
@ -86,7 +102,8 @@ in
|
||||||
description = serviceRef "environment";
|
description = serviceRef "environment";
|
||||||
};
|
};
|
||||||
service.image = mkOption {
|
service.image = mkOption {
|
||||||
type = str;
|
type = nullOr str;
|
||||||
|
default = null;
|
||||||
description = serviceRef "image";
|
description = serviceRef "image";
|
||||||
};
|
};
|
||||||
service.command = mkOption {
|
service.command = mkOption {
|
||||||
|
@ -193,6 +210,11 @@ in
|
||||||
default = [];
|
default = [];
|
||||||
description = serviceRef "external_links";
|
description = serviceRef "external_links";
|
||||||
};
|
};
|
||||||
|
service.profiles = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = [];
|
||||||
|
description = serviceRef "profiles";
|
||||||
|
};
|
||||||
service.extra_hosts = mkOption {
|
service.extra_hosts = mkOption {
|
||||||
type = listOf str;
|
type = listOf str;
|
||||||
default = [];
|
default = [];
|
||||||
|
@ -296,6 +318,11 @@ in
|
||||||
default = null;
|
default = null;
|
||||||
description = serviceRef "stop_signal";
|
description = serviceRef "stop_signal";
|
||||||
};
|
};
|
||||||
|
service.stop_grace_period = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
default = null;
|
||||||
|
description = serviceRef "stop_grace_period";
|
||||||
|
};
|
||||||
service.sysctls = mkOption {
|
service.sysctls = mkOption {
|
||||||
type = attrsOf (either str int);
|
type = attrsOf (either str int);
|
||||||
default = {};
|
default = {};
|
||||||
|
@ -328,10 +355,11 @@ in
|
||||||
volumes
|
volumes
|
||||||
environment
|
environment
|
||||||
sysctls
|
sysctls
|
||||||
image
|
|
||||||
;
|
;
|
||||||
} // lib.optionalAttrs (config.service.build.context != null) {
|
} // lib.optionalAttrs (config.service.image != null) {
|
||||||
inherit (config.service) build;
|
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 != []) {
|
} // lib.optionalAttrs (cap_add != []) {
|
||||||
inherit cap_add;
|
inherit cap_add;
|
||||||
} // lib.optionalAttrs (cap_drop != []) {
|
} // lib.optionalAttrs (cap_drop != []) {
|
||||||
|
@ -378,6 +406,8 @@ in
|
||||||
inherit (config.service) restart;
|
inherit (config.service) restart;
|
||||||
} // lib.optionalAttrs (config.service.stop_signal != null) {
|
} // lib.optionalAttrs (config.service.stop_signal != null) {
|
||||||
inherit (config.service) stop_signal;
|
inherit (config.service) stop_signal;
|
||||||
|
} // lib.optionalAttrs (config.service.stop_grace_period != null) {
|
||||||
|
inherit (config.service) stop_grace_period;
|
||||||
} // lib.optionalAttrs (config.service.tmpfs != []) {
|
} // lib.optionalAttrs (config.service.tmpfs != []) {
|
||||||
inherit (config.service) tmpfs;
|
inherit (config.service) tmpfs;
|
||||||
} // lib.optionalAttrs (config.service.tty != null) {
|
} // lib.optionalAttrs (config.service.tty != null) {
|
||||||
|
@ -386,5 +416,7 @@ in
|
||||||
inherit (config.service) working_dir;
|
inherit (config.service) working_dir;
|
||||||
} // lib.optionalAttrs (config.service.user != null) {
|
} // lib.optionalAttrs (config.service.user != null) {
|
||||||
inherit (config.service) user;
|
inherit (config.service) user;
|
||||||
|
} // lib.optionalAttrs (config.service.profiles != []) {
|
||||||
|
inherit (config.service) profiles;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,17 +163,19 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = lib.mkMerge [{
|
||||||
build.image = builtImage;
|
build.image = builtImage;
|
||||||
build.imageName = config.build.image.imageName;
|
build.imageName = config.build.image.imageName;
|
||||||
build.imageTag =
|
build.imageTag =
|
||||||
if config.build.image.imageTag != ""
|
if config.build.image.imageTag != ""
|
||||||
then config.build.image.imageTag
|
then config.build.image.imageTag
|
||||||
else lib.head (lib.strings.splitString "-" (baseNameOf config.build.image.outPath));
|
else lib.head (lib.strings.splitString "-" (baseNameOf config.build.image.outPath));
|
||||||
|
image.rawConfig.Cmd = config.image.command;
|
||||||
service.image = lib.mkDefault "${config.build.imageName}:${config.build.imageTag}";
|
image.nixBuild = lib.mkDefault (priorityIsDefault options.service.image);
|
||||||
image.rawConfig.Cmd = config.image.command;
|
}
|
||||||
|
( lib.mkIf (config.service.build.context == null)
|
||||||
image.nixBuild = lib.mkDefault (priorityIsDefault options.service.image);
|
{
|
||||||
};
|
service.image = lib.mkDefault "${config.build.imageName}:${config.build.imageTag}";
|
||||||
|
})
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ in
|
||||||
service.tmpfs = [
|
service.tmpfs = [
|
||||||
"/run" # noexec is fine because exes should be symlinked from elsewhere anyway
|
"/run" # noexec is fine because exes should be symlinked from elsewhere anyway
|
||||||
"/run/wrappers" # noexec breaks this intentionally
|
"/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.stop_signal = "SIGRTMIN+3";
|
||||||
service.tty = true;
|
service.tty = true;
|
||||||
|
|
|
@ -29,7 +29,7 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
dockerSocket.enable = true;
|
dockerSocket.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
# no caches, because no internet
|
# no caches, because no internet
|
||||||
nix.settings.substituters = lib.mkForce [];
|
nix.settings.substituters = lib.mkForce [];
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ in
|
||||||
pkgs.stdenv
|
pkgs.stdenv
|
||||||
];
|
];
|
||||||
|
|
||||||
virtualisation.memorySize = 1024;
|
virtualisation.memorySize = 2048;
|
||||||
virtualisation.diskSize = 8000;
|
virtualisation.diskSize = 8000;
|
||||||
};
|
};
|
||||||
testScript = ''
|
testScript = ''
|
||||||
|
|
|
@ -4,7 +4,7 @@ pkgs.nixosTest {
|
||||||
name = "test-basic-arion-kafka";
|
name = "test-basic-arion-kafka";
|
||||||
nodes = {
|
nodes = {
|
||||||
machine = { ... }: {
|
machine = { ... }: {
|
||||||
virtualisation.memorySize = 3000;
|
virtualisation.memorySize = 4096;
|
||||||
virtualisation.diskSize = 10000;
|
virtualisation.diskSize = 10000;
|
||||||
imports = [
|
imports = [
|
||||||
../../nixos-module.nix
|
../../nixos-module.nix
|
||||||
|
|
Loading…
Reference in a new issue