Reproducible dotfiles in nix
1{
2 description = "Example Darwin system flake";
3
4 inputs = {
5 nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6 nix-darwin.url = "github:LnL7/nix-darwin";
7 nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
8 home-manager.url = "github:nix-community/home-manager";
9 home-manager.inputs.nixpkgs.follows = "nixpkgs";
10 zig.url = "github:mitchellh/zig-overlay";
11 zls-flake = {
12 url = "github:zigtools/zls";
13 inputs.nixpkgs.follows = "nixpkgs";
14 };
15 superhtml.url = "https://flakehub.com/f/ethanholz/superhtml-flake/0.6.2.tar.gz";
16 ziggy.url = "github:kristoff-it/ziggy";
17 carbonfox = {
18 url = "https://raw.githubusercontent.com/EdenEast/nightfox.nvim/refs/heads/main/extra/carbonfox/carbonfox.ghostty";
19 flake = false;
20 };
21 determinate.url = "https://flakehub.com/f/DeterminateSystems/determinate/3";
22 flake-parts.url = "github:hercules-ci/flake-parts";
23 git-hooks-nix = {
24 url = "github:cachix/git-hooks.nix";
25 inputs.nixpkgs.follows = "nixpkgs";
26 };
27 };
28
29 outputs = inputs @ {self, ...}: let
30 mkDarwin = self.my_lib.mkDarwin {};
31 in
32 inputs.flake-parts.lib.mkFlake {inherit inputs;} {
33 flake = {
34 my_lib = import ./lib {inherit inputs;};
35 darwinConfigurations."Ethans-Laptop" = mkDarwin {
36 system = "aarch64-darwin";
37 };
38 homeConfigurations."ethan" = let
39 userName = "ethan";
40 in
41 inputs.home-manager.lib.homeManagerConfiguration {
42 pkgs = import inputs.nixpkgs {
43 system = "x86_64-linux";
44 config.allowUnfree = true;
45 };
46 extraSpecialArgs = {
47 inherit inputs userName;
48 };
49 modules = [
50 ({pkgs, ...}: {
51 imports = [
52 (import ./lib/shared/home.nix {inherit inputs pkgs userName;})
53 (import ./lib/shared/lsp.nix {inherit inputs pkgs;})
54 (import ./lib/shared/python.nix {inherit inputs pkgs;})
55 (import ./lib/shared/nix.nix {inherit inputs pkgs;})
56 ];
57 })
58 ];
59 };
60 };
61
62 systems = ["aarch64-darwin" "x86_64-linux"];
63 perSystem = {
64 pkgs,
65 system,
66 ...
67 }: let
68 pre-commit-config = {
69 src = ./.;
70 hooks = {
71 alejandra.enable = true;
72 flake-checker.enable = true;
73 };
74 package = pkgs.prek;
75 };
76 in {
77 formatter = let
78 config = (inputs.git-hooks-nix.lib.${system}.run pre-commit-config).config;
79 inherit (config) package configFile;
80 script = ''
81 ${pkgs.lib.getExe package} run --all-files --config ${configFile}
82 '';
83 in
84 pkgs.writeShellScriptBin "pre-commit-run" script;
85
86 # # Run the hooks in a sandbox with `nix flake check`.
87 # # Read-only filesystem and no internet access.
88 # checks = {
89 # pre-commit-check = inputs.git-hooks-nix.lib.${system}.run pre-commit-config;
90 # };
91
92 devShells.default = pkgs.mkShell {
93 buildInputs = [pkgs.just pkgs.jq];
94 };
95 };
96 };
97}