flake: using crane now

This commit is contained in:
2005 2024-09-25 03:56:42 +02:00
parent 44eaf50255
commit 4bd5075d5d
4 changed files with 129 additions and 75 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
/target /target
result

View file

@ -1,24 +1,75 @@
{ {
"nodes": { "nodes": {
"nixpkgs": { "crane": {
"locked": { "locked": {
"lastModified": 1716137900, "lastModified": 1727060013,
"narHash": "sha256-sowPU+tLQv8GlqtVtsXioTKeaQvlMz/pefcdwg8MvfM=", "narHash": "sha256-/fC5YlJy4IoAW9GhkJiwyzk0K/gQd9Qi4rRcoweyG9E=",
"owner": "NixOS", "owner": "ipetkov",
"repo": "nixpkgs", "repo": "crane",
"rev": "6c0b7a92c30122196a761b440ac0d46d3d9954f1", "rev": "6b40cc876c929bfe1e3a24bf538ce3b5622646ba",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "owner": "ipetkov",
"ref": "nixos-unstable", "repo": "crane",
"type": "indirect" "type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1726560853,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1727089097,
"narHash": "sha256-ZMHMThPsthhUREwDebXw7GX45bJnBCVbfnH1g5iuSPc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "568bfef547c14ca438c56a0bece08b8bb2b71a9c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
} }
}, },
"root": { "root": {
"inputs": { "inputs": {
"crane": "crane",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

133
flake.nix
View file

@ -1,77 +1,80 @@
{ {
description = "romodoro builder"; description = "Romodoro flake";
inputs.nixpkgs.url = "nixpkgs/nixos-unstable"; inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs }: crane.url = "github:ipetkov/crane";
let
supportedSystems =
[
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; flake-utils.url = "github:numtide/flake-utils";
};
nixpkgsFor = forAllSystems (system: import nixpkgs { outputs = { self, nixpkgs, crane, flake-utils, ... }:
inherit system; flake-utils.lib.eachDefaultSystem (system:
}); let
pkgs = nixpkgs.legacyPackages.${system};
in craneLib = crane.mkLib pkgs;
{
packages = forAllSystems (system: commonArgs = {
let src = craneLib.cleanCargoSource ./.;
pkgs = nixpkgsFor.${system}; strictDeps = true;
in
{ nativeBuildInputs = with pkgs;[
default = pkgs.rustPlatform.buildRustPackage { pkg-config
pname = "romodoro"; alsa-oss
version = "0.1.1"; alsa-lib.dev
src = ./.; alsa-utils
git
cmake
];
buildInputs = with pkgs;[
alsa-oss
alsa-lib.dev
alsa-utils
git
pkg-config
git
cmake
];
};
romodoro = craneLib.buildPackage (commonArgs // {
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
nativeBuildInputs = [
pkgs.pkg-config
pkgs.alsa-oss
pkgs.alsa-lib.dev
pkgs.alsa-utils
pkgs.git
pkgs.cmake
];
buildInputs = [
pkgs.alsa-oss
pkgs.alsa-lib.dev
pkgs.alsa-utils
pkgs.git
pkgs.pkg-config
pkgs.git
pkgs.cmake
];
cargoLock.lockFile = ./Cargo.lock;
};
}); });
in
{
checks = {
inherit romodoro;
};
devShells.default = packages.default = romodoro;
with nixpkgs; mkShell
{
LIBCLANG_PATH = "${pkgs.llvmPackages_17.libclang.lib}/lib";
RUST_BACKTRACE = 1;
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
packages = with pkgs; [ apps.default = flake-utils.lib.mkApp {
rustc drv = romodoro;
cargo };
rustfmt
rust-analyzer devShells.default = craneLib.devShell {
clippy # Inherit inputs from checks.
rustup checks = self.checks.${system};
pkg-config
openssl LIBCLANG_PATH = "${pkgs.llvmPackages_17.libclang.lib}/lib";
]; RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
}; packages = with pkgs; [
}; openssl
pkg-config
libiconv
alsa-oss
alsa-lib.dev
alsa-utils
git
pkg-config
git
cmake
];
};
});
} }

1
result
View file

@ -1 +0,0 @@
/nix/store/pgv753ssnznv9hlapz6c2vnh6fmw9pgg-romodoro-0.1.1