From 4bd5075d5d4c8cf8b3f521564a649e0eff0ab495 Mon Sep 17 00:00:00 2001 From: 4o1x5 <4o1x5@4o1x5.dev> Date: Wed, 25 Sep 2024 03:56:42 +0200 Subject: [PATCH] flake: using crane now --- .gitignore | 1 + flake.lock | 69 +++++++++++++++++++++++---- flake.nix | 133 +++++++++++++++++++++++++++-------------------------- result | 1 - 4 files changed, 129 insertions(+), 75 deletions(-) delete mode 120000 result diff --git a/.gitignore b/.gitignore index ea8c4bf..c191f14 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +result \ No newline at end of file diff --git a/flake.lock b/flake.lock index d0ea0f7..24ecea6 100644 --- a/flake.lock +++ b/flake.lock @@ -1,24 +1,75 @@ { "nodes": { - "nixpkgs": { + "crane": { "locked": { - "lastModified": 1716137900, - "narHash": "sha256-sowPU+tLQv8GlqtVtsXioTKeaQvlMz/pefcdwg8MvfM=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "6c0b7a92c30122196a761b440ac0d46d3d9954f1", + "lastModified": 1727060013, + "narHash": "sha256-/fC5YlJy4IoAW9GhkJiwyzk0K/gQd9Qi4rRcoweyG9E=", + "owner": "ipetkov", + "repo": "crane", + "rev": "6b40cc876c929bfe1e3a24bf538ce3b5622646ba", "type": "github" }, "original": { - "id": "nixpkgs", - "ref": "nixos-unstable", - "type": "indirect" + "owner": "ipetkov", + "repo": "crane", + "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": { "inputs": { + "crane": "crane", + "flake-utils": "flake-utils", "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", diff --git a/flake.nix b/flake.nix index eb76131..3e836a4 100644 --- a/flake.nix +++ b/flake.nix @@ -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 }: - let - supportedSystems = - [ - "x86_64-linux" - "x86_64-darwin" - "aarch64-linux" - "aarch64-darwin" - ]; + crane.url = "github:ipetkov/crane"; - forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + flake-utils.url = "github:numtide/flake-utils"; + }; - nixpkgsFor = forAllSystems (system: import nixpkgs { - inherit system; - }); + outputs = { self, nixpkgs, crane, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; - in - { + craneLib = crane.mkLib pkgs; - packages = forAllSystems (system: - let - pkgs = nixpkgsFor.${system}; - in - { - default = pkgs.rustPlatform.buildRustPackage { - pname = "romodoro"; - version = "0.1.1"; - src = ./.; + commonArgs = { + src = craneLib.cleanCargoSource ./.; + strictDeps = true; + + nativeBuildInputs = with pkgs;[ + pkg-config + alsa-oss + alsa-lib.dev + 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 = - with nixpkgs; mkShell - { - LIBCLANG_PATH = "${pkgs.llvmPackages_17.libclang.lib}/lib"; - RUST_BACKTRACE = 1; - RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + packages.default = romodoro; - packages = with pkgs; [ - rustc - cargo - rustfmt - rust-analyzer - clippy - rustup - pkg-config - openssl - ]; - }; - }; + apps.default = flake-utils.lib.mkApp { + drv = romodoro; + }; + + devShells.default = craneLib.devShell { + # Inherit inputs from checks. + checks = self.checks.${system}; + + 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 + ]; + }; + }); } - - diff --git a/result b/result deleted file mode 120000 index 0df76cd..0000000 --- a/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/pgv753ssnznv9hlapz6c2vnh6fmw9pgg-romodoro-0.1.1 \ No newline at end of file