20 src = fetchFromGitHub {
21 owner = "common-fate";
24 sha256 = "sha256-sIn6D0696QPo4fs7HzvQNIopIfYYV4fYLmVdwQZnZag=";
27 vendorHash = "sha256-QswW1PyxrVWf6ZAPKW69q0JIXpyhSHucE5A7hkr8uxw=";
29 nativeBuildInputs = [ makeWrapper ];
34 "-X github.com/common-fate/granted/internal/build.Version=v${version}"
35 "-X github.com/common-fate/granted/internal/build.Commit=${src.rev}"
36 "-X github.com/common-fate/granted/internal/build.Date=1970-01-01-00:00:01"
37 "-X github.com/common-fate/granted/internal/build.BuiltBy=Nix"
46 # assume depends on assumego, so we add (placeholder "out") to its path
47 addToAssumePath = lib.makeBinPath [
53 ln -s $out/bin/granted $out/bin/assumego
55 # Create script with correct permissions
56 install -Dm755 /dev/null $out/bin/assume
58 # assume is a script that must be sourced
59 # We can't wrap it because it inspects $0 and calls return, which can only
60 # be done in sourced scripts.
61 # So instead we insert the following snippet into the beginning of the
62 # script to add to PATH.
63 # This is borrowed from wrapProgram --suffix PATH :
64 addToPath="$(cat << 'EOF'
66 PATH=''${PATH:+':'$PATH':'}
67 if [[ $PATH != *':'''${addToAssumePath}''':'* ]]; then
68 PATH=$PATH'${addToAssumePath}'
77 # Insert below the #!/bin/sh shebang
78 echo "$addToPath" | sed "/#!\/bin\/sh/r /dev/stdin" $src/scripts/assume >> $out/bin/assume
80 + lib.optionalString withFish ''
82 install -Dm755 $src/scripts/assume.fish $out/share/assume.fish
83 substituteInPlace $out/share/assume.fish \
84 --replace /bin/fish ${fish}/bin/fish
87 nativeInstallCheckInputs = [ versionCheckHook ];
88 doInstallCheck = true;
90 passthru.updateScript = nix-update-script { };
93 description = "Easiest way to access your cloud";
94 homepage = "https://github.com/common-fate/granted";
95 changelog = "https://github.com/common-fate/granted/releases/tag/${version}";
96 license = licenses.mit;
97 maintainers = with maintainers; [