{ pkgs, lib, inputs, outputs, ...}: let
  inherit (inputs) nixpkgs;
in {
  imports = [
    inputs.sops-nix-darwin.darwinModules.sops
    inputs.home-manager.darwinModules.home-manager
  ];

  # pin nixpkgs in the system flake registry to the revision used
  # to build the config
  nix.registry.nixpkgs.flake = nixpkgs;
  nixpkgs.config.allowUnfree = true;
  nixpkgs.config.overlays = [
    (final: prev: lib.optionalAttrs (prev.stdenv.system == "aarch64-darwin") {
      # Add access to x86 packages system is running Apple Silicon
      pkgs-x86 = import nixpkgs {
        system = "x86_64-darwin";
        config.allowUnfree = true;
      };
    })
    inputs.nixpkgs-firefox-darwin.overlay
  ];

  # Keep nix upgraded
  services.nix-daemon.enable = true;
  nix.package = pkgs.nix;

  # Enable flakes, and enrich apple silicon
  nix.extraOptions = ''
    experimental-features = nix-command flakes repl-flake
  ''+ lib.optionalString (pkgs.system == "aarch64-darwin") ''
    extra-platforms = x86_64-darwin aarch64-darwin
  '';

  programs.zsh.enable = true;
  programs.fish.enable = true;

  environment.shells = [
    pkgs.fish
    pkgs.zsh
    pkgs.bashInteractive
  ];
  users.users.root.shell = pkgs.fish;

  #system.configurationRevision = self.rev or self.dirtyRev or null;
  system.stateVersion = 4;

  security.pam.enableSudoTouchIdAuth = true;

  home-manager.extraSpecialArgs = { inherit inputs outputs; };

  environment.systemPackages = with pkgs; [
    iterm2    
  ];
}
