summaryrefslogtreecommitdiff
path: root/hostnix/mojo/flake.nix
blob: fecdd5004466d67cdaeaf48925d2d54cd8c7e2aa (plain)
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
{
  description = "nix-darwin system flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-25.11-darwin";
    nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    nix-darwin.url = "github:nix-darwin/nix-darwin/nix-darwin-25.11";
    nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = inputs@{ self, nix-darwin, nixpkgs, nixpkgs-unstable }:
  let
    configuration = { pkgs, ... }: {
      environment.systemPackages = let
        # TODO is there a better way to do this?
        pkgsUnstable = import nixpkgs-unstable {
          localSystem = pkgs.stdenv.system;
          config.allowUnfree = true;
        };
      in
        [
          pkgs.direnv
          pkgs.nix-direnv

          (pkgs.writeShellScriptBin "claude" ''
            exec /usr/bin/sandbox-exec -f ${self}/claude.sb \
              -D TARGET_DIR=$HOME/src \
              -D TMP_DIR=/tmp \
              -D HOME_DIR=$HOME \
              -D CACHE_DIR=$HOME/.cache \
              ${pkgsUnstable.claude-code}/bin/claude \
              --allow-dangerously-skip-permissions "$@"
          '')
          pkgsUnstable.jujutsu
        ];

      nix.settings.experimental-features = "nix-command flakes";

      system.primaryUser = "joe";

      # Set Git commit hash for darwin-version.
      system.configurationRevision = self.rev or self.dirtyRev or null;

      # Used for backwards compatibility, please read the changelog before changing.
      # $ darwin-rebuild changelog
      system.stateVersion = 6;

      # The platform the configuration will be used on.
      nixpkgs.hostPlatform = "aarch64-darwin";

      nixpkgs.config.allowUnfree = true;
    };

    apps = { pkgs, ... }: {
      homebrew = {
        enable = true;
        onActivation.cleanup = "uninstall";
        brews = [ "mas" ];
        casks = [ "linearmouse" ];
        masApps = {
          "Kagi for Safari" = 1622835804;
          "KeePassium (KeePass passwords)" = 1435127111;
          Xcode = 497799835;
        };
      };
    };
  in
  {
    darwinConfigurations.mojo = nix-darwin.lib.darwinSystem {
      modules = [ configuration apps ];
    };
  };
}