flake.nix 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. {
  2. description = "Elvish configuration";
  3. inputs = {
  4. nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
  5. flake-utils.url = "github:numtide/flake-utils";
  6. };
  7. outputs = { self, nixpkgs, flake-utils }:
  8. flake-utils.lib.eachDefaultSystem (system:
  9. with nixpkgs.legacyPackages.${system}; {
  10. packages.carapace-bin = buildGoModule rec {
  11. pname = "carapace-bin";
  12. version = "0.28.5";
  13. src = fetchFromGitHub {
  14. owner = "rsteube";
  15. repo = "carapace-bin";
  16. rev = "v${version}";
  17. hash = "sha256-mprwDx1SvvT96MR1YgLwIJaEHCknCkbJ9zq0HfNJy/Y=";
  18. };
  19. ldflags = [ "-s" "-w" ];
  20. tags = [ "release" ];
  21. subPackages = [ "cmd/carapace" ];
  22. preBuild = ''
  23. go generate ./...
  24. '';
  25. vendorHash = "sha256-rR0mLO8jjhTPySQ/BTegNe9kd2DudULOuYBBB/P9K1s=";
  26. };
  27. packages.elvish =
  28. let
  29. carapace-bin = self.packages.${system}.carapace-bin;
  30. config = runCommand "elvish-config" {
  31. nativeBuildInputs = [ makeWrapper ];
  32. } ''
  33. mkdir -p $out/elvish
  34. cp -r ${./lib} $out/elvish/lib
  35. cat <<EOF > $out/elvish/rc.elv
  36. use config
  37. eval (carapace _carapace|slurp)
  38. EOF
  39. '';
  40. in
  41. writeScriptBin "elvish" ''
  42. #!/bin/sh
  43. export XDG_DATA_DIRS="${config}:$XDG_DATA_DIRS"
  44. export PATH="${carapace-bin}/bin:$PATH"
  45. if command -v keyctl > /dev/null && [ -z "$KEYCTL_INIT" ]; then
  46. export KEYCTL_INIT=1
  47. keyctl new_session >/dev/null
  48. fi
  49. if [ -z "$XDG_RUNTIME_DIR" ] && [ -n "$TMPDIR" ]; then
  50. export XDG_RUNTIME_DIR="$TMPDIR"
  51. fi
  52. exec ${elvish}/bin/elvish -rc "${config}/elvish/rc.elv" "$@"
  53. '';
  54. packages.default = self.packages.${system}.elvish;
  55. }
  56. );
  57. }