From d196f9d314089cf90ecd0f279271ef7036000afc Mon Sep 17 00:00:00 2001 From: Leandro Lisboa Penz Date: Mon, 13 Feb 2023 23:01:04 +0000 Subject: [PATCH] flake.nix: multi-platform support with flake-utils --- flake.lock | 16 ++++++++++++++++ flake.nix | 28 ++++++++++++++++++---------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index 6708ba2..c2238fe 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,20 @@ { "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1674120619, @@ -18,6 +33,7 @@ }, "root": { "inputs": { + "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 32d7b3d..5722d6f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,15 +1,23 @@ { description = "Execute a command periodically, showing the output only when it changes"; - inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable; - outputs = { self, nixpkgs }: { - packages.x86_64-linux.default = - with import nixpkgs { system = "x86_64-linux"; }; - rustPlatform.buildRustPackage { - pname = "ogle"; - version = "1.4.4"; - src = self; - cargoLock.lockFile = ./Cargo.lock; - }; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages."${system}"; + in + rec { + packages.default = pkgs.rustPlatform.buildRustPackage { + pname = "ogle"; + version = "1.4.4"; + src = self; + cargoLock.lockFile = ./Cargo.lock; + }; + } + ); }