diff --git a/flake.lock b/flake.lock index c74ebff..d0801c1 100644 --- a/flake.lock +++ b/flake.lock @@ -241,22 +241,6 @@ "type": "github" } }, - "nixpkgs-caddy": { - "locked": { - "lastModified": 1699107987, - "narHash": "sha256-nWXETr4Oqy/vOfzgWyMY04qzEN2iREFJc5ycQ3XNu0A=", - "owner": "jpds", - "repo": "nixpkgs", - "rev": "a33b02fa9d664f31dadc8a874eb1a5dbaa9f4ecf", - "type": "github" - }, - "original": { - "owner": "jpds", - "ref": "caddy-external-plugins", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { "agenix": "agenix", @@ -264,8 +248,7 @@ "home-manager": "home-manager_2", "lix-module": "lix-module", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs", - "nixpkgs-caddy": "nixpkgs-caddy" + "nixpkgs": "nixpkgs" } }, "stable": { diff --git a/flake.nix b/flake.nix index fa97b52..84d0330 100644 --- a/flake.nix +++ b/flake.nix @@ -33,26 +33,23 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - # Used for caddy plugins - nixpkgs-caddy.url = "github:jpds/nixpkgs/caddy-external-plugins"; - }; outputs = - { self - , nixpkgs - , nixos-hardware - , lix-module - , agenix - , colmena - , home-manager - , ... + { + self, + nixpkgs, + nixos-hardware, + lix-module, + agenix, + colmena, + home-manager, + ... }@inputs: let system = "x86_64-linux"; pkgs = import nixpkgs { inherit system; }; lib = nixpkgs.lib; - caddyWithPlugins = pkgs.callPackage ./packages/caddy-pkg.nix { }; in { diff --git a/hosts/default.nix b/hosts/default.nix index 21ff683..423aca5 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -1,26 +1,24 @@ -{ nixpkgs -, nixos-hardware -, agenix -, home-manager -, lix-module -, nixpkgs-caddy -, ... +{ + nixpkgs, + nixos-hardware, + agenix, + home-manager, + lix-module, + ... }: let agenixOverlay = final: prev: { agenix = agenix.packages.${prev.system}.default; }; + customOverlays = import ../overlay; + pkgs = system: import nixpkgs { inherit system; - overlays = [ agenixOverlay ]; - config.allowUnfree = true; - }; - - pkgs-caddy = - system: - import nixpkgs-caddy { - inherit system; + overlays = [ + agenixOverlay + customOverlays + ]; config.allowUnfree = true; }; @@ -48,9 +46,7 @@ in home-manager.nixosModules.home-manager agenix.nixosModules.default ]; - specialArgs = { - # inherit nixvim nix-index-database; - }; + # specialArgs = { }; }; arr = nixpkgs.lib.nixosSystem { @@ -61,9 +57,7 @@ in ./arr agenix.nixosModules.default ]; - specialArgs = { - # inherit nixvim nix-index-database; - }; + # specialArgs = { }; }; metrics = nixpkgs.lib.nixosSystem { @@ -74,9 +68,7 @@ in ./metrics agenix.nixosModules.default ]; - specialArgs = { - pkgs-caddy = pkgs-caddy "x86_64-linux"; - }; + # specialArgs = { }; }; } diff --git a/hosts/metrics/default.nix b/hosts/metrics/default.nix index 1a7875b..c094e78 100644 --- a/hosts/metrics/default.nix +++ b/hosts/metrics/default.nix @@ -1,8 +1,8 @@ -{ config -, pkgs -, lib -, pkgs-caddy -, ... +{ + config, + pkgs, + lib, + ... }: { diff --git a/overlay/caddy-custom.nix b/overlay/caddy-custom.nix new file mode 100644 index 0000000..8bfbd11 --- /dev/null +++ b/overlay/caddy-custom.nix @@ -0,0 +1,48 @@ +{ pkgs, ... }: + +with pkgs; + +caddy.override { + buildGoModule = args: buildGoModule (args // { + src = stdenv.mkDerivation rec { + pname = "caddy-using-xcaddy-${xcaddy.version}"; + inherit (caddy) version; + + dontUnpack = true; + dontFixup = true; + + nativeBuildInputs = [ + cacert + go + ]; + + plugins = [ + # https://github.com/caddy-dns/cloudflare + "github.com/caddy-dns/cloudflare@89f16b99c18ef49c8bb470a82f895bce01cbaece" + ]; + + configurePhase = '' + export GOCACHE=$TMPDIR/go-cache + export GOPATH="$TMPDIR/go" + export XCADDY_SKIP_BUILD=1 + ''; + + buildPhase = '' + ${xcaddy}/bin/xcaddy build "${caddy.src.rev}" ${lib.concatMapStringsSep " " (plugin: "--with ${plugin}") plugins} + cd buildenv* + go mod vendor + ''; + + installPhase = '' + cp -r --reflink=auto . $out + ''; + + outputHash = "sha256-lyhEIOgGkR31bt9YV+W854TBZw419G8uuTtBSsFcgCA="; + outputHashMode = "recursive"; + }; + + subPackages = [ "." ]; + ldflags = [ "-s" "-w" ]; ## don't include version info twice + vendorHash = null; + }); +} diff --git a/overlay/default.nix b/overlay/default.nix new file mode 100644 index 0000000..e5f7337 --- /dev/null +++ b/overlay/default.nix @@ -0,0 +1 @@ +_: prev: { caddy-custom = prev.callPackage ./caddy-custom.nix { }; }