diff options
author | Emile <git@emile.space> | 2025-02-12 21:24:31 +0100 |
---|---|---|
committer | Emile <git@emile.space> | 2025-02-12 21:24:31 +0100 |
commit | c0a8852e4ec21f15c5a862201515518c3eee7734 (patch) | |
tree | eb906ede104475df681d3b61ecae234d5bb67b62 /nix/templates/goapp/flake.nix | |
parent | 2e1c7e7c033a8d1819c65a65dbed71f884e2fec1 (diff) |
template: a basic golang app template
This template allows building golang apps as well as a corresponding docker container from the built package
Diffstat (limited to 'nix/templates/goapp/flake.nix')
-rw-r--r-- | nix/templates/goapp/flake.nix | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/nix/templates/goapp/flake.nix b/nix/templates/goapp/flake.nix new file mode 100644 index 0000000..414acb8 --- /dev/null +++ b/nix/templates/goapp/flake.nix @@ -0,0 +1,52 @@ +{ + inputs.nixpkgs.url = "git+https://github.com/nixos/nixpkgs.git?shallow=1?ref=nixos-24.11"; + inputs.flake-utils.url = "git+https://github.com/numtide/flake-utils"; + + outputs = + { nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ ]; + }; + + package-and-docker = packagename: { + # the raw package + "${packagename}" = import ./${packagename} { inherit pkgs packagename; }; + + # the docker image + "${packagename}-docker" = pkgs.dockerTools.buildImage { + name = "${packagename}"; + config.Cmd = [ "${packagename}/bin/${packagename}" ]; + }; + }; + in + { + packages = { } // (package-and-docker "backend") // (package-and-docker "frontend"); + + devShells.default = pkgs.mkShell { + buildInputs = builtins.attrValues { + inherit (pkgs) + go + gopls + helix + ripgrep + fd + tokei + tree + + eza + ; + }; + + shellHook = '' + alias ls=eza + echo "goapp shell" + export PS1='>; ' + ''; + }; + } + ); +} |