mirror of
https://github.com/georgyo/ifconfig.io.git
synced 2025-10-15 08:33:41 +00:00
Compare commits
6 Commits
142b9726ea
...
github_act
Author | SHA1 | Date | |
---|---|---|---|
|
9e649a1c2e | ||
|
c22766233e | ||
|
45aaf5f0f3 | ||
|
e0726c0996 | ||
|
ff2f51ddf2 | ||
|
3229003474 |
37
.github/workflows/test.yml
vendored
Normal file
37
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
name: "Test"
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
jobs:
|
||||||
|
test-nix:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
# Nix Flakes doesn't work on shallow clones
|
||||||
|
fetch-depth: 0
|
||||||
|
- uses: cachix/install-nix-action@v16
|
||||||
|
with:
|
||||||
|
nix_path: nixpkgs=channel:nixos-unstable
|
||||||
|
extra_nix_config: |
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
system-features = nixos-test benchmark big-parallel kvm
|
||||||
|
- run: nix-build
|
||||||
|
test:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version: [ 1.14.x, 1.15.x, 1.16.x ]
|
||||||
|
os: [ ubuntu-latest ]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go-version }}
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Format
|
||||||
|
run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi
|
||||||
|
if: matrix.os == 'ubuntu-latest'
|
||||||
|
- name: Test
|
||||||
|
run: go test -race ./...
|
44
flake.lock
generated
44
flake.lock
generated
@@ -16,17 +16,53 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1638122382,
|
||||||
|
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nix-bundle": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1626704917,
|
||||||
|
"narHash": "sha256-cJ73kxY5ZCPWQeQZyCSdvkBqjqJkU5wgETBNaXfqF18=",
|
||||||
|
"owner": "matthewbauer",
|
||||||
|
"repo": "nix-bundle",
|
||||||
|
"rev": "223f4ffc4179aa318c34dc873a08cb00090db829",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "matthewbauer",
|
||||||
|
"repo": "nix-bundle",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1641334250,
|
"lastModified": 1641230035,
|
||||||
"narHash": "sha256-phZavHnNA98Ub5gDeNFUt7fI4Y1S0mnGzqY4MCCgBNI=",
|
"narHash": "sha256-hFyqihERaTbLxCOlugy/rpp22VLtLh8SPRnA2uu3F/8=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "27ff8d72f5c9c38ca073f73dd0ae74e676fbb4f7",
|
"rev": "78cd22c1b8604de423546cd49bfe264b786eca13",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
@@ -34,6 +70,8 @@
|
|||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nix-bundle": "nix-bundle",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
57
flake.nix
57
flake.nix
@@ -1,13 +1,15 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
flake-compat = {
|
flake-compat = {
|
||||||
url = "github:edolstra/flake-compat";
|
url = "github:edolstra/flake-compat";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
nix-bundle = {url = "github:matthewbauer/nix-bundle"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||||
};
|
};
|
||||||
outputs = { self, nixpkgs, ... }:
|
outputs = { self, nixpkgs, flake-utils, nix-bundle, ... }:
|
||||||
let
|
let
|
||||||
|
|
||||||
version = builtins.replaceStrings [ "\n" ] [ "" ]
|
version = builtins.replaceStrings [ "\n" ] [ "" ]
|
||||||
@@ -21,20 +23,12 @@
|
|||||||
|
|
||||||
officialRelease = false;
|
officialRelease = false;
|
||||||
|
|
||||||
systems = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" ];
|
in flake-utils.lib.eachDefaultSystem (system:
|
||||||
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
|
let pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in rec {
|
||||||
|
|
||||||
# Memoize nixpkgs for different platforms for efficiency.
|
packages = flake-utils.lib.flattenTree rec {
|
||||||
nixpkgsFor = forAllSystems (system:
|
ifconfigio = pkgs.buildGoModule {
|
||||||
import nixpkgs {
|
|
||||||
inherit system;
|
|
||||||
overlays = [ self.overlay ];
|
|
||||||
});
|
|
||||||
in {
|
|
||||||
overlay = final: prev: {
|
|
||||||
ifconfigio = with final;
|
|
||||||
with pkgs;
|
|
||||||
(buildGoModule {
|
|
||||||
name = "ifconfig.io-${version}";
|
name = "ifconfig.io-${version}";
|
||||||
|
|
||||||
src = self;
|
src = self;
|
||||||
@@ -44,40 +38,27 @@
|
|||||||
mkdir -p $out/usr/lib/ifconfig.io/
|
mkdir -p $out/usr/lib/ifconfig.io/
|
||||||
cp -r ./templates $out/usr/lib/ifconfig.io
|
cp -r ./templates $out/usr/lib/ifconfig.io
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
});
|
docker-image = pkgs.dockerTools.buildLayeredImage {
|
||||||
|
|
||||||
ifconfigio-docker = with final;
|
|
||||||
with pkgs;
|
|
||||||
(dockerTools.buildLayeredImage {
|
|
||||||
name = "ifconfig.io";
|
name = "ifconfig.io";
|
||||||
tag = version;
|
tag = version;
|
||||||
created = "now";
|
created = "now";
|
||||||
contents = [ ifconfigio busybox ];
|
contents = [ ifconfigio pkgs.busybox ];
|
||||||
config = {
|
config = {
|
||||||
Cmd = "/bin/ifconfig.io";
|
Cmd = "/bin/ifconfig.io";
|
||||||
WorkingDir = "/usr/lib/ifconfig.io";
|
WorkingDir = "/usr/lib/ifconfig.io";
|
||||||
ExposedPorts = { "8080" = { }; };
|
ExposedPorts = { "8080" = { }; };
|
||||||
Env = [ "HOSTNAME=ifconfig.io" "TLS=0" "TLSCERT=" "TLSKEY=" ];
|
Env = [ "HOSTNAME=ifconfig.io" "TLS=0" "TLSCERT=" "TLSKEY=" ];
|
||||||
};
|
};
|
||||||
});
|
};
|
||||||
};
|
|
||||||
packages = forAllSystems (system: {
|
|
||||||
inherit (nixpkgsFor.${system}) ifconfigio ifconfigio-docker;
|
|
||||||
});
|
|
||||||
defaultPackage =
|
|
||||||
forAllSystems (system: self.packages.${system}.ifconfigio);
|
|
||||||
|
|
||||||
nixosModules.ifconfigio = { pkgs, ... }: {
|
|
||||||
nixpkgs.overlays = [ self.overlay ];
|
|
||||||
systemd.packages = [ pkgs.ifconfigio ];
|
|
||||||
users.users.ifconfigio = {
|
|
||||||
description = "ifconfig.io daemon user";
|
|
||||||
group = "ifconfigio";
|
|
||||||
isSystemUser = true;
|
|
||||||
};
|
};
|
||||||
users.groups.ifconfigio = { };
|
defaultPackage = packages.ifconfigio;
|
||||||
};
|
apps.ifconfigio = { type = "app"; program = "${packages.ifconfigio}/bin/ifconfig.io"; };
|
||||||
|
defaultApp = apps.ifconfigio;
|
||||||
|
|
||||||
};
|
defaultBundler = nix-bundle.bundlers.nix-bundle;
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user