dotfiles.nix/lib/mkDarwinSystem.nix

55 lines
1.8 KiB
Nix

# taken from https://github.com/malob/nixpkgs/blob/27e04346555277687a60c0168969b3945c2b25ba/lib/mkDarwinSystem.nix
self: inputs: nixpkgs:
{ primaryUser, system ? "aarch64-darwin"
# `nix-darwin` modules to include
, modules ? [ ]
# Additional `nix-darwin` modules to include, useful when reusing a configuration with
# `lib.makeOverridable`.
, extraModules ? [ ]
# Value for `home-manager`'s `home.stateVersion` option.
, homeStateVersion
# `home-manager` modules to include
, homeModules ? [ ]
# Additional `home-manager` modules to include, useful when reusing a configuration with
# `lib.makeOverridable`.
, extraHomeModules ? [ ] }:
inputs.darwin.lib.darwinSystem {
inherit system;
modules = modules ++ extraModules ++ [
inputs.home-manager.darwinModules.home-manager
({ config, ... }:
let cfg = config.users.primaryUser;
in {
users.primaryUser = primaryUser;
inherit nixpkgs;
# Support legacy workflows that use `<nixpkgs>` etc.
nix.nixPath = {
nixpkgs = "${inputs.nixpkgs}";
darwin = "${inputs.darwin}";
};
# `home-manager` config
users.users.${cfg.username}.home = cfg.homeDirectory;
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.${cfg.username} = {
imports = homeModules ++ extraHomeModules;
home.stateVersion = homeStateVersion;
home.primaryUser = primaryUser;
home.homeDirectory = cfg.homeDirectory;
home.enableNixpkgsReleaseCheck = true;
};
# Make sure nixpkgs#pkg refers to this nixpkgs
nix.registry.nixpkgs.flake = inputs.nixpkgs;
# Add this flake to the registry
nix.registry.my.flake = self;
})
];
}