~yaymukund/dotfiles

dotfiles/hosts/work/flake.nix -rw-r--r-- 3.0 KiB
f1704db3 — Mukund Lakshman Add protobuf cli prerequisite for pigeon 7 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{
  description = "development environment for work laptop";
  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";

    dotfiles-private.url = "/Users/mukund.lakshman/src/dotfiles-private";
    lol = {
      url = "/Users/mukund.lakshman/src/lol";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    neovim.url = "path:../../common/neovim";
    zsh.url = "path:../../common/zsh";
  };

  outputs = {
    self,
    dotfiles-private,
    flake-utils,
    lol,
    neovim,
    nixpkgs,
    zsh
  }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};

        coder = pkgs.callPackage ./coder.nix {
          version = "1.31.0";
          sha256 = "IL+qxfp963dqDBBg+fuIV6ZmHGSFKOnyHUHFE0YB3z4=";
        };

        promptInit = zsh.mkPromptInit."${system}" {
          starshipOptions = {
            withUsername = true;
            prefix = "[•](purple)";
          };
        };

        wrappedTerraform = pkgs.writeShellScriptBin "terraform" ''
          # This is generated by ${toString ./flake.nix}
          $HOME/src/discord/.local/bin/terraform "$@"
        '';

        rebuildWorkspace = pkgs.writeShellScriptBin "coder-rebuild-workspace" ''
          # This is generated by ${toString ./flake.nix}
          set -e

          WORKSPACE_NAME="mukund-dev"
          WORKSPACE_SSH_URL="coder.$WORKSPACE_NAME"

          workspace_running() {
            coder workspaces ls -o json | \
            jq \
              -rce \
              --arg WORKSPACE_NAME $WORKSPACE_NAME \
              '. | any(
                .name == $WORKSPACE_NAME and
                .latest_stat.container_status == "on"
              )'
          }

          rebuild_workspace() {
            coder workspaces rebuild $WORKSPACE_NAME --follow
            ssh -t $WORKSPACE_SSH_URL 'bash -lc "$HOME/dotfiles/install-dev.sh"'
          }

          if workspace_running ; then
            echo "workspace '$WORKSPACE_NAME' already running"
          else
            echo "rebuilding $WORKSPACE_NAME"
            rebuild_workspace
          fi
        '';

        lolWithOptions = lol.withOptions."${system}" {
          config = { torrent = dotfiles-private.lol_torrent_config; };
        };
      in {
        packages.default = pkgs.mkShell {
          packages = with pkgs; [
            bat
            delta
            difftastic
            exa
            fd
            ffmpeg
            fzf
            git
            jq
            lftp
            mpv
            ripgrep
            starship
            teleport
            youtube-dl
            zoxide
            zsh-history-substring-search
          ] ++ [
            coder
            # firefox.default."${system}"
            lolWithOptions
            neovim.packages."${system}".default
            rebuildWorkspace
            wrappedTerraform
          ];

          shellHook = ''
            ${zsh.shellInit.${system}}
            ${promptInit}
          '';
        };
      });
}