diff --git a/flake.lock b/flake.lock deleted file mode 100644 index d8f51dd..0000000 --- a/flake.lock +++ /dev/null @@ -1,64 +0,0 @@ -{ - "nodes": { - "crane": { - "locked": { - "lastModified": 1769737823, - "narHash": "sha256-DrBaNpZ+sJ4stXm+0nBX7zqZT9t9P22zbk6m5YhQxS4=", - "owner": "ipetkov", - "repo": "crane", - "rev": "b2f45c3830aa96b7456a4c4bc327d04d7a43e1ba", - "type": "github" - }, - "original": { - "owner": "ipetkov", - "repo": "crane", - "type": "github" - } - }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1769996383, - "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1769900590, - "narHash": "sha256-I7Lmgj3owOTBGuauy9FL6qdpeK2umDoe07lM4V+PnyA=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "41e216c0ca66c83b12ab7a98cc326b5db01db646", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-25.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "crane": "crane", - "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 6cdc30b..0000000 --- a/flake.nix +++ /dev/null @@ -1,102 +0,0 @@ -{ - description = "manages multiple identities (e.g. personal, work, university, ...) in git repos for you"; - - inputs = { - crane.url = "github:ipetkov/crane"; - - flake-parts = { - url = "github:hercules-ci/flake-parts"; - inputs.nixpkgs-lib.follows = "nixpkgs"; - }; - - nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; - }; - - outputs = inputs @ { self, crane, ... }: - inputs.flake-parts.lib.mkFlake { inherit inputs; } ({ lib, ... }: { - systems = [ "x86_64-linux" "aarch64-linux" ]; - - perSystem = { pkgs, self', system, ... }: let - buildInputs = with pkgs; [ - gpgme - pkg-config - ]; - - nativeBuildInputs = with pkgs; [ - pkg-config - ]; - - crateSrc = lib.cleanSourceWith { - src = self.outPath; - filter = name: type: builtins.all (f: f name type) [ - lib.sources.cleanSourceFilter - (name: type: !(builtins.elem (builtins.baseNameOf name) [ "flake.nix" "flake.lock" ])) - ]; - }; - - craneArgs = { - src = crateSrc; - strictDeps = true; - - inherit buildInputs nativeBuildInputs; - }; - - craneLib = crane.mkLib pkgs; - - # Build the dependencies with different parameters - cargoArtifacts = craneLib.buildDepsOnly craneArgs; - - cargoTOML = builtins.fromTOML (builtins.readFile ./Cargo.toml); - in { - packages.xtask = (craneLib.buildPackage ( craneArgs // { - inherit cargoArtifacts; - - cargoExtraArgs = "--package xtask"; - - meta = { - licences = with lib.licences; [mit asl20]; - platforms = [ system ]; - mainProgram = "xtask"; - }; - })); - - packages.default = (craneLib.buildPackage ( craneArgs // { - inherit cargoArtifacts; - - nativeBuildInputs = craneArgs.nativeBuildInputs ++ [ self'.packages.xtask ]; - - postInstall = let - manDir = "$out/share/man/man1"; - in '' - mkdir -p "${manDir}" - xtask manpage "${manDir}" - find "${manDir}" -type f -exec gzip {} \; - ''; - - meta = { - licences = with lib.licences; [mit asl20]; - platforms = [ system ]; - mainProgram = cargoTOML.package.name; - } - // lib.optionalAttrs (lib.attrsets.hasAttrByPath ["package" "description"] cargoTOML) { - inherit (cargoTOML.package) description; - }; - })); - - apps.default = { - type = "app"; - program = let pkg = self'.packages.default; in "${pkg}/bin/${pkg.pname}"; - }; - - devShells.default = craneLib.devShell { - checks = self'.checks; - - inherit buildInputs nativeBuildInputs; - - packages = with pkgs; [ - # Cargo and rustc are provided by default. - ]; - }; - }; - }); -} diff --git a/xtask/src/manpage.rs b/xtask/src/manpage.rs index cf4e4f3..daaa9df 100644 --- a/xtask/src/manpage.rs +++ b/xtask/src/manpage.rs @@ -1,36 +1,25 @@ use std::path::PathBuf; use clap::{CommandFactory as _, Parser}; -use git_identity::cli; /// Render the manpage of git-identity from its clap definition #[derive(Parser)] pub struct Cli { - /// The directory in which to write the newly generated manpages + /// The file in which to write the newly generated manpage /// - /// By default, this is "./target" - out_dir: Option, + /// By default, this is "target/git-identity.1" + out_file: Option, } pub fn main(cli: Cli) -> anyhow::Result<()> { - let out_dir = cli.out_dir.unwrap_or_else(|| PathBuf::from("./target")); + let man = clap_mangen::Man::new(git_identity::cli::Cli::command()); + let mut buffer: Vec = Default::default(); + man.render(&mut buffer)?; - let render = |name: &'static str, command: clap::Command| -> anyhow::Result<()> { - let man = clap_mangen::Man::new(command.name(name)); - - let mut buffer = Vec::::new(); - man.render(&mut buffer)?; - - let mut out_path = out_dir.clone(); - out_path.push(man.get_filename()); - - std::fs::write(out_path, buffer)?; - - Ok(()) - }; - - render("git-identity", cli::Cli::command())?; - render("git-identity-import", cli::ImportCli::command())?; + std::fs::write( + cli.out_file.unwrap_or_else(|| "./target/git-identity.1".into()), + buffer, + )?; Ok(()) }