mirror of
https://github.com/lelgenio/demoji.git
synced 2025-01-18 12:46:25 -03:00
Update to use crane
This commit is contained in:
parent
afe472b3e3
commit
19ece99761
132
flake.lock
132
flake.lock
|
@ -1,22 +1,138 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"advisory-db": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1673800717,
|
||||
"narHash": "sha256-SFHraUqLSu5cC6IxTprex/nTsI81ZQAtDvlBvGDWfnA=",
|
||||
"path": "/nix/store/d6vlzbp9x6ixk1d1gr7if0f2ji6s8q4v-source",
|
||||
"rev": "2f9fd351ec37f5d479556cd48be4ca340da59b8f",
|
||||
"type": "path"
|
||||
"lastModified": 1675868798,
|
||||
"narHash": "sha256-ghS+rNMYKidm9HQtRQQ1SRs30SXRR11s73GjtXfyWG4=",
|
||||
"owner": "rustsec",
|
||||
"repo": "advisory-db",
|
||||
"rev": "b485cf4db1e37d03433c505c7675c2656f59874a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
"owner": "rustsec",
|
||||
"repo": "advisory-db",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"crane": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1675814591,
|
||||
"narHash": "sha256-RuO67fK41LFbKmcE3m1BoIAfFOcrpAlk0jGso/kWK1c=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "972ef2af69c4b25ec6c8583f55f7b07c956c811c",
|
||||
"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": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1675698036,
|
||||
"narHash": "sha256-BgsQkQewdlQi8gapJN4phpxkI/FCE/2sORBaFcYbp/A=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "1046c7b92e908a1202c0f1ba3fc21d19e1cf1b62",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"advisory-db": "advisory-db",
|
||||
"crane": "crane",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"crane",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"crane",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1675391458,
|
||||
"narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
123
flake.nix
123
flake.nix
|
@ -1,29 +1,110 @@
|
|||
{
|
||||
description = "Pick emojis using dmenu";
|
||||
inputs = { };
|
||||
outputs = { self, nixpkgs, ... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
description = "Build a cargo project";
|
||||
|
||||
definition = { pkgs, languages ? [ ] }:
|
||||
pkgs.rustPlatform.buildRustPackage {
|
||||
pname = "demoji";
|
||||
version = "0.1";
|
||||
src = pkgs.lib.cleanSource ./.;
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
cargoBuildFlags = if languages == [ ] then "--all-features" else "--features ${pkgs.lib.concatStringSep "," languages}";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
|
||||
crane = {
|
||||
url = "github:ipetkov/crane";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
advisory-db = {
|
||||
url = "github:rustsec/advisory-db";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, crane, flake-utils, advisory-db, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
|
||||
outputs = with pkgs; {
|
||||
packages.${system} = {
|
||||
default = self.packages.${system}.demoji;
|
||||
demoji = pkgs.callPackage definition { };
|
||||
inherit (pkgs) lib;
|
||||
|
||||
craneLib = crane.lib.${system};
|
||||
src = craneLib.cleanCargoSource ./.;
|
||||
|
||||
buildInputs = [
|
||||
# Add additional build inputs here
|
||||
];
|
||||
|
||||
# Build *just* the cargo dependencies, so we can reuse
|
||||
# all of that work (e.g. via cachix) when running in CI
|
||||
cargoArtifacts = craneLib.buildDepsOnly {
|
||||
inherit src buildInputs;
|
||||
};
|
||||
|
||||
devShells.${system}.default =
|
||||
mkShell { nativeBuildInputs = [ xorg.libxcb ]; };
|
||||
};
|
||||
# Build the actual crate itself, reusing the dependency
|
||||
# artifacts from above.
|
||||
my-crate = craneLib.buildPackage {
|
||||
inherit cargoArtifacts src buildInputs;
|
||||
};
|
||||
in
|
||||
{
|
||||
checks = {
|
||||
# Build the crate as part of `nix flake check` for convenience
|
||||
inherit my-crate;
|
||||
|
||||
in outputs;
|
||||
# Run clippy (and deny all warnings) on the crate source,
|
||||
# again, resuing the dependency artifacts from above.
|
||||
#
|
||||
# Note that this is done as a separate derivation so that
|
||||
# we can block the CI if there are issues here, but not
|
||||
# prevent downstream consumers from building our crate by itself.
|
||||
my-crate-clippy = craneLib.cargoClippy {
|
||||
inherit cargoArtifacts src buildInputs;
|
||||
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
||||
};
|
||||
|
||||
my-crate-doc = craneLib.cargoDoc {
|
||||
inherit cargoArtifacts src buildInputs;
|
||||
};
|
||||
|
||||
# Check formatting
|
||||
my-crate-fmt = craneLib.cargoFmt {
|
||||
inherit src;
|
||||
};
|
||||
|
||||
# Audit dependencies
|
||||
my-crate-audit = craneLib.cargoAudit {
|
||||
inherit src advisory-db;
|
||||
};
|
||||
|
||||
# Run tests with cargo-nextest
|
||||
# Consider setting `doCheck = false` on `my-crate` if you do not want
|
||||
# the tests to run twice
|
||||
my-crate-nextest = craneLib.cargoNextest {
|
||||
inherit cargoArtifacts src buildInputs;
|
||||
partitions = 1;
|
||||
partitionType = "count";
|
||||
};
|
||||
} // lib.optionalAttrs (system == "x86_64-linux") {
|
||||
# NB: cargo-tarpaulin only supports x86_64 systems
|
||||
# Check code coverage (note: this will not upload coverage anywhere)
|
||||
my-crate-coverage = craneLib.cargoTarpaulin {
|
||||
inherit cargoArtifacts src;
|
||||
};
|
||||
};
|
||||
|
||||
packages.default = my-crate;
|
||||
|
||||
apps.default = flake-utils.lib.mkApp {
|
||||
drv = my-crate;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
inputsFrom = builtins.attrValues self.checks;
|
||||
|
||||
# Extra inputs can be added here
|
||||
nativeBuildInputs = with pkgs; [
|
||||
cargo
|
||||
rustc
|
||||
];
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::{io::Write, time::Duration};
|
|||
|
||||
use arboard::SetExtLinux;
|
||||
use clap::Parser;
|
||||
use emoji;
|
||||
use emoji::lookup_by_glyph::iter_emoji;
|
||||
|
||||
/// Simple program to list all emojis
|
||||
#[derive(Parser, Debug)]
|
||||
|
@ -39,7 +39,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
fn pick_emoji_dmenu(c: &Vec<String>, args: &Args) -> char {
|
||||
fn pick_emoji_dmenu(c: &[String], args: &Args) -> char {
|
||||
let child_stdout = if args.copy {
|
||||
std::process::Stdio::piped()
|
||||
} else {
|
||||
|
@ -76,12 +76,12 @@ fn send_to_clipboard(out: String) {
|
|||
|
||||
let mut clip = arboard::Clipboard::new().unwrap();
|
||||
|
||||
clip.set().wait().text(out.clone()).unwrap();
|
||||
clip.set().wait().text(out).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
fn write_emojis_to_stdout(args: &Args, mut out: impl Write) {
|
||||
for emoji in emoji::lookup_by_glyph::iter_emoji() {
|
||||
for emoji in iter_emoji() {
|
||||
let native_description = emoji_description(emoji, &args.lang);
|
||||
let fallback_description = emoji_description(emoji, "en");
|
||||
let basic_description = emoji.name.to_string();
|
||||
|
|
Loading…
Reference in a new issue