diff options
author | Alan Pearce | 2024-06-25 18:02:18 +0200 |
---|---|---|
committer | Alan Pearce | 2024-06-25 18:09:28 +0200 |
commit | 398210c8ce4140de12720d3f16cc88284a146005 (patch) | |
tree | 2d8144b52870c97f8cd9b86738fd51b50cda0bf5 /default.nix | |
parent | cd1125a213d742b5a89e8b60f0c7aafef13b8783 (diff) | |
download | website-398210c8ce4140de12720d3f16cc88284a146005.tar.lz website-398210c8ce4140de12720d3f16cc88284a146005.tar.zst website-398210c8ce4140de12720d3f16cc88284a146005.zip |
build with ko instead of nix
Diffstat (limited to 'default.nix')
-rw-r--r-- | default.nix | 94 |
1 files changed, 2 insertions, 92 deletions
diff --git a/default.nix b/default.nix index 2949836..779ea74 100644 --- a/default.nix +++ b/default.nix @@ -1,45 +1,10 @@ let sources = import ./npins; - pkgs = import sources.nixpkgs { - overlays = [ - (import "${sources.gomod2nix}/overlay.nix") - ]; - }; + pkgs = import sources.nixpkgs { }; pre-commit-hooks = import sources.pre-commit-hooks; - - inherit (pkgs) - buildGoApplication - lib - runCommandLocal; - - version = "unstable"; - mkDocker = type: { server, architecture ? pkgs.go.GOARCH }: - pkgs.dockerTools.${type} { - name = "registry.fly.io/alanpearce-eu"; - contents = with pkgs; [ - cacert - ]; - inherit architecture; - config = { - Cmd = [ "${server}/bin/server" ]; - Env = [ - "PRODUCTION=true" - "LISTEN_ADDRESS=::" - "ROOT=/data" - "PORT=80" - ]; - WorkingDir = "/data"; - ExposedPorts = { - "80/tcp" = { }; - "443/tcp" = { }; - }; - }; - }; - mkDockerStream = mkDocker "streamLayeredImage"; - mkDockerImage = mkDocker "buildLayeredImage"; in -rec { +{ pre-commit-check = pre-commit-hooks.run { src = ./.; hooks = { @@ -51,61 +16,6 @@ rec { entry = "${pkgs.go}/bin/go mod tidy"; pass_filenames = false; }; - gomod2nix = { - enable = true; - name = "gomod2nix"; - description = "Import go.mod updates to nix"; - types_or = [ "go-sum" ]; - entry = "${pkgs.gomod2nix}/bin/gomod2nix --outdir nix"; - pass_filenames = false; - }; - }; - }; - server = buildGoApplication { - pname = "server"; - inherit version; - CGO_ENABLED = 0; - src = with lib.fileset; toSource { - root = ./.; - fileset = unions [ - ./go.mod - ./go.sum - ./cmd/server - ./internal - ./templates - ]; }; - modules = ./nix/gomod2nix.toml; - patchPhase = '' - ${pkgs.templ}/bin/templ generate - ''; - subPackages = [ "cmd/server" ]; - tags = [ "embed" ]; - ldflags = [ - "-s" - "-w" - ]; - }; - docker-stream = mkDockerStream { inherit server; }; - docker-image = mkDockerImage { inherit server; }; - - server-amd64-linux = server.overrideAttrs (old: old // { - GOOS = "linux"; - GOARCH = "amd64"; - fixupPhase = '' - if [[ -d $out/bin/linux_amd64 ]] - then - mv $out/bin/linux_amd64/server $out/bin/server - rmdir $out/bin/linux_amd64 - fi - ''; - }); - docker-image-amd64-linux = mkDockerImage { - server = server-amd64-linux; - architecture = "amd64"; - }; - docker-stream-amd64-linux = mkDockerStream { - server = server-amd64-linux; - architecture = "amd64"; }; } |