/ env / dev.nix
dev.nix
 1  {
 2    nixidy = {
 3      target = {
 4        branch = "main";
 5        rootPath = "./manifests/dev";
 6        repository = "https://github.com/MFarabi619/MFarabi619.git";
 7      };
 8    };
 9    applications = {
10      demo = {
11        namespace = "demo";
12        createNamespace = true;
13        resources =
14          let
15            labels = {
16              "app.kubernetes.io/name" = "nginx";
17            };
18          in
19          {
20            deployments = {
21              nginx.spec = {
22                selector.matchLabels = labels;
23                template = {
24                  metadata.labels = labels;
25                  spec = {
26                    securityContext.fsGroup = 1000;
27                    containers.nginx = {
28                      image = "nginx:1.25.1";
29                      imagePullPolicy = "IfNotPresent";
30                      volumeMounts = {
31                        "/etc/nginx".name = "config";
32                        "/var/lib/html".name = "static";
33                      };
34                    };
35                    volumes = {
36                      config.configMap.name = "nginx-config";
37                      static.configMap.name = "nginx-static";
38                    };
39                  };
40                };
41              };
42            };
43  
44            configMaps = {
45              nginx-config.data."nginx.conf" = ''
46                user nginx nginx;
47                error_log /dev/stdout info;
48                pid /dev/null;
49                events {}
50                http {
51                  access_log /dev/stdout;
52                  server {
53                    listen 80;
54                    index index.html;
55                    location / {
56                    root /var/lib/html;
57                    }
58                  }
59                }
60              '';
61  
62              nginx-static.data."index.html" = ''
63                <html><body><h1>Hello from NGINX</h1></body></html>
64              '';
65            };
66  
67            services = {
68              nginx.spec = {
69                selector = labels;
70                ports.http.port = 80;
71              };
72            };
73          };
74      };
75    };
76  }