Simplified flake definition
This commit is contained in:
parent
48298b3190
commit
553d4d8760
5 changed files with 66 additions and 116 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1,3 @@
|
|||
/target
|
||||
.direnv
|
||||
result
|
||||
|
|
58
default.nix
58
default.nix
|
@ -1,51 +1,7 @@
|
|||
# (import (
|
||||
# fetchTarball {
|
||||
# url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
|
||||
# sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; }
|
||||
# ) {
|
||||
# src = ./.;
|
||||
# }).defaultNix
|
||||
{ lib
|
||||
, naersk
|
||||
, stdenv
|
||||
, clangStdenv
|
||||
, hostPlatform
|
||||
, targetPlatform
|
||||
, pkg-config
|
||||
, libiconv
|
||||
, rustfmt
|
||||
, cargo
|
||||
, rustc
|
||||
, openssl
|
||||
}:
|
||||
let cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
|
||||
in
|
||||
naersk.lib."${targetPlatform.system}".buildPackage rec {
|
||||
src = ./.;
|
||||
|
||||
buildInputs = [
|
||||
rustfmt
|
||||
pkg-config
|
||||
cargo
|
||||
rustc
|
||||
libiconv
|
||||
openssl
|
||||
];
|
||||
|
||||
checkInputs = [ cargo rustc ];
|
||||
doCheck = true;
|
||||
|
||||
CARGO_BUILD_INCREMENTAL = "false";
|
||||
RUST_BACKTRACE = "full";
|
||||
copyLibs = true;
|
||||
|
||||
name = cargoToml.package.name;
|
||||
version = cargoToml.package.version;
|
||||
|
||||
meta = with lib; {
|
||||
description = cargoToml.package.description;
|
||||
homepage = cargoToml.package.homepage;
|
||||
license = with licenses; [ mit ];
|
||||
maintainers = with maintainers; [ ];
|
||||
};
|
||||
}
|
||||
(import (
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
|
||||
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; }
|
||||
) {
|
||||
src = ./.;
|
||||
}).defaultNix
|
||||
|
|
18
flake.lock
18
flake.lock
|
@ -51,7 +51,23 @@
|
|||
"root": {
|
||||
"inputs": {
|
||||
"naersk": "naersk",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1637014545,
|
||||
"narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
97
flake.nix
97
flake.nix
|
@ -3,74 +3,43 @@
|
|||
inputs = {
|
||||
naersk.url = "github:nmattia/naersk/master";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, naersk }:
|
||||
let
|
||||
cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
|
||||
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
|
||||
in
|
||||
{
|
||||
overlay = final: prev: {
|
||||
"${cargoToml.package.name}" = final.callPackage ./. { inherit naersk; };
|
||||
};
|
||||
|
||||
packages = forAllSystems (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
self.overlay
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
"${cargoToml.package.name}" = pkgs."${cargoToml.package.name}";
|
||||
});
|
||||
|
||||
defaultPackage = forAllSystems (system: (import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ self.overlay ];
|
||||
})."${cargoToml.package.name}");
|
||||
|
||||
checks = forAllSystems (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ self.overlay ];
|
||||
};
|
||||
in
|
||||
{
|
||||
format = pkgs.runCommand "check-format"
|
||||
{
|
||||
buildInputs = with pkgs; [ rustfmt cargo ];
|
||||
} ''
|
||||
${pkgs.rustfmt}/bin/cargo-fmt fmt --manifest-path ${./.}/Cargo.toml -- --check
|
||||
${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.}
|
||||
touch $out
|
||||
'';
|
||||
"${cargoToml.package.name}" = pkgs."${cargoToml.package.name}";
|
||||
}
|
||||
);
|
||||
|
||||
devShell = forAllSystems (system:
|
||||
let pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ self.overlay ];
|
||||
outputs = { self, nixpkgs, utils, naersk }:
|
||||
utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
naersk-lib = pkgs.callPackage naersk { };
|
||||
in
|
||||
rec {
|
||||
overlay = final: prev: {
|
||||
ha-now-playing = final.callPackage ./.;
|
||||
};
|
||||
in
|
||||
pkgs.mkShell {
|
||||
inputsFrom = with pkgs; [
|
||||
pkgs."${cargoToml.package.name}"
|
||||
|
||||
packages.ha-now-playing = naersk-lib.buildPackage {
|
||||
pname = "ha-now-playing";
|
||||
root = ./.;
|
||||
|
||||
buildInputs = with pkgs;[
|
||||
openssl
|
||||
];
|
||||
buildInputs = with pkgs; [
|
||||
rustfmt
|
||||
nixpkgs-fmt
|
||||
nativeBuildInputs = with pkgs; [
|
||||
pkg-config
|
||||
];
|
||||
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
defaultPackage = packages.ha-now-playing;
|
||||
|
||||
apps.ha-now-playing = utils.lib.mkApp {
|
||||
drv = self.defaultPackage."${system}";
|
||||
};
|
||||
defaultApp = apps.ha-now-playing;
|
||||
|
||||
devShell = with pkgs; mkShell {
|
||||
buildInputs = [ cargo rustc rustfmt pre-commit rustPackages.clippy ];
|
||||
RUST_SRC_PATH = rustPlatform.rustLibSrc;
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
|
7
shell.nix
Normal file
7
shell.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
(import (
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
|
||||
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; }
|
||||
) {
|
||||
src = ./.;
|
||||
}).shellNix
|
Loading…
Reference in a new issue