From 4132b747cae1a9b3edc814f35182c79f9f73ec3b Mon Sep 17 00:00:00 2001 From: a-kenji Date: Mon, 28 Feb 2022 13:42:53 +0100 Subject: [PATCH] Nix add man (#1148) * update(nix): add manpage to `man` output * fmt(nix): nixpkgs-fmt --- flake.nix | 173 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 89 insertions(+), 84 deletions(-) diff --git a/flake.nix b/flake.nix index 2312a25f..af11e7ca 100644 --- a/flake.nix +++ b/flake.nix @@ -19,111 +19,116 @@ "i686-linux" "x86_64-darwin" "x86_64-linux" - ] (system: - let - overlays = [ (import rust-overlay) ]; + ] + (system: + let + overlays = [ (import rust-overlay) ]; - pkgs = import nixpkgs { inherit system overlays; }; + pkgs = import nixpkgs { inherit system overlays; }; - name = "zellij"; - pname = name; - root = toString ./.; + name = "zellij"; + pname = name; + root = toString ./.; - ignoreSource = [ ".git" "target" ]; + ignoreSource = [ ".git" "target" ]; - src = pkgs.nix-gitignore.gitignoreSource ignoreSource root; + src = pkgs.nix-gitignore.gitignoreSource ignoreSource root; - rustToolchainToml = - pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain; - cargoLock = { lockFile = ./Cargo.lock; }; - cargo = rustToolchainToml; - rustc = rustToolchainToml; + rustToolchainToml = + pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain; + cargoLock = { lockFile = ./Cargo.lock; }; + cargo = rustToolchainToml; + rustc = rustToolchainToml; - #env - RUST_BACKTRACE = 1; + #env + RUST_BACKTRACE = 1; - buildInputs = [ - rustToolchainToml + buildInputs = [ + rustToolchainToml - # in order to run tests - pkgs.openssl - ]; + # in order to run tests + pkgs.openssl + ]; - nativeBuildInputs = [ - pkgs.installShellFiles - pkgs.copyDesktopItems + nativeBuildInputs = [ + # generates manpages + pkgs.mandown - # for openssl/openssl-sys - pkgs.pkg-config - ]; + pkgs.installShellFiles + pkgs.copyDesktopItems - devInputs = [ - pkgs.cargo-make - pkgs.rust-analyzer - pkgs.nixpkgs-fmt - # generates manpages - pkgs.mandown - # optimizes wasm binaries - pkgs.binaryen - ]; + # for openssl/openssl-sys + pkgs.pkg-config + ]; - in rec { + devInputs = [ + pkgs.cargo-make + pkgs.rust-analyzer + pkgs.nixpkgs-fmt + # optimizes wasm binaries + pkgs.binaryen + ]; - packages.zellij = - (pkgs.makeRustPlatform { inherit cargo rustc; }).buildRustPackage { - inherit src name cargoLock buildInputs nativeBuildInputs; + in + rec { - preCheck = '' - HOME=$TMPDIR - ''; + packages.zellij = + (pkgs.makeRustPlatform { inherit cargo rustc; }).buildRustPackage { + inherit src name cargoLock buildInputs nativeBuildInputs; - postInstall = '' + preCheck = '' + HOME=$TMPDIR + ''; - # explicit behavior - $out/bin/zellij setup --generate-completion bash > ./completions.bash - installShellCompletion --bash --name ${pname}.bash ./completions.bash - $out/bin/zellij setup --generate-completion fish > ./completions.fish - installShellCompletion --fish --name ${pname}.fish ./completions.fish - $out/bin/zellij setup --generate-completion zsh > ./completions.zsh - installShellCompletion --zsh --name _${pname} ./completions.zsh + postInstall = '' + mandown ./docs/MANPAGE.md > ./zellij.1 + installManPage ./zellij.1 - install -Dm644 ./assets/logo.png $out/share/icons/hicolor/scalable/apps/zellij.png + # explicit behavior + $out/bin/zellij setup --generate-completion bash > ./completions.bash + installShellCompletion --bash --name ${pname}.bash ./completions.bash + $out/bin/zellij setup --generate-completion fish > ./completions.fish + installShellCompletion --fish --name ${pname}.fish ./completions.fish + $out/bin/zellij setup --generate-completion zsh > ./completions.zsh + installShellCompletion --zsh --name _${pname} ./completions.zsh - copyDesktopItems - ''; + install -Dm644 ./assets/logo.png $out/share/icons/hicolor/scalable/apps/zellij.png - desktopItems = [ - (pkgs.makeDesktopItem { - type = "Application"; - inherit name; - desktopName = "zellij"; - terminal = true; - genericName = "Terminal multiplexer"; - comment = "Manage your terminal applications"; - exec = "zellij"; - icon = "zellij"; - categories = [ "ConsoleOnly;System" ]; - }) - ]; + copyDesktopItems + ''; - meta = with pkgs.lib; { - homepage = "https://github.com/zellij-org/zellij/"; - description = "A terminal workspace with batteries included"; - license = [ licenses.mit ]; + desktopItems = [ + (pkgs.makeDesktopItem { + type = "Application"; + inherit name; + desktopName = "zellij"; + terminal = true; + genericName = "Terminal multiplexer"; + comment = "Manage your terminal applications"; + exec = "zellij"; + icon = "zellij"; + categories = [ "ConsoleOnly;System" ]; + }) + ]; + + meta = with pkgs.lib; { + homepage = "https://github.com/zellij-org/zellij/"; + description = "A terminal workspace with batteries included"; + license = [ licenses.mit ]; + }; }; + + defaultPackage = packages.zellij; + + # nix run + apps.zellij = flake-utils.lib.mkApp { drv = packages.zellij; }; + defaultApp = apps.zellij; + + devShell = pkgs.mkShell { + name = "zellij-dev"; + inherit buildInputs RUST_BACKTRACE; + nativeBuildInputs = nativeBuildInputs ++ devInputs; }; - defaultPackage = packages.zellij; - - # nix run - apps.zellij = flake-utils.lib.mkApp { drv = packages.zellij; }; - defaultApp = apps.zellij; - - devShell = pkgs.mkShell { - name = "zellij-dev"; - inherit buildInputs RUST_BACKTRACE; - nativeBuildInputs = nativeBuildInputs ++ devInputs; - }; - - }); + }); }