DEVELOPMENT ENVIRONMENT

~liljamo/felu

ref: 6e0ca50953f70389d6a917f4bbab04688b00655f felu/flake.nix -rw-r--r-- 2.5 KiB
6e0ca509Jonni Liljamo chore: update mod name and dependencies a month ago
                                                                                
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
96
97
98
99
100
101
102
103
104
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
    flake-parts = {
      url = "github:hercules-ci/flake-parts";
      inputs.nixpkgs-lib.follows = "nixpkgs";
    };

    pre-commit-hooks = {
      url = "github:cachix/git-hooks.nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    devshell = {
      url = "github:numtide/devshell";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    templ = {
      url = "github:a-h/templ?ref=tags/v0.2.778";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = inputs @ {self, ...}:
    inputs.flake-parts.lib.mkFlake {inherit inputs;} {
      imports = [
        inputs.devshell.flakeModule
      ];

      systems = ["x86_64-linux"];
      perSystem = {
        pkgs,
        system,
        ...
      }: {
        checks.pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
          src = ./.;
          hooks = {
            # Nix formatting
            alejandra.enable = true;

            # Go formatting, linting, static checking
            gofmt.enable = true;
            govet.enable = true;
            revive.enable = true;
          };
        };

        devshells.default = {
          env = [
            {
              name = "GIN_MODE";
              value = "release";
            }
            {
              name = "FELU_DB_PATH";
              value = "tmp/";
            }
            {
              name = "FELU_DNS_PATTERN";
              value = "ddns.feludns.arpa.";
            }
            {
              name = "FELU_DNS_BIND_PORT";
              value = "8053";
            }
          ];
          commands = [
            {
              help = "run felu";
              name = "felu-dev-run";
              command = "go run cmd/felu/main.go";
            }
            {
              help = "generate templ templates (watch)";
              name = "felu-dev-templ";
              command = "templ generate --watch";
            }
            {
              help = "generate tailwindcss (watch)";
              name = "felu-dev-tailwindcss";
              command = "tailwindcss -i input.css -o ./static/styles.css --watch";
            }
          ];
          packages = with pkgs;
            [
              gcc

              go
              gopls

              tailwindcss
              tailwindcss-language-server
            ]
            ++ [
              inputs.templ.packages.${system}.default
            ];

          devshell.startup.pre-commit.text = self.checks.${system}.pre-commit-check.shellHook;
        };
      };
    };
}