From 914d5f43698ea2a2f11644798377ddbc6d34954e Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Tue, 18 Jun 2024 17:44:21 +0200 Subject: [PATCH] ci: use flake-parts --- flake.lock | 52 +++++++++++++++++++++++++++--- flake.nix | 93 +++++++++++++++++++++++++++++++++--------------------- 2 files changed, 104 insertions(+), 41 deletions(-) diff --git a/flake.lock b/flake.lock index 783377eb..5592dc93 100644 --- a/flake.lock +++ b/flake.lock @@ -20,6 +20,26 @@ "type": "github" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1717285511, + "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -56,16 +76,15 @@ "root": { "inputs": { "crane": "crane", - "flake-utils": "flake-utils", + "flake-parts": "flake-parts", "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" + "rust-overlay": "rust-overlay", + "shelly": "shelly" } }, "rust-overlay": { "inputs": { - "flake-utils": [ - "flake-utils" - ], + "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" ] @@ -84,6 +103,29 @@ "type": "github" } }, + "shelly": { + "inputs": { + "flake-parts": [ + "flake-parts" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1718420551, + "narHash": "sha256-NU8NBXVPj0KuY4Tl/LtZPrbX3PmmmgPuhk/1pzm9cyk=", + "owner": "CertainLach", + "repo": "shelly", + "rev": "4f70221f3f9ad9058f590eefb25251b6760aaa47", + "type": "github" + }, + "original": { + "owner": "CertainLach", + "repo": "shelly", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index 981186b0..786efab7 100644 --- a/flake.nix +++ b/flake.nix @@ -2,28 +2,42 @@ description = "Jrsonnet"; inputs = { nixpkgs.url = "github:nixos/nixpkgs"; - flake-utils.url = "github:numtide/flake-utils"; rust-overlay = { url = "github:oxalica/rust-overlay"; - inputs = { - nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; - }; + inputs.nixpkgs.follows = "nixpkgs"; + }; + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; }; crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; }; + shelly = { + url = "github:CertainLach/shelly"; + inputs = { + flake-parts.follows = "flake-parts"; + nixpkgs.follows = "nixpkgs"; + }; + }; }; - outputs = { + outputs = inputs @ { nixpkgs, - flake-utils, + flake-parts, rust-overlay, crane, + shelly, ... }: - flake-utils.lib.eachDefaultSystem ( - system: let + flake-parts.lib.mkFlake {inherit inputs;} { + imports = [shelly.flakeModule]; + systems = ["x86_64-linux" "aarch64-linux" "armv7l-linux" "armv6l-linux" "mingw-w64"]; + perSystem = { + config, + system, + ... + }: let pkgs = import nixpkgs { inherit system; overlays = [rust-overlay.overlays.default]; @@ -32,14 +46,18 @@ rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; craneLib = (crane.mkLib pkgs).overrideToolchain rust; in { + legacyPackages = { + jsonnetImpls = { + go-jsonnet = pkgs.callPackage ./nix/go-jsonnet.nix {}; + sjsonnet = pkgs.callPackage ./nix/sjsonnet.nix {}; + jsonnet = pkgs.callPackage ./nix/jsonnet.nix {}; + # I didn't managed to build it, and nixpkgs version is marked as broken + # haskell-jsonnet = pkgs.callPackage ./nix/haskell-jsonnet.nix { }; + rsjsonnet = pkgs.callPackage ./nix/rsjsonnet.nix {}; + }; + }; packages = rec { default = jrsonnet; - go-jsonnet = pkgs.callPackage ./nix/go-jsonnet.nix {}; - sjsonnet = pkgs.callPackage ./nix/sjsonnet.nix {}; - jsonnet = pkgs.callPackage ./nix/jsonnet.nix {}; - # I didn't managed to build it, and nixpkgs version is marked as broken - # haskell-jsonnet = pkgs.callPackage ./nix/haskell-jsonnet.nix { }; - rsjsonnet = pkgs.callPackage ./nix/rsjsonnet.nix {}; jrsonnet = pkgs.callPackage ./nix/jrsonnet.nix { inherit craneLib; @@ -61,7 +79,7 @@ }; benchmarks = pkgs.callPackage ./nix/benchmarks.nix { - inherit go-jsonnet sjsonnet jsonnet rsjsonnet; + inherit (config.legacyPackages.jsonnetImpls) go-jsonnet sjsonnet jsonnet rsjsonnet; jrsonnetVariants = [ { drv = jrsonnet.override {forBenchmarks = true;}; @@ -70,7 +88,7 @@ ]; }; benchmarks-quick = pkgs.callPackage ./nix/benchmarks.nix { - inherit go-jsonnet sjsonnet jsonnet rsjsonnet; + inherit (config.legacyPackages.jsonnetImpls) go-jsonnet sjsonnet jsonnet rsjsonnet; quick = true; jrsonnetVariants = [ { @@ -80,7 +98,7 @@ ]; }; benchmarks-against-release = pkgs.callPackage ./nix/benchmarks.nix { - inherit go-jsonnet sjsonnet jsonnet rsjsonnet; + inherit (config.legacyPackages.jsonnetImpls) go-jsonnet sjsonnet jsonnet rsjsonnet; jrsonnetVariants = [ { drv = jrsonnet.override {forBenchmarks = true;}; @@ -97,7 +115,7 @@ ]; }; benchmarks-quick-against-release = pkgs.callPackage ./nix/benchmarks.nix { - inherit go-jsonnet sjsonnet jsonnet rsjsonnet; + inherit (config.legacyPackages.jsonnetImpls) go-jsonnet sjsonnet jsonnet rsjsonnet; quick = true; jrsonnetVariants = [ { @@ -115,22 +133,25 @@ ]; }; }; - devShells.default = craneLib.devShell { - packages = with pkgs; [ - alejandra - cargo-edit - cargo-asm - cargo-outdated - cargo-watch - cargo-insta - lld - hyperfine - graphviz - ] ++ lib.optionals (!stdenv.isDarwin) [ - valgrind - kcachegrind - ]; + shelly.shells.default = { + factory = craneLib.devShell; + packages = with pkgs; + [ + alejandra + cargo-edit + cargo-asm + cargo-outdated + cargo-watch + cargo-insta + lld + hyperfine + graphviz + ] + ++ lib.optionals (!stdenv.isDarwin) [ + valgrind + kcachegrind + ]; }; - } - ); + }; + }; }