nix/docker builds

This commit is contained in:
Cadey Ratio 2020-05-31 15:33:39 -04:00
parent 8ec674e6e4
commit 5d35469a86
5 changed files with 51 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/target
.env
/result

16
default.nix Normal file
View File

@ -0,0 +1,16 @@
{ pkgs ? import <nixpkgs> { }, sources ? import ./nix/sources.nix
, naersk ? import sources.naersk { } }:
with pkgs;
let
srcNoTarget = dir:
builtins.filterSource
(path: type: type != "directory" || builtins.baseNameOf path != "target")
dir;
naersk = pkgs.callPackage sources.naersk { };
src = srcNoTarget ./.;
remapPathPrefix = true;
in naersk.buildPackage {
inherit src remapPathPrefix;
buildInputs = with pkgs; [ pkg-config openssl libgit2 ];
}

21
docker.nix Normal file
View File

@ -0,0 +1,21 @@
{ system ? builtins.currentSystem }:
let
pkgs = import <nixpkgs> { };
callPackage = pkgs.lib.callPackageWith pkgs;
gitea-release = callPackage ./default.nix { };
dockerImage = pkg:
pkgs.dockerTools.buildLayeredImage {
name = "xena/gitea-release";
tag = "${gitea-release.version}";
contents = [ pkg ];
config = {
Cmd = [ "/bin/gitea-release" "drone" ];
WorkingDir = "/";
};
};
in dockerImage gitea-release

View File

@ -1,4 +1,16 @@
{
"naersk": {
"branch": "master",
"description": "Build rust crates in Nix. No configuration, no code generation, no IFD. Sandbox friendly.",
"homepage": "",
"owner": "nmattia",
"repo": "naersk",
"rev": "a82fd7dc31a58c462b6dfa9d9d886fa2cc75dfd4",
"sha256": "00bjwir52y6jbf0b22qy9qxramw35k5fc7kp9hymr1zgpmw9kbwg",
"type": "tarball",
"url": "https://github.com/nmattia/naersk/archive/a82fd7dc31a58c462b6dfa9d9d886fa2cc75dfd4.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs-mozilla": {
"branch": "master",
"description": "mozilla related nixpkgs (extends nixos/nixpkgs repo)",

View File

@ -6,5 +6,6 @@ in pkgs.mkShell {
latest.rustChannels.stable.rust
openssl
pkg-config
libgit2
];
}