flake.nix 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. {
  2. description = "Elvish configuration";
  3. inputs = {
  4. nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
  5. };
  6. outputs = { self, nixpkgs }:
  7. {
  8. packages.x86_64-linux.carapace-bin =
  9. with import nixpkgs {
  10. system = "x86_64-linux";
  11. };
  12. buildGoModule rec {
  13. pname = "carapace-bin";
  14. version = "0.19.0";
  15. src = fetchFromGitHub {
  16. owner = "rsteube";
  17. repo = "carapace-bin";
  18. rev = "v${version}";
  19. sha256 = "sha256-Bdtuehfp81fq1ZSV+7jwSmxViu8FzVbBGoZ2HfDda5g=";
  20. };
  21. ldflags = [ "-s" "-w" ];
  22. patches = [
  23. # https://github.com/rsteube/carapace-bin/pull/1480
  24. ./carapace-nix-build.patch
  25. ];
  26. tags = [ "release" ];
  27. subPackages = [ "cmd/carapace" ];
  28. preBuild = ''
  29. go generate ./...
  30. '';
  31. vendorSha256 = "sha256-WXntyDbpGEXHkYgv21vN/JG/CVn6SqnMhmgXfFEQ9eM=";
  32. };
  33. packages.x86_64-linux.elvish =
  34. with import nixpkgs {
  35. system = "x86_64-linux";
  36. };
  37. let
  38. carapace-bin = self.packages.x86_64-linux.carapace-bin;
  39. config = runCommand "elvish-config" {
  40. nativeBuildInputs = [ makeWrapper ];
  41. } ''
  42. mkdir -p $out/elvish
  43. cp -r ${./lib} $out/elvish/lib
  44. cat <<EOF > $out/elvish/rc.elv
  45. use config
  46. eval (carapace _carapace|slurp)
  47. EOF
  48. '';
  49. in
  50. writeScriptBin "elvish" ''
  51. #!/bin/sh
  52. export XDG_DATA_DIRS="${config}:$XDG_DATA_DIRS"
  53. export PATH="${carapace-bin}/bin:$PATH"
  54. if [ -z "$KEYCTL_INIT" ]; then
  55. export KEYCTL_INIT=1
  56. keyctl new_session >/dev/null
  57. fi
  58. exec ${elvish}/bin/elvish -rc "${config}/elvish/rc.elv" "$@"
  59. '';
  60. packages.x86_64-linux.default = self.packages.x86_64-linux.elvish;
  61. };
  62. }