DEVELOPMENT ENVIRONMENT

~liljamo/felu

0fd14dfb8cb1d1e02aced57518f3798f8de34b0a — Jonni Liljamo a month ago 3824bb8
chore: update flake inputs, dev environment and tailwindcss
8 files changed, 161 insertions(+), 147 deletions(-)

A .envrc
M .gitignore
M flake.lock
M flake.nix
D scripts/go_run_dev.sh
D scripts/tailwindcss.sh
D scripts/templ.sh
M static/styles.css
A .envrc => .envrc +1 -0
@@ 0,0 1,1 @@
use_flake

M .gitignore => .gitignore +4 -3
@@ 1,3 1,4 @@
.pre-commit-config.yaml
tmp/
internal/components/*_templ.*
/.pre-commit-config.yaml
/tmp/
/internal/components/*_templ.*
/.direnv/

M flake.lock => flake.lock +56 -96
@@ 1,5 1,25 @@
{
  "nodes": {
    "devshell": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1722113426,
        "narHash": "sha256-Yo/3loq572A8Su6aY5GP56knpuKYRvM2a1meP9oJZCw=",
        "owner": "numtide",
        "repo": "devshell",
        "rev": "67cce7359e4cd3c45296fb4aaf6a19e2a9c757ae",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "devshell",
        "type": "github"
      }
    },
    "flake-compat": {
      "flake": false,
      "locked": {


@@ 16,45 36,29 @@
        "type": "github"
      }
    },
    "flake-utils": {
      "inputs": {
        "systems": "systems"
      },
      "locked": {
        "lastModified": 1709126324,
        "narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "d465f4819400de7c8d874d50b982301f28a84605",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "flake-utils_2": {
    "flake-parts": {
      "inputs": {
        "systems": "systems_2"
        "nixpkgs-lib": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1701680307,
        "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
        "lastModified": 1726153070,
        "narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=",
        "owner": "hercules-ci",
        "repo": "flake-parts",
        "rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "owner": "hercules-ci",
        "repo": "flake-parts",
        "type": "github"
      }
    },
    "flake-utils_3": {
    "flake-utils": {
      "inputs": {
        "systems": "systems_3"
        "systems": "systems"
      },
      "locked": {
        "lastModified": 1694529238,


@@ 70,7 74,7 @@
        "type": "github"
      }
    },
    "flake-utils_4": {
    "flake-utils_2": {
      "locked": {
        "lastModified": 1667395993,
        "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",


@@ 93,11 97,11 @@
        ]
      },
      "locked": {
        "lastModified": 1703887061,
        "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=",
        "lastModified": 1709087332,
        "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
        "owner": "hercules-ci",
        "repo": "gitignore.nix",
        "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5",
        "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
        "type": "github"
      },
      "original": {


@@ 129,7 133,7 @@
    },
    "gomod2nix": {
      "inputs": {
        "flake-utils": "flake-utils_3",
        "flake-utils": "flake-utils",
        "nixpkgs": [
          "templ",
          "nixpkgs"


@@ 151,11 155,11 @@
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1709386671,
        "narHash": "sha256-VPqfBnIJ+cfa78pd4Y5Cr6sOWVW8GYHRVucxJGmRf8Q=",
        "lastModified": 1727617520,
        "narHash": "sha256-uNfh3aMyCekMpjtL/PZtl2Hz/YqNuUpCBEzVxt1QYck=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "fa9a51752f1b5de583ad5213eb621be071806663",
        "rev": "7eee17a8a5868ecf596bbb8c8beb527253ea8f4d",
        "type": "github"
      },
      "original": {


@@ 167,32 171,16 @@
    },
    "nixpkgs-stable": {
      "locked": {
        "lastModified": 1704874635,
        "narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-23.11",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs_2": {
      "locked": {
        "lastModified": 1704842529,
        "narHash": "sha256-OTeQA+F8d/Evad33JMfuXC89VMetQbsU4qcaePchGr4=",
        "lastModified": 1720386169,
        "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "eabe8d3eface69f5bb16c18f8662a702f50c20d5",
        "rev": "194846768975b7ad2c4988bdb82572c00222c0d7",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixpkgs-unstable",
        "ref": "nixos-24.05",
        "repo": "nixpkgs",
        "type": "github"
      }


@@ 200,28 188,30 @@
    "pre-commit-hooks": {
      "inputs": {
        "flake-compat": "flake-compat",
        "flake-utils": "flake-utils_2",
        "gitignore": "gitignore",
        "nixpkgs": "nixpkgs_2",
        "nixpkgs": [
          "nixpkgs"
        ],
        "nixpkgs-stable": "nixpkgs-stable"
      },
      "locked": {
        "lastModified": 1708018599,
        "narHash": "sha256-M+Ng6+SePmA8g06CmUZWi1AjG2tFBX9WCXElBHEKnyM=",
        "lastModified": 1727514110,
        "narHash": "sha256-0YRcOxJG12VGDFH8iS8pJ0aYQQUAgo/r3ZAL+cSh9nk=",
        "owner": "cachix",
        "repo": "pre-commit-hooks.nix",
        "rev": "5df5a70ad7575f6601d91f0efec95dd9bc619431",
        "repo": "git-hooks.nix",
        "rev": "85f7a7177c678de68224af3402ab8ee1bcee25c8",
        "type": "github"
      },
      "original": {
        "owner": "cachix",
        "repo": "pre-commit-hooks.nix",
        "repo": "git-hooks.nix",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "flake-utils": "flake-utils",
        "devshell": "devshell",
        "flake-parts": "flake-parts",
        "nixpkgs": "nixpkgs",
        "pre-commit-hooks": "pre-commit-hooks",
        "templ": "templ"


@@ 242,36 232,6 @@
        "type": "github"
      }
    },
    "systems_2": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "owner": "nix-systems",
        "repo": "default",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "github"
      },
      "original": {
        "owner": "nix-systems",
        "repo": "default",
        "type": "github"
      }
    },
    "systems_3": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "owner": "nix-systems",
        "repo": "default",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "github"
      },
      "original": {
        "owner": "nix-systems",
        "repo": "default",
        "type": "github"
      }
    },
    "templ": {
      "inputs": {
        "gitignore": "gitignore_2",


@@ 298,7 258,7 @@
    },
    "xc": {
      "inputs": {
        "flake-utils": "flake-utils_4",
        "flake-utils": "flake-utils_2",
        "nixpkgs": [
          "templ",
          "nixpkgs"

M flake.nix => flake.nix +86 -33
@@ 1,9 1,20 @@
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    flake-parts = {
      url = "github:hercules-ci/flake-parts";
      inputs.nixpkgs-lib.follows = "nixpkgs";
    };

    pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
    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.598";


@@ 11,41 22,83 @@
    };
  };

  outputs = inputs @ {
    self,
    nixpkgs,
    flake-utils,
    pre-commit-hooks,
    templ,
  }:
    flake-utils.lib.eachSystem ["x86_64-linux"] (
      system: let
        pkgs = nixpkgs.legacyPackages.${system};
        templ-pkg = templ.packages.${system}.default;
      in {
        checks = {
          pre-commit-check = pre-commit-hooks.lib.${system}.run {
            src = ./.;
            hooks = {
              gofmt.enable = true;
              govet.enable = true;
              revive.enable = true;
            };
  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 = pkgs.mkShell {
          inherit (self.checks.${system}.pre-commit-check) shellHook;
          buildInputs = [
            pkgs.go
            pkgs.gopls
        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

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

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

D scripts/go_run_dev.sh => scripts/go_run_dev.sh +0 -7
@@ 1,7 0,0 @@
#!/usr/bin/env sh
export GIN_MODE=release
export FELU_DB_PATH=tmp/
export FELU_DNS_PATTERN=ddns.feludns.arpa.
export FELU_DNS_BIND_PORT=8053

go run cmd/felu/main.go

D scripts/tailwindcss.sh => scripts/tailwindcss.sh +0 -2
@@ 1,2 0,0 @@
#!/usr/bin/env sh
tailwindcss -i input.css -o ./static/styles.css --watch

D scripts/templ.sh => scripts/templ.sh +0 -2
@@ 1,2 0,0 @@
#!/usr/bin/env sh
templ generate --watch

M static/styles.css => static/styles.css +14 -4
@@ 1,5 1,5 @@
/*
! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com
! tailwindcss v3.4.10 | MIT License | https://tailwindcss.com
*/

/*


@@ 211,6 211,8 @@ textarea {
  /* 1 */
  line-height: inherit;
  /* 1 */
  letter-spacing: inherit;
  /* 1 */
  color: inherit;
  /* 1 */
  margin: 0;


@@ 234,9 236,9 @@ select {
*/

button,
[type='button'],
[type='reset'],
[type='submit'] {
input:where([type='button']),
input:where([type='reset']),
input:where([type='submit']) {
  -webkit-appearance: button;
  /* 1 */
  background-color: transparent;


@@ 492,6 494,10 @@ video {
  --tw-backdrop-opacity:  ;
  --tw-backdrop-saturate:  ;
  --tw-backdrop-sepia:  ;
  --tw-contain-size:  ;
  --tw-contain-layout:  ;
  --tw-contain-paint:  ;
  --tw-contain-style:  ;
}

::backdrop {


@@ 542,6 548,10 @@ video {
  --tw-backdrop-opacity:  ;
  --tw-backdrop-saturate:  ;
  --tw-backdrop-sepia:  ;
  --tw-contain-size:  ;
  --tw-contain-layout:  ;
  --tw-contain-paint:  ;
  --tw-contain-style:  ;
}

.absolute {