ifconfig.io/flake.nix

65 lines
2.0 KiB
Nix
Raw Permalink Normal View History

2020-11-16 02:05:14 +00:00
{
inputs = {
2020-11-29 03:09:05 +00:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
2020-11-16 02:05:14 +00:00
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
2020-11-29 03:09:05 +00:00
flake-utils.url = "github:numtide/flake-utils";
nix-bundle = {url = "github:matthewbauer/nix-bundle"; inputs.nixpkgs.follows = "nixpkgs"; };
2020-11-16 02:05:14 +00:00
};
2020-11-29 03:09:05 +00:00
outputs = { self, nixpkgs, flake-utils, nix-bundle, ... }:
2020-11-16 02:05:14 +00:00
let
version = builtins.replaceStrings [ "\n" ] [ "" ]
(builtins.readFile ./.version + versionSuffix);
versionSuffix = if officialRelease then
""
else
"pre${
nixpkgs.lib.substring 0 8 (self.lastModifiedDate or self.lastModified)
}_${self.shortRev or "dirty"}";
officialRelease = false;
2020-11-29 03:09:05 +00:00
in flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system};
in rec {
2020-11-16 02:05:14 +00:00
2020-11-29 03:09:05 +00:00
packages = flake-utils.lib.flattenTree rec {
ifconfigio = pkgs.buildGoModule {
2020-11-16 02:05:14 +00:00
name = "ifconfig.io-${version}";
src = self;
2022-01-04 22:42:51 +00:00
vendorSha256 = "sha256-KUgKselGjYI0I1zT/LB48pksswNXLbrgBM6LtYPeT/Q=";
2020-11-16 02:05:14 +00:00
postInstall = ''
mkdir -p $out/usr/lib/ifconfig.io/
cp -r ./templates $out/usr/lib/ifconfig.io
'';
2020-11-29 03:09:05 +00:00
};
2020-11-16 02:05:14 +00:00
2020-11-29 03:09:05 +00:00
docker-image = pkgs.dockerTools.buildLayeredImage {
2020-11-17 02:42:21 +00:00
name = "ifconfig.io";
tag = version;
created = "now";
2020-11-29 03:09:05 +00:00
contents = [ ifconfigio pkgs.busybox ];
2020-11-17 02:42:21 +00:00
config = {
Cmd = "/bin/ifconfig.io";
WorkingDir = "/usr/lib/ifconfig.io";
ExposedPorts = { "8080" = { }; };
Env = [ "HOSTNAME=ifconfig.io" "TLS=0" "TLSCERT=" "TLSKEY=" ];
};
2020-11-29 03:09:05 +00:00
};
2020-11-16 02:05:14 +00:00
};
2020-11-29 03:09:05 +00:00
defaultPackage = packages.ifconfigio;
apps.ifconfigio = { type = "app"; program = "${packages.ifconfigio}/bin/ifconfig.io"; };
defaultApp = apps.ifconfigio;
2020-11-16 02:05:14 +00:00
2020-11-29 03:09:05 +00:00
defaultBundler = nix-bundle.bundlers.nix-bundle;
});
2020-11-16 02:05:14 +00:00
}