-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
95 lines (88 loc) · 3.03 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nix2container = {
url = "github:nlewo/nix2container";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
devenv = {
url = "github:cachix/devenv";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { devenv, flake-utils, nix2container, nixpkgs, self } @ inputs:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs { inherit system; };
nix2containerPkgs = nix2container.packages.${system};
in
{
packages = {
default = pkgs.php.buildComposerProject (finalAttrs: {
pname = "apposto";
version = "1.0.0";
src = ./.;
vendorHash = "sha256-8tbJFWwvOawBZL6Z1ZVsk2/lmABgEEe2FGyolZhmFHA=";
postInstall = ''
cd $out/share/php/apposto
php artisan livewire:publish --assets
php artisan storage:link
'';
nativeBuildInputs = [ pkgs.php ];
});
containerImage = let appRoot = "/share/php/apposto"; in
nix2containerPkgs.nix2container.buildImage {
name = "apposto";
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [ self.packages.${system}.default pkgs.bashInteractive pkgs.coreutils pkgs.curl ];
};
perms = [{
path = self.packages.${system}.default;
regex = "^${self.packages.${system}.default}${appRoot}/database$";
mode = "755";
uid = 1000;
gid = 1000;
}];
config = {
Cmd = [ "serve" ];
Entrypoint = [ "${appRoot}/artisan" ];
Env = [
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
];
ExposedPorts = {
"8000" = { };
};
User = "1000:1000";
Volumes = {
"${appRoot}/bootstrap/cache" = { };
"${appRoot}/database/database.sqlite" = { };
"${appRoot}/storage" = { };
};
WorkingDir = appRoot;
};
};
};
devShells = {
default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
({ config, ... }: {
languages.php.enable = true;
packages = [
pkgs.actionlint
pkgs.azure-cli
pkgs.helm-docs
pkgs.kubectl
pkgs.kubelogin
pkgs.kubernetes-helm
];
processes.serve.exec = "./artisan serve";
})
];
};
};
});
}