Merge pull request #258 from yavko/use-crane

ci(nix): Add Crane and Naersk builders
This commit is contained in:
Jake Stanger 2023-07-26 22:51:16 +01:00 committed by GitHub
commit c094179fca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 248 additions and 56 deletions

View File

@ -1,9 +1,66 @@
{ {
"nodes": { "nodes": {
"crane": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1688772518,
"narHash": "sha256-ol7gZxwvgLnxNSZwFTDJJ49xVY5teaSvF7lzlo3YQfM=",
"owner": "ipetkov",
"repo": "crane",
"rev": "8b08e96c9af8c6e3a2b69af5a7fa168750fcf88e",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"inputs": { "inputs": {
"systems": "systems" "systems": "systems"
}, },
"locked": {
"lastModified": 1687709756,
"narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": { "locked": {
"lastModified": 1681202837, "lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
@ -18,13 +75,44 @@
"type": "github" "type": "github"
} }
}, },
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1688534083,
"narHash": "sha256-/bI5vsioXscQTsx+Hk9X5HfweeNZz/6kVKsbdqfwW7g=",
"owner": "nix-community",
"repo": "naersk",
"rev": "abca1fb7a6cfdd355231fc220c3d0302dbb4369a",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1688049487, "lastModified": 1687412861,
"narHash": "sha256-100g4iaKC9MalDjUW9iN6Jl/OocTDtXdeAj7pEGIRh4=", "narHash": "sha256-Z/g0wbL68C+mSGerYS2quv9FXQ1RRP082cAC0Bh4vcs=",
"path": "/nix/store/s1z7nb9n6r5n0r34fabp6yybwkbr8mjk-source",
"rev": "e603dc5f061ca1d8a19b3ede6a8cf9c9fcba6cdc",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1690179384,
"narHash": "sha256-+arbgqFTAtoeKtepW9wCnA0njCOyoiDFyl0Q0SBSOtE=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "4bc72cae107788bf3f24f30db2e2f685c9298dc9", "rev": "b12803b6d90e2e583429bb79b859ca53c348b39a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -36,23 +124,50 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs", "crane": "crane",
"rust-overlay": "rust-overlay" "naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay_2"
} }
}, },
"rust-overlay": { "rust-overlay": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": [
"crane",
"flake-utils"
],
"nixpkgs": [
"crane",
"nixpkgs"
]
},
"locked": {
"lastModified": 1688351637,
"narHash": "sha256-CLTufJ29VxNOIZ8UTg0lepsn3X03AmopmaLTTeHDCL4=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "f9b92316727af9e6c7fee4a761242f7f46880329",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"rust-overlay_2": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1688092301, "lastModified": 1690252178,
"narHash": "sha256-NTgT955DzXWVjHsuBn1t2K0x4hUghY7uE1jG2nGL5R4=", "narHash": "sha256-9oEz822bvbHobfCUjJLDor2BqW3I5tycIauzDlzOALY=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "4c31223801dd0f28ac15d60f2e5ddbd4d51ce17a", "rev": "8d64353ca827002fb8459e44d49116c78d868eba",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -75,6 +190,21 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"systems_2": {
"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", "root": "root",

View File

@ -6,11 +6,18 @@
url = "github:oxalica/rust-overlay"; url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk.url = "github:nix-community/naersk";
}; };
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
rust-overlay, rust-overlay,
crane,
naersk,
... ...
}: let }: let
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
@ -31,6 +38,11 @@
in { in {
overlays.default = final: prev: let overlays.default = final: prev: let
rust = mkRustToolchain final; rust = mkRustToolchain final;
craneLib = (crane.mkLib final).overrideToolchain rust;
naersk' = prev.callPackage naersk {
cargo = rust;
rustc = rust;
};
rustPlatform = prev.makeRustPlatform { rustPlatform = prev.makeRustPlatform {
cargo = rust; cargo = rust;
@ -42,11 +54,33 @@
(builtins.substring 4 2 longDate) (builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate) (builtins.substring 6 2 longDate)
]); ]);
builder = "naersk";
in { in {
ironbar = prev.callPackage ./nix/default.nix { ironbar = let
version = props.package.version + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty"); version = props.package.version + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
inherit rustPlatform; in
}; if builder == "crane"
then
prev.callPackage ./nix/default.nix {
inherit version;
inherit rustPlatform;
builderName = builder;
builder = craneLib;
}
else if builder == "naersk"
then
prev.callPackage ./nix/default.nix {
inherit version;
inherit rustPlatform;
builderName = builder;
builder = naersk';
}
else
prev.callPackage ./nix/default.nix {
inherit version;
inherit rustPlatform;
builderName = builder;
};
}; };
packages = genSystems ( packages = genSystems (
system: let system: let

View File

@ -19,49 +19,77 @@
lib, lib,
version ? "git", version ? "git",
features ? [], features ? [],
}: builderName ? "nix",
rustPlatform.buildRustPackage rec { builder ? {},
inherit version; }: let
pname = "ironbar"; basePkg = rec {
src = builtins.path { inherit version;
name = "ironbar"; pname = "ironbar";
path = lib.cleanSource ../.; src = builtins.path {
}; name = "ironbar";
buildNoDefaultFeatures = path = lib.cleanSource ../.;
if features == [] };
then false nativeBuildInputs = [pkg-config wrapGAppsHook gobject-introspection];
else true; buildInputs = [gtk3 gdk-pixbuf glib gtk-layer-shell glib-networking shared-mime-info gnome.adwaita-icon-theme hicolor-icon-theme gsettings-desktop-schemas libxkbcommon openssl];
buildFeatures = features; propagatedBuildInputs = [
cargoDeps = rustPlatform.importCargoLock { gtk3
lockFile = ../Cargo.lock; ];
}; preFixup = ''
cargoLock.lockFile = ../Cargo.lock; gappsWrapperArgs+=(
cargoLock.outputHashes."stray-0.1.3" = "sha256-7mvsWZFmPWti9AiX67h6ZlWiVVRZRWIxq3pVaviOUtc="; # Thumbnailers
nativeBuildInputs = [pkg-config wrapGAppsHook gobject-introspection]; --prefix XDG_DATA_DIRS : "${gdk-pixbuf}/share"
buildInputs = [gtk3 gdk-pixbuf glib gtk-layer-shell glib-networking shared-mime-info gnome.adwaita-icon-theme hicolor-icon-theme gsettings-desktop-schemas libxkbcommon openssl]; --prefix XDG_DATA_DIRS : "${librsvg}/share"
propagatedBuildInputs = [ --prefix XDG_DATA_DIRS : "${webp-pixbuf-loader}/share"
gtk3 --prefix XDG_DATA_DIRS : "${shared-mime-info}/share"
]; )
preFixup = '' '';
gappsWrapperArgs+=( passthru = {
# Thumbnailers updateScript = gnome.updateScript {
--prefix XDG_DATA_DIRS : "${gdk-pixbuf}/share" packageName = pname;
--prefix XDG_DATA_DIRS : "${librsvg}/share" attrPath = "gnome.${pname}";
--prefix XDG_DATA_DIRS : "${webp-pixbuf-loader}/share" };
--prefix XDG_DATA_DIRS : "${shared-mime-info}/share" };
) meta = with lib; {
''; homepage = "https://github.com/JakeStanger/ironbar";
passthru = { description = "Customisable gtk-layer-shell wlroots/sway bar written in rust.";
updateScript = gnome.updateScript { license = licenses.mit;
packageName = pname; platforms = platforms.linux;
attrPath = "gnome.${pname}"; mainProgram = "ironbar";
}; };
}; };
meta = with lib; { flags = let
homepage = "https://github.com/JakeStanger/ironbar"; noDefault =
description = "Customisable gtk-layer-shell wlroots/sway bar written in rust."; if features == []
license = licenses.mit; then ""
platforms = platforms.linux; else "--no-default-features";
mainProgram = "ironbar"; featuresStr =
}; if features == []
} then ""
else ''-F "${builtins.concatStringsSep "," features}"'';
in [noDefault featuresStr];
in
if builderName == "naersk"
then
builder.buildPackage (basePkg
// {
cargoOptions = old: old ++ flags;
})
else if builderName == "crane"
then
builder.buildPackage (basePkg
// {
cargoExtraArgs = builtins.concatStringsSep " " flags;
doCheck = false;
})
else
rustPlatform.buildRustPackage (basePkg
// {
buildNoDefaultFeatures =
if features == []
then false
else true;
buildFeatures = features;
cargoDeps = rustPlatform.importCargoLock {lockFile = ../Cargo.lock;};
cargoLock.lockFile = ../Cargo.lock;
cargoLock.outputHashes."stray-0.1.3" = "sha256-7mvsWZFmPWti9AiX67h6ZlWiVVRZRWIxq3pVaviOUtc=";
})