From 9d1abc0bc8f342de08eb4092da3ef5e482d20a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 2 Jan 2023 11:19:32 +0100 Subject: [PATCH] switch to flake-parts from flake-utils --- flake.lock | 23 +++++++++++------- flake.nix | 69 +++++++++++++++++++++++++++--------------------------- 2 files changed, 49 insertions(+), 43 deletions(-) diff --git a/flake.lock b/flake.lock index 3cbf13e..a2240e7 100644 --- a/flake.lock +++ b/flake.lock @@ -1,17 +1,22 @@ { "nodes": { - "flake-utils": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "lastModified": 1672616755, + "narHash": "sha256-dvwU2ORLpiP6ZMXL3CJ/qrqmtLBLF6VAc+Fois7Qfew=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "87673d7c13a799d95ce25ff5dc7b9e15f01af2ea", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, @@ -33,7 +38,7 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", + "flake-parts": "flake-parts", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 971dd6e..c934680 100644 --- a/flake.nix +++ b/flake.nix @@ -2,45 +2,46 @@ description = "Hydra's builtin hydra-eval-jobs as a standalone"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.flake-parts.url = "github:hercules-ci/flake-parts"; + inputs.flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; - outputs = - { self - , nixpkgs - , flake-utils - }: - flake-utils.lib.eachDefaultSystem ( - system: - let - nixVersion = nixpkgs.lib.fileContents ./.nix-version; - pkgs = nixpkgs.legacyPackages.${system}; - inherit (pkgs) stdenv; - devShell = self.devShells.${system}.default; - drvArgs = { - srcDir = self; - nix = if nixVersion == "unstable" then pkgs.nixUnstable else pkgs.nixVersions."nix_${nixVersion}"; - }; - in + outputs = inputs @ { flake-parts, ... }: + let + inherit (inputs.nixpkgs) lib; + inherit (inputs) self; + nixVersion = lib.fileContents ./.nix-version; + in + flake-parts.lib.mkFlake { inherit inputs; } { - packages.nix-eval-jobs = pkgs.callPackage ./default.nix drvArgs; + systems = inputs.nixpkgs.lib.systems.flakeExposed; + perSystem = { pkgs, self', ... }: + let + devShell = self'.devShells.default; + drvArgs = { + srcDir = self; + nix = if nixVersion == "unstable" then pkgs.nixUnstable else pkgs.nixVersions."nix_${nixVersion}"; + }; + in + { + packages.nix-eval-jobs = pkgs.callPackage ./default.nix drvArgs; - checks.treefmt = stdenv.mkDerivation { - name = "treefmt-check"; - src = self; - nativeBuildInputs = devShell.nativeBuildInputs; - dontConfigure = true; + checks.treefmt = pkgs.stdenv.mkDerivation { + name = "treefmt-check"; + src = self; + nativeBuildInputs = devShell.nativeBuildInputs; + dontConfigure = true; - inherit (devShell) NODE_PATH; + inherit (devShell) NODE_PATH; - buildPhase = '' - env HOME=$(mktemp -d) treefmt --fail-on-change - ''; + buildPhase = '' + env HOME=$(mktemp -d) treefmt --fail-on-change + ''; - installPhase = "touch $out"; - }; + installPhase = "touch $out"; + }; - packages.default = self.packages.${system}.nix-eval-jobs; - devShells.default = pkgs.callPackage ./shell.nix drvArgs; - } - ); + packages.default = self'.packages.nix-eval-jobs; + devShells.default = pkgs.callPackage ./shell.nix drvArgs; + }; + }; }