flake.nix 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.20.3";
  15. src = fetchFromGitHub {
  16. owner = "rsteube";
  17. repo = "carapace-bin";
  18. rev = "v${version}";
  19. hash = "sha256-oPTMStq8YOM+HWiWajbMJSxUuHowhMI3P0HR+Ns+CGI=";
  20. };
  21. ldflags = [ "-s" "-w" ];
  22. tags = [ "release" ];
  23. subPackages = [ "cmd/carapace" ];
  24. preBuild = ''
  25. go generate ./...
  26. '';
  27. vendorSha256 = "sha256-IrdJDezB8fs2ypACY7Kn7FBfuh+T63yuEr5FA1Erfxw=";
  28. };
  29. packages.x86_64-linux.elvish =
  30. with import nixpkgs {
  31. system = "x86_64-linux";
  32. };
  33. let
  34. carapace-bin = self.packages.x86_64-linux.carapace-bin;
  35. config = runCommand "elvish-config" {
  36. nativeBuildInputs = [ makeWrapper ];
  37. } ''
  38. mkdir -p $out/elvish
  39. cp -r ${./lib} $out/elvish/lib
  40. cat <<EOF > $out/elvish/rc.elv
  41. use config
  42. eval (carapace _carapace|slurp)
  43. EOF
  44. '';
  45. in
  46. writeScriptBin "elvish" ''
  47. #!/bin/sh
  48. export XDG_DATA_DIRS="${config}:$XDG_DATA_DIRS"
  49. export PATH="${carapace-bin}/bin:$PATH"
  50. if [ -z "$KEYCTL_INIT" ]; then
  51. export KEYCTL_INIT=1
  52. keyctl new_session >/dev/null
  53. fi
  54. exec ${elvish}/bin/elvish -rc "${config}/elvish/rc.elv" "$@"
  55. '';
  56. packages.x86_64-linux.default = self.packages.x86_64-linux.elvish;
  57. };
  58. }