123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- {
- description = "Elvish configuration";
- inputs = {
- nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
- flake-utils.url = "github:numtide/flake-utils";
- };
- outputs = { self, nixpkgs, flake-utils }:
- flake-utils.lib.eachDefaultSystem (system:
- with nixpkgs.legacyPackages.${system}; {
- packages.carapace-bin = buildGo121Module rec {
- pname = "carapace-bin";
- version = "0.27.0";
- src = fetchFromGitHub {
- owner = "rsteube";
- repo = "carapace-bin";
- rev = "v${version}";
- hash = "sha256-UcJbWOYkNUJEilJL/LG5o+I1ugqEOEGfs+uvKUMnTMU=";
- };
- ldflags = [ "-s" "-w" ];
- tags = [ "release" ];
- subPackages = [ "cmd/carapace" ];
- preBuild = ''
- go generate ./...
- '';
- vendorSha256 = "sha256-PN8ARsJQqRj333ervoy24PZoWkrCIYiGxOovzEhPNZQ=";
- };
- packages.elvish =
- let
- carapace-bin = self.packages.${system}.carapace-bin;
- config = runCommand "elvish-config" {
- nativeBuildInputs = [ makeWrapper ];
- } ''
- mkdir -p $out/elvish
- cp -r ${./lib} $out/elvish/lib
- cat <<EOF > $out/elvish/rc.elv
- use config
- eval (carapace _carapace|slurp)
- EOF
- '';
- in
- writeScriptBin "elvish" ''
- #!/bin/sh
- export XDG_DATA_DIRS="${config}:$XDG_DATA_DIRS"
- export PATH="${carapace-bin}/bin:$PATH"
- if command -v keyctl > /dev/null && [ -z "$KEYCTL_INIT" ]; then
- export KEYCTL_INIT=1
- keyctl new_session >/dev/null
- fi
- if [ -z "$XDG_RUNTIME_DIR" ] && [ -n "$TMPDIR" ]; then
- export XDG_RUNTIME_DIR="$TMPDIR"
- fi
- exec ${elvish}/bin/elvish -rc "${config}/elvish/rc.elv" "$@"
- '';
- packages.default = self.packages.${system}.elvish;
- }
- );
- }
|