1
0

flake.nix 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. {
  2. description = "The EZA flake for developing and releasing (soon)";
  3. inputs = {
  4. flake-utils.url = "github:numtide/flake-utils";
  5. naersk.url = "github:nix-community/naersk";
  6. nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
  7. treefmt-nix.url = "github:numtide/treefmt-nix";
  8. rust-overlay.url = "github:oxalica/rust-overlay";
  9. };
  10. outputs = {
  11. self,
  12. flake-utils,
  13. naersk,
  14. nixpkgs,
  15. treefmt-nix,
  16. rust-overlay,
  17. }:
  18. flake-utils.lib.eachDefaultSystem (
  19. system: let
  20. overlays = [(import rust-overlay)];
  21. pkgs = (import nixpkgs) {
  22. inherit system overlays;
  23. };
  24. toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
  25. naersk' = pkgs.callPackage naersk {
  26. cargo = toolchain;
  27. rustc = toolchain;
  28. clippy = toolchain;
  29. };
  30. treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
  31. buildInputs = with pkgs; lib.optionals stdenv.isDarwin [libiconv darwin.apple_sdk.frameworks.Security];
  32. in rec {
  33. # For `nix fmt`
  34. formatter = treefmtEval.config.build.wrapper;
  35. packages = {
  36. # For `nix build` `nix run`, & `nix profile install`:
  37. default = naersk'.buildPackage {
  38. pname = "eza";
  39. version = "latest";
  40. src = ./.;
  41. doCheck = true; # run `cargo test` on build
  42. # buildInputs = with pkgs; [ zlib ]
  43. # ++ lib.optionals stdenv.isDarwin [ libiconv Security ];
  44. buildInputs = buildInputs ++ (with pkgs; [zlib]);
  45. nativeBuildInputs = with pkgs; [cmake pkg-config installShellFiles pandoc];
  46. buildNoDefaultFeatures = true;
  47. # buildFeatures = lib.optional gitSupport "git";
  48. buildFeatures = "git";
  49. # outputs = [ "out" "man" ];
  50. postInstall = ''
  51. pandoc --standalone -f markdown -t man man/eza.1.md > man/eza.1
  52. pandoc --standalone -f markdown -t man man/eza_colors.5.md > man/eza_colors.5
  53. pandoc --standalone -f markdown -t man man/eza_colors-explanation.5.md > man/eza_colors-explanation.5
  54. installManPage man/eza.1 man/eza_colors.5 man/eza_colors-explanation.5
  55. installShellCompletion \
  56. --bash completions/bash/eza \
  57. --fish completions/fish/eza.fish \
  58. --zsh completions/zsh/_eza
  59. '';
  60. meta = with pkgs.lib; {
  61. description = "A modern, maintained replacement for ls";
  62. longDescription = ''
  63. eza is a modern replacement for ls. It uses colours for information by
  64. default, helping you distinguish between many types of files, such as
  65. whether you are the owner, or in the owning group. It also has extra
  66. features not present in the original ls, such as viewing the Git status
  67. for a directory, or recursing into directories with a tree view. eza is
  68. written in Rust, so it’s small, fast, and portable.
  69. '';
  70. homepage = "https://github.com/eza-community/eza";
  71. license = licenses.mit;
  72. mainProgram = "eza";
  73. maintainers = with maintainers; [cafkafk];
  74. };
  75. };
  76. # Run `nix build .#check` to check code
  77. check = naersk'.buildPackage {
  78. src = ./.;
  79. mode = "check";
  80. inherit buildInputs;
  81. };
  82. # Run `nix build .#test` to run tests
  83. test = naersk'.buildPackage {
  84. src = ./.;
  85. mode = "test";
  86. inherit buildInputs;
  87. };
  88. # Run `nix build .#clippy` to lint code
  89. clippy = naersk'.buildPackage {
  90. src = ./.;
  91. mode = "clippy";
  92. inherit buildInputs;
  93. };
  94. vhs = pkgs.buildGoModule rec {
  95. pname = "vhs";
  96. version = "0.6.0";
  97. src = pkgs.fetchFromGitHub {
  98. owner = "PThorpe92";
  99. repo = pname;
  100. rev = "70ff84c3b192a2f3379adf56dd873c63bc8163ac";
  101. hash = "sha256-QgE9XpJKZSJDjY2Z2GC1ndWgwXOJaB1fzvGUGFFf5XM=";
  102. };
  103. vendorHash = "sha256-zugGnhLrqqqVjMFZrO4rrSj3UzyHWpLra1rxyGG2ga4=";
  104. nativeBuildInputs = with pkgs; [installShellFiles makeWrapper];
  105. ldflags = ["-s" "-w" "-X=main.Version=${version}"];
  106. postInstall = ''
  107. wrapProgram $out/bin/vhs --prefix PATH : ${pkgs.lib.makeBinPath (pkgs.lib.optionals pkgs.stdenv.isLinux [pkgs.chromium] ++ [pkgs.ffmpeg pkgs.ttyd])}
  108. $out/bin/vhs man > vhs.1
  109. installManPage vhs.1
  110. installShellCompletion --cmd vhs \
  111. --bash <($out/bin/vhs completion bash) \
  112. --fish <($out/bin/vhs completion fish) \
  113. --zsh <($out/bin/vhs completion zsh)
  114. '';
  115. meta = with pkgs.lib; {
  116. description = "A tool for generating terminal GIFs with code";
  117. homepage = "https://github.com/charmbracelet/vhs";
  118. changelog = "https://github.com/charmbracelet/vhs/releases/tag/v${version}";
  119. license = licenses.mit;
  120. maintainers = with maintainers; [cafkafk];
  121. };
  122. };
  123. };
  124. # For `nix develop`:
  125. devShells.default = pkgs.mkShell {
  126. nativeBuildInputs = with pkgs; [toolchain just pandoc packages.vhs convco];
  127. };
  128. # For `nix flake check`
  129. checks = {
  130. formatting = treefmtEval.config.build.check self;
  131. build = packages.check;
  132. test = packages.test;
  133. lint = packages.clippy;
  134. };
  135. }
  136. );
  137. }