wip: deb VM

This commit is contained in:
shimun 2021-07-29 01:37:29 +02:00
parent 38b3a77b78
commit a776c00c69
Signed by: shimun
GPG Key ID: E81D8382DC2F971B
2 changed files with 70 additions and 10 deletions

35
flake.lock generated
View File

@ -1,5 +1,21 @@
{ {
"nodes": { "nodes": {
"cargo-deb": {
"flake": false,
"locked": {
"lastModified": 1627137192,
"narHash": "sha256-zDAwiETJquiViEvBKMuI9WWgSGhVDscL/m1ufKJENBw=",
"owner": "mmstick",
"repo": "cargo-deb",
"rev": "f603d105b4641e00640e46b189c6ee0c8f084de2",
"type": "github"
},
"original": {
"owner": "mmstick",
"repo": "cargo-deb",
"type": "github"
}
},
"naersk": { "naersk": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -7,11 +23,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1612192764, "lastModified": 1623927034,
"narHash": "sha256-7EnLtZQWP6511G1ZPA7FmJlqAr3hWsAYb24tvTvJ/ec=", "narHash": "sha256-sGxlmfp5eXL5sAMNqHSb04Zq6gPl+JeltIZ226OYN0w=",
"owner": "nmattia", "owner": "nmattia",
"repo": "naersk", "repo": "naersk",
"rev": "6e149bfd726a8ebefa415f2d713ba6d942435abd", "rev": "e09c320446c5c2516d430803f7b19f5833781337",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -22,11 +38,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1613208951, "lastModified": 1627245147,
"narHash": "sha256-pxDu+9KZBnZkMcKBqSAqw1oQwTIbxTeIwcMtygLsWio=", "narHash": "sha256-CQzH/4Mbhcx1HD+dtD7pZ0dHUZvX4eKN9b8Ifzz4gC4=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "2118cf551b9944cfdb929b8ea03556f097dd0381", "rev": "23098f20376cd1c874af476e5d8ef9169105b020",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -36,6 +52,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"cargo-deb": "cargo-deb",
"naersk": "naersk", "naersk": "naersk",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"utils": "utils" "utils": "utils"
@ -43,11 +60,11 @@
}, },
"utils": { "utils": {
"locked": { "locked": {
"lastModified": 1610051610, "lastModified": 1623875721,
"narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=", "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc", "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -3,13 +3,17 @@
inputs = { inputs = {
utils.url = "github:numtide/flake-utils"; utils.url = "github:numtide/flake-utils";
cargo-deb = {
flake = false;
url = "github:mmstick/cargo-deb";
};
naersk = { naersk = {
url = "github:nmattia/naersk"; url = "github:nmattia/naersk";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
outputs = { self, nixpkgs, utils, naersk }: outputs = { self, nixpkgs, utils, naersk, cargo-deb }:
let let
root = ./.; root = ./.;
pname = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.name; pname = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.name;
@ -28,6 +32,45 @@
packages.${pname} = naersk-lib.buildPackage { packages.${pname} = naersk-lib.buildPackage {
inherit pname root buildInputs nativeBuildInputs LIBCLANG_PATH; inherit pname root buildInputs nativeBuildInputs LIBCLANG_PATH;
}; };
packages."${pname}-deb" =
let
cargoDeb = naersk-lib.buildPackage {
pname = "cargo-deb";
root = cargo-deb;
};
pkg = packages.${pname};
vm = pkgs.vmTools.diskImageFuns.ubuntu1804x86_64 { extraPackages = [ "cargo" "cryptsetup" "libclang-dev" "libcryptsetup-dev" ]; };
makefile = pkgs.writeText "Makefile" "
.PHONY: install
cargo-deb:
cargo install --debug --path cargo-deb
install: cargo-deb
cargo-deb
mkdir -p debs
cp target/debian/*.deb debs/
";
src = pkgs.runCommandLocal "${pname}-vendored" {} ''
mkdir -p $out/.cargo $out/cargo-deb/.cargo
printf '${pkg.cargoconfig}' > $out/.cargo/config.toml;
printf '${cargoDeb.cargoconfig}' > $out/cargo-deb/.cargo/config.toml;
printf '.PHONY: install\ninstall:\n\tcargo install --debug --path cargo-deb\n\tcargo-deb\n\tmkdir -p debs\n\tcp target/debian/*.deb debs/' > $out/Makefile
cp -r ${pkg.src}/. $out/
cp -r ${cargoDeb.src}/. $out/cargo-deb/
'';
args = {
diskImage = vm;
inherit src;
name = pname;
buildInputs = [ ];
meta.description = "No descr";
};
in
pkgs.releaseTools.debBuild args;
defaultPackage = packages.${pname}; defaultPackage = packages.${pname};
# `nix run` # `nix run`