1{
2 description = "multi device configuration flake";
3 inputs = {
4 nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
5
6 home-manager.url = "github:nix-community/home-manager/master";
7 home-manager.inputs.nixpkgs.follows = "nixpkgs";
8
9 rust-overlay.url = "github:oxalica/rust-overlay";
10 rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
11
12 apple-fonts.url = "github:nmarks413/apple-fonts.nix";
13
14 nvf.url = "github:notashelf/nvf";
15 nvf.inputs.nixpkgs.follows = "nixpkgs";
16
17 darwin.url = "github:lnl7/nix-darwin/master";
18 darwin.inputs.nixpkgs.follows = "nixpkgs";
19
20 zig.url = "github:mitchellh/zig-overlay";
21 zls.url = "github:zigtools/zls?rev=a26718049a8657d4da04c331aeced1697bc7652b";
22
23 moonlight.url = "github:moonlight-mod/moonlight"; # Add `/develop` to the flake URL to use nightly.
24 moonlight.inputs.nixpkgs.follows = "nixpkgs";
25
26 zen-browser = {
27 url = "github:youwen5/zen-browser-flake";
28 inputs.nixpkgs.follows = "nixpkgs";
29 };
30
31 android-nixpkgs = {
32 url = "github:tadfisher/android-nixpkgs/stable";
33 inputs.nixpkgs.follows = "nixpkgs";
34
35 };
36
37 vicinae.url = "github:vicinaehq/vicinae";
38
39 nix-options-search.url = "github:madsbv/nix-options-search";
40
41 nix-index-database.url = "github:nix-community/nix-index-database";
42 nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
43 };
44 outputs =
45 {
46 self,
47 nixpkgs,
48 darwin,
49 ...
50 }@inputs:
51 let
52 inherit (nixpkgs) lib;
53
54 overlays = [
55 inputs.zig.overlays.default
56 inputs.rust-overlay.overlays.default
57 inputs.android-nixpkgs.overlays.default
58
59 # https://github.com/NixOS/nixpkgs/issues/513245#issuecomment-4320293674
60 (_: prev: {
61 openldap = prev.openldap.overrideAttrs {
62 doCheck = !prev.stdenv.hostPlatform.isi686;
63 };
64 })
65
66 # https://github.com/LnL7/nix-darwin/issues/1041
67 (_: prev: {
68 karabiner-elements = prev.karabiner-elements.overrideAttrs (old: {
69 version = "14.13.0";
70
71 src = prev.fetchurl {
72 inherit (old.src) url;
73 hash = "sha256-gmJwoht/Tfm5qMecmq1N6PSAIfWOqsvuHU8VDJY8bLw=";
74 };
75 });
76 })
77
78 # Copy-on-write checkouts; exported from ~/dev/jj change trunyqzm.
79 (_: prev: {
80 jujutsu = prev.jujutsu.overrideAttrs (old: {
81 patches = old.patches or [ ] ++ [ ./packages/jujutsu/copy-on-write-checkouts.patch ];
82 });
83 })
84
85 # custom packages
86 (_: pkgs: {
87 autofmt = pkgs.callPackage ./packages/autofmt { };
88 exiled_exchange_2 = pkgs.callPackage ./packages/exiled_exchange_2 { };
89 awakened_poe_trade = pkgs.callPackage ./packages/awakened_poe_trade { };
90 mtga-draft-17lands = pkgs.callPackage ./packages/17lands { };
91 })
92 ];
93
94 # We only use x86_64 on Linux and Apple Silicon Macs
95 # Overlays are applied here, as early as possible.
96 getNixPkgs = system: import nixpkgs { inherit system overlays; };
97 systems = {
98 "x86_64-linux" = getNixPkgs "x86_64-linux";
99 "aarch64-darwin" = getNixPkgs "aarch64-darwin";
100 };
101 forAllSystems =
102 f:
103 builtins.mapAttrs # #
104 (system: pkgs: f (inputs // { inherit system pkgs; }))
105 systems;
106
107 # Library Functions
108 mkNeovim = import ./lib/mkNeovim.nix { inherit self inputs; };
109 mkSystem = import ./lib/mkSystem.nix { inherit inputs mkNeovim overlays; };
110 in
111 rec {
112 # "nix fmt"
113 formatter = forAllSystems (inputs: inputs.pkgs.autofmt);
114 packages = forAllSystems (
115 { system, pkgs, ... }:
116 {
117 nvim-clover = mkNeovim "clover" pkgs;
118 nvim-fish = mkNeovim "fish" pkgs;
119 nvim-natalie = mkNeovim "natalie" pkgs;
120
121 inherit (pkgs) autofmt;
122 }
123 // lib.optionalAttrs (system == "aarch64-darwin") {
124 # "nix run .#darwin-rebuild"
125 inherit (darwin.packages.aarch64-darwin) darwin-rebuild;
126 }
127 );
128
129 # natalie's desktop computer
130 nixosConfigurations.nixos = mkSystem "nixos" {
131 user = "natalie";
132 host = "desktop";
133 system = "x86_64-linux";
134 };
135 # natalie's laptop
136 darwinConfigurations."Natalies-MacBook-Air" = mkSystem "Natalies-MacBook-Air" {
137 user = "natalie";
138 host = "laptop";
139 system = "aarch64-darwin";
140 };
141
142 # clover's mac studio "sandwich"
143 darwinConfigurations.sandwich = mkSystem "sandwich" {
144 user = "clover";
145 host = "sandwich";
146 system = "aarch64-darwin";
147 };
148 # clover's macbook air "paperback"
149 darwinConfigurations.paperback = mkSystem "paperback" {
150 user = "clover";
151 host = "paperback";
152 system = "aarch64-darwin";
153 };
154 # clover's work macbook pro
155 darwinConfigurations.clover-work-mac = mkSystem "clover-work-mac" {
156 user = "clover";
157 host = "work";
158 system = "aarch64-darwin";
159 };
160
161 # fish's cattop
162 nixosConfigurations.cattop = mkSystem "cattop" {
163 user = "fish";
164 host = "cattop";
165 system = "x86_64-linux";
166 };
167
168 # generate checks for "nix flake check --all-systems --no-build"
169 # checks.aarch64-darwin = builtins.listToAttrs (
170 # builtins.map (
171 # name:
172 # let
173 # d = darwinConfigurations.${name}.system;
174 # in
175 # {
176 # name = "darwinConfiguration-" + d.name;
177 # value = d;
178 # }
179 # ) (builtins.attrNames darwinConfigurations)
180 # );
181 };
182}