241 lines
7.6 KiB
Nix
241 lines
7.6 KiB
Nix
{
|
|
description = "mat's nix configs";
|
|
|
|
inputs = {
|
|
# Package sets
|
|
nixpkgs.url = github:NixOS/nixpkgs/nixpkgs-21.11-darwin;
|
|
nixpkgs-unstable.url = github:NixOS/nixpkgs/nixpkgs-unstable;
|
|
nixpkgs-master.url = github:NixOS/nixpkgs/master;
|
|
|
|
# Environment/system management
|
|
darwin.url = github:lnl7/nix-darwin/master;
|
|
darwin.inputs.nixpkgs.follows = "nixpkgs-unstable";
|
|
home-manager.url = github:nix-community/home-manager;
|
|
home-manager.inputs.nixpkgs.follows = "nixpkgs-unstable";
|
|
|
|
# Config "flag" for disabling homebrew
|
|
homebrew-enabled.url = github:boolean-option/true;
|
|
|
|
# Other sources
|
|
flake-utils.url = github:numtide/flake-utils;
|
|
flake-compat = {
|
|
url = github:edolstra/flake-compat;
|
|
flake = false;
|
|
};
|
|
dark-mode-notify-src = {
|
|
url = github:bouk/dark-mode-notify;
|
|
flake = false;
|
|
};
|
|
luar-src = {
|
|
url = github:gustavo-hms/luar;
|
|
flake = false;
|
|
};
|
|
smarttab-kak-src = {
|
|
url = github:andreyorst/smarttab.kak;
|
|
flake = false;
|
|
};
|
|
};
|
|
|
|
outputs = { self, darwin, nixpkgs, home-manager, flake-utils, ... }@inputs:
|
|
let
|
|
|
|
inherit (darwin.lib) darwinSystem;
|
|
inherit (inputs.nixpkgs-unstable.lib)
|
|
attrValues
|
|
genAttrs
|
|
makeOverridable
|
|
optional
|
|
optionalAttrs
|
|
singleton;
|
|
|
|
# Configuration for `nixpkgs`
|
|
nixpkgsConfig = {
|
|
config = { allowUnfree = true; };
|
|
overlays = attrValues self.overlays ++ singleton (
|
|
final: prev:
|
|
let
|
|
pkgs = import ./pkgs {
|
|
inherit inputs genAttrs;
|
|
inherit (final) callPackage;
|
|
};
|
|
in
|
|
pkgs // optionalAttrs (prev.stdenv.system == "aarch64-darwin")
|
|
{
|
|
# Sub in x86 version of packages that don't build on Apple Silicon yet
|
|
inherit (final.pkgs-x86);
|
|
}
|
|
);
|
|
};
|
|
|
|
# Shared home-manager configs
|
|
homeManagerStateVersion = "22.05";
|
|
homeManagerCommonConfig = {
|
|
imports = attrValues self.homeManagerModules ++ [
|
|
./home
|
|
{ home.stateVersion = homeManagerStateVersion; }
|
|
];
|
|
};
|
|
|
|
# Modules shared by most `nix-darwin` personal configurations.
|
|
nixDarwinCommonModules = attrValues self.darwinModules ++ [
|
|
# Main `nix-darwin` config
|
|
./darwin
|
|
# `home-manager` module
|
|
home-manager.darwinModules.home-manager
|
|
(
|
|
{ config, lib, pkgs, ... }:
|
|
let
|
|
inherit (config.users) primaryUser;
|
|
in
|
|
{
|
|
nixpkgs = nixpkgsConfig;
|
|
# Hack to support legacy worklows that use `<nixpkgs>` etc.
|
|
nix.nixPath = { nixpkgs = "$HOME/dotfiles.nix/nixpkgs.nix"; };
|
|
# `home-manager` config
|
|
users.users.${primaryUser}.home = "/Users/${primaryUser}";
|
|
home-manager.useGlobalPkgs = true;
|
|
home-manager.users.${primaryUser} = homeManagerCommonConfig;
|
|
# Add a registry entry for this flake
|
|
nix.registry.my.flake = self;
|
|
}
|
|
)
|
|
];
|
|
in
|
|
{
|
|
# `nix-darwin` configs
|
|
darwinConfigurations = rec {
|
|
# Mininal configurations to bootstrap systems
|
|
bootstrap-x86 = makeOverridable darwinSystem {
|
|
system = "x86_64-darwin";
|
|
modules = [ ./darwin/bootstrap.nix { nixpkgs = nixpkgsConfig; } ];
|
|
};
|
|
bootstrap-arm = bootstrap-x86.override { system = "aarch64-darwin"; };
|
|
|
|
# M1 MBP
|
|
matbook = darwinSystem {
|
|
system = "aarch64-darwin";
|
|
modules = nixDarwinCommonModules ++ [
|
|
{
|
|
users.primaryUser = "mat";
|
|
networking.computerName = "matbook pro m1";
|
|
networking.hostName = "matbook";
|
|
networking.knownNetworkServices = [
|
|
"Wi-Fi"
|
|
];
|
|
}
|
|
];
|
|
};
|
|
|
|
# Config with small modifications needed/desired for CI with GitHub workflow
|
|
githubCI = darwinSystem {
|
|
system = "x86_64-darwin";
|
|
modules = nixDarwinCommonModules ++ [
|
|
({ lib, ... }: {
|
|
users.primaryUser = "runner";
|
|
homebrew.enable = lib.mkForce false;
|
|
})
|
|
];
|
|
};
|
|
|
|
# Build and activate with `nix build .#cloudVM.activationPackage; ./result/activate`
|
|
cloudVM = home-manager.lib.homeManagerConfiguration {
|
|
system = "x86_64-linux";
|
|
stateVersion = homeManagerStateVersion;
|
|
homeDirectory = "/home/mat";
|
|
username = "mat";
|
|
configuration = {
|
|
imports = [ homeManagerCommonConfig ];
|
|
nixpkgs = nixpkgsConfig;
|
|
};
|
|
};
|
|
|
|
# attrValues self.darwinModules ++ [
|
|
# # Main `nix-darwin` config
|
|
# ./configuration.nix
|
|
# # `home-manager` module
|
|
# home-manager.darwinModules.home-manager
|
|
# {
|
|
# nixpkgs = nixpkgsConfig;
|
|
# # `home-manager` config
|
|
# home-manager.useGlobalPkgs = true;
|
|
# home-manager.useUserPackages = true;
|
|
# home-manager.users.mat = import ./home.nix;
|
|
# }
|
|
# ];
|
|
# };
|
|
};
|
|
|
|
# Overlays --------------------------------------------------------------- {{{
|
|
|
|
overlays = {
|
|
# nixpkgs overlays
|
|
pkgs-stable = final: prev: {
|
|
pkgs-stable = import inputs.nixpkgs {
|
|
inherit (prev.stdenv) system;
|
|
inherit (nixpkgsConfig) config;
|
|
};
|
|
};
|
|
|
|
pkgs-unstable = final: prev: {
|
|
pkgs-unstable = import inputs.nixpkgs-unstable {
|
|
inherit (prev.stdenv) system;
|
|
inherit (nixpkgsConfig) config;
|
|
};
|
|
};
|
|
|
|
pkgs-master = final: prev: {
|
|
pkgs-master = import inputs.nixpkgs-master {
|
|
inherit (prev.stdenv) system;
|
|
inherit (nixpkgsConfig) config;
|
|
};
|
|
};
|
|
|
|
colors = import ./overlays/colors.nix;
|
|
|
|
# Overlay useful on Macs with Apple Silicon
|
|
apple-silicon = final: prev: optionalAttrs (prev.stdenv.system == "aarch64-darwin") {
|
|
# Add access to x86 packages system is running Apple Silicon
|
|
pkgs-x86 = import inputs.nixpkgs-unstable {
|
|
system = "x86_64-darwin";
|
|
inherit (nixpkgsConfig) config;
|
|
};
|
|
};
|
|
|
|
patched = final: prev: optionalAttrs prev.stdenv.isDarwin {
|
|
lib = prev.lib // {
|
|
homebrew-enabled = inputs.homebrew-enabled.value;
|
|
};
|
|
};
|
|
};
|
|
|
|
# `nix-darwin` modules (some are pending upstream acceptance)
|
|
darwinModules = {
|
|
programs-nix-index = import ./modules/darwin/programs/nix-index.nix;
|
|
security-pam = import ./modules/darwin/security/pam.nix;
|
|
users = import ./modules/darwin/users.nix;
|
|
};
|
|
|
|
# home manager configurations
|
|
homeManagerModules = {
|
|
# configs-git-aliases = import ./home/configs/git-aliases.nix;
|
|
# configs-gh-aliases = import ./home/configs/gh-aliases.nix;
|
|
configs-starship-symbols = import ./home/configs/starship-symbols.nix;
|
|
programs-kakoune-extras = import ./modules/home/programs/kakoune/extras.nix;
|
|
programs-kitty-extras = import ./modules/home/programs/kitty/extras.nix;
|
|
};
|
|
|
|
} // flake-utils.lib.eachDefaultSystem (system: {
|
|
legacyPackages = import inputs.nixpkgs-unstable {
|
|
inherit system;
|
|
inherit (nixpkgsConfig) config;
|
|
overlays = with self.overlays; [
|
|
pkgs-master
|
|
pkgs-stable
|
|
colors
|
|
apple-silicon
|
|
patched
|
|
];
|
|
};
|
|
});
|
|
}
|