From 06fa652f9626590a9727f3ec8b48330ad3fcb78f Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Sun, 25 May 2025 00:56:17 +0200 Subject: [PATCH] feat: simplify flake.nix, correct package derivation --- default.nix | 7 +++++ flake.lock | 40 +++------------------------- flake.nix | 75 +++++++++++++++++++---------------------------------- 3 files changed, 36 insertions(+), 86 deletions(-) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..a7c0599 --- /dev/null +++ b/default.nix @@ -0,0 +1,7 @@ +{pkgs ? import {}}: +pkgs.rustPlatform.buildRustPackage { + pname = "pumo-system-information"; + version = "0.1.0"; + cargoLock.lockFile = ./Cargo.lock; + src = pkgs.lib.cleanSource ./.; +} diff --git a/flake.lock b/flake.lock index be5ef2d..45e9f61 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,5 @@ { "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1747744144, @@ -36,7 +18,6 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay" } @@ -48,11 +29,11 @@ ] }, "locked": { - "lastModified": 1747967795, - "narHash": "sha256-76s4jDRbQzxRO+5y8ilMp5V30qVgY9R6n8U7aOap8ig=", + "lastModified": 1748054080, + "narHash": "sha256-rwFiLLNCwkj9bqePtH1sMqzs1xmohE0Ojq249piMzF4=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "f1d5bfa8c692cacd798a3e1fb93d54c1b9ac701a", + "rev": "2221d8d53c128beb69346fa3ab36da3f19bb1691", "type": "github" }, "original": { @@ -60,21 +41,6 @@ "repo": "rust-overlay", "type": "github" } - }, - "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 a0a33a7..3b81ccc 100644 --- a/flake.nix +++ b/flake.nix @@ -1,61 +1,38 @@ { description = "System information in JSON format for eww"; - inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - flake-utils = { - url = "github:numtide/flake-utils"; - inputs.nixpkgs.follows = "nixpkgs"; - }; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - - outputs = - { - self, - nixpkgs, - flake-utils, - rust-overlay, - }: - flake-utils.lib.eachSystem [ "x86_64-linux" ] ( - system: - let - overlays = [ (import rust-overlay) ]; - pkgs = import nixpkgs { inherit system overlays; }; - rustVersion = (pkgs.rust-bin.fromRustupToolchainFile ./rustup-toolchain.toml); - rustPlatform = pkgs.makeRustPlatform { - cargo = rustVersion; - rustc = rustVersion; - }; - appName = "pumo-system-info"; - appRustBuild = rustPlatform.buildRustPackage { - pname = appName; - version = "0.1.0"; - src = ./.; - cargoLock.lockFile = ./Cargo.lock; - doCheck = true; - }; + outputs = { + nixpkgs, + rust-overlay, + ... + }: let + supportedSystems = ["x86_64-linux" "aarch64-linux"]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + pkgsFor = nixpkgs.legacyPackages; + in { + packages = forAllSystems (system: { + default = pkgsFor.${system}.callPackage ./. {}; + }); + formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); + devShells = forAllSystems ( + system: let + overlays = [(import rust-overlay)]; + pkgs = import nixpkgs {inherit system overlays;}; + rustVersion = pkgs.rust-bin.fromRustupToolchainFile ./rustup-toolchain.toml; in - { - packages.pumoSystemInfo = appRustBuild; - formatter = nixpkgs.legacyPackages.${system}.nixfmt-rfc-style; - defaultPackage = appRustBuild; - devShell = - with pkgs; - mkShell { - buildInputs = [ - bacon - cargo - cargo-deny - cargo-msrv - cargo-tarpaulin - just - rustVersion - ]; - }; - } + pkgs.mkShell { + buildInputs = with pkgs; [ + bacon + cargo + rustVersion + ]; + } ); + }; }