nix: don't use naersik to build package

This commit is contained in:
Dmitriy Pleshevskiy 2022-09-18 17:23:59 +03:00
parent c0b010e279
commit 38be5079ff
Signed by: pleshevskiy
GPG Key ID: 1B59187B161C0215
3 changed files with 35 additions and 72 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
.env* .env*
!.env.example !.env.example
.direnv

View File

@ -1,39 +1,6 @@
{ {
"nodes": { "nodes": {
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1655042882,
"narHash": "sha256-9BX8Fuez5YJlN7cdPO63InoyBy7dm3VlJkkmTt6fS1A=",
"owner": "nix-community",
"repo": "naersk",
"rev": "cddffb5aa211f50c4b8750adbec0bbbdfb26bb9f",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "master",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": {
"lastModified": 1659190188,
"narHash": "sha256-LudYrDFPFaQMW0l68TYkPWRPKmqpxIFU1nWfylIp9AQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a3fddd46a7f3418d7e3940ded94701aba569161d",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1659190188, "lastModified": 1659190188,
"narHash": "sha256-LudYrDFPFaQMW0l68TYkPWRPKmqpxIFU1nWfylIp9AQ=", "narHash": "sha256-LudYrDFPFaQMW0l68TYkPWRPKmqpxIFU1nWfylIp9AQ=",
@ -51,8 +18,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"naersk": "naersk", "nixpkgs": "nixpkgs",
"nixpkgs": "nixpkgs_2",
"utils": "utils" "utils": "utils"
} }
}, },

View File

@ -1,46 +1,41 @@
{ {
inputs = { inputs = {
naersk.url = "github:nix-community/naersk/master";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils"; utils.url = "github:numtide/flake-utils";
}; };
outputs = { self, nixpkgs, utils, naersk }: outputs = { self, nixpkgs, utils }:
utils.lib.eachDefaultSystem (system: let
let cargoToml = with builtins; (fromTOML (readFile ./Cargo.toml));
name = "vnetod";
pkgs = import nixpkgs { inherit system; };
naersk-lib = pkgs.callPackage naersk { };
in
rec {
# Executes by `nix build .#<name>`
packages = {
${name} = naersk.lib.${system}.buildPackage {
pname = name;
root = ./.;
};
};
# Executes by `nix build .`
packages.default = packages.${name};
# the same but deprecated in Nix 2.7
defaultPackage = packages.default;
# Executes by `nix run .#<name> -- <args?>` version = "${cargoToml.package.version}_${builtins.substring 0 8 self.lastModifiedDate}_${self.shortRev or "dirty"}";
apps = { in
${name} = utils.lib.mkApp { utils.lib.eachDefaultSystem
inherit name; (system:
drv = packages.${name}; let
}; inherit (nixpkgs) lib;
}; pkgs = import nixpkgs { inherit system; };
# Executes by `nix run . -- <args?>`
apps.default = apps.${name};
# the same but deprecated in Nix 2.7
defaultApp = apps.default;
# Used by `nix develop` vnetod = pkgs.rustPlatform.buildRustPackage {
devShell = with pkgs; mkShell { name = "vnetod-${version}";
buildInputs = [ cargo rustc rustfmt pre-commit rustPackages.clippy ];
RUST_SRC_PATH = rustPlatform.rustLibSrc; src = lib.cleanSource ./.;
}; cargoLock.lockFile = ./Cargo.lock;
});
doCheck = true;
};
in
{
apps.default = {
type = "app";
program = "${vnetod}/bin/vnetod";
};
packages.default = vnetod;
devShell = pkgs.mkShell {
packages = with pkgs; [ cargo rustc rustfmt clippy rust-analyzer ];
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
};
});
} }