caddy soluzione 2. overlay senza nixpkgs custom

This commit is contained in:
pazpi 2024-09-06 08:02:07 +02:00
parent 1903e0a6e1
commit 6602567bf9
6 changed files with 80 additions and 59 deletions

19
flake.lock generated
View file

@ -241,22 +241,6 @@
"type": "github" "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": { "root": {
"inputs": { "inputs": {
"agenix": "agenix", "agenix": "agenix",
@ -264,8 +248,7 @@
"home-manager": "home-manager_2", "home-manager": "home-manager_2",
"lix-module": "lix-module", "lix-module": "lix-module",
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs"
"nixpkgs-caddy": "nixpkgs-caddy"
} }
}, },
"stable": { "stable": {

View file

@ -33,26 +33,23 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
# Used for caddy plugins
nixpkgs-caddy.url = "github:jpds/nixpkgs/caddy-external-plugins";
}; };
outputs = outputs =
{ self {
, nixpkgs self,
, nixos-hardware nixpkgs,
, lix-module nixos-hardware,
, agenix lix-module,
, colmena agenix,
, home-manager colmena,
, ... home-manager,
...
}@inputs: }@inputs:
let let
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
lib = nixpkgs.lib; lib = nixpkgs.lib;
caddyWithPlugins = pkgs.callPackage ./packages/caddy-pkg.nix { };
in in
{ {

View file

@ -1,26 +1,24 @@
{ nixpkgs {
, nixos-hardware nixpkgs,
, agenix nixos-hardware,
, home-manager agenix,
, lix-module home-manager,
, nixpkgs-caddy lix-module,
, ... ...
}: }:
let let
agenixOverlay = final: prev: { agenix = agenix.packages.${prev.system}.default; }; agenixOverlay = final: prev: { agenix = agenix.packages.${prev.system}.default; };
customOverlays = import ../overlay;
pkgs = pkgs =
system: system:
import nixpkgs { import nixpkgs {
inherit system; inherit system;
overlays = [ agenixOverlay ]; overlays = [
config.allowUnfree = true; agenixOverlay
}; customOverlays
];
pkgs-caddy =
system:
import nixpkgs-caddy {
inherit system;
config.allowUnfree = true; config.allowUnfree = true;
}; };
@ -48,9 +46,7 @@ in
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
agenix.nixosModules.default agenix.nixosModules.default
]; ];
specialArgs = { # specialArgs = { };
# inherit nixvim nix-index-database;
};
}; };
arr = nixpkgs.lib.nixosSystem { arr = nixpkgs.lib.nixosSystem {
@ -61,9 +57,7 @@ in
./arr ./arr
agenix.nixosModules.default agenix.nixosModules.default
]; ];
specialArgs = { # specialArgs = { };
# inherit nixvim nix-index-database;
};
}; };
metrics = nixpkgs.lib.nixosSystem { metrics = nixpkgs.lib.nixosSystem {
@ -74,9 +68,7 @@ in
./metrics ./metrics
agenix.nixosModules.default agenix.nixosModules.default
]; ];
specialArgs = { # specialArgs = { };
pkgs-caddy = pkgs-caddy "x86_64-linux";
};
}; };
} }

View file

@ -1,8 +1,8 @@
{ config {
, pkgs config,
, lib pkgs,
, pkgs-caddy lib,
, ... ...
}: }:
{ {

48
overlay/caddy-custom.nix Normal file
View file

@ -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;
});
}

1
overlay/default.nix Normal file
View file

@ -0,0 +1 @@
_: prev: { caddy-custom = prev.callPackage ./caddy-custom.nix { }; }